Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20200930.0 #7168

Merged
merged 65 commits into from
Sep 30, 2020
Merged
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ca1dacd
Update to actually set loading
zsarnett Sep 18, 2020
672b867
[ci skip] Translation update
homeassistant Sep 19, 2020
229ba3a
[ci skip] Translation update
homeassistant Sep 20, 2020
d538b61
Media Player Browser: Fix child names add tooltip (#7020)
zsarnett Sep 20, 2020
e6357e2
[ci skip] Translation update
homeassistant Sep 21, 2020
4b84696
Adopt --code-font-family (#6997)
KTibow Sep 21, 2020
f80bea2
Fix outline on mouseover in firefox (#7052)
thomasloven Sep 21, 2020
b4d34d9
Add Hours to show to the cache key (#7072)
zsarnett Sep 21, 2020
24b390b
Add actions to entities config struct (#7063)
zsarnett Sep 21, 2020
76db64c
Fix Calendar Title from not removing (#7058)
zsarnett Sep 21, 2020
6013394
Fix for NOT IN / IN Operators (#7061)
b3nj1 Sep 21, 2020
0fb3814
fix media icon diff (#7071)
zsarnett Sep 21, 2020
106f18a
Update Material Design Icons to v5.6.55 (#7081)
Sep 21, 2020
ad64657
[ci skip] Translation update
homeassistant Sep 22, 2020
25a2264
Use absolute URL for background image in media-control card (#7100)
thomasloven Sep 22, 2020
b9c41d8
Optimize images (#7091)
nvllsvm Sep 22, 2020
e7e7912
Fix wait for trigger (#7089)
bramkragten Sep 22, 2020
6d5c6e2
Show message when there are no add-ons (#7101)
ludeeus Sep 22, 2020
0304c0e
Fix sensor card from not working with detail (#7060)
zsarnett Sep 22, 2020
bd51188
Adds hassio-system-metrics (#7105)
ludeeus Sep 22, 2020
0894a30
[ci skip] Translation update
homeassistant Sep 23, 2020
b7d8ff6
Corrected password changed message in User panel (#7111)
bcrowie Sep 23, 2020
8668f0f
Progress circle when loading data (#7059)
zsarnett Sep 23, 2020
dde4a40
[ci skip] Translation update
homeassistant Sep 24, 2020
c39c408
cloud-webhooks cleanup (#7118)
ludeeus Sep 24, 2020
bbee94e
Prevent deletion of the owner user (#7116)
ludeeus Sep 24, 2020
f822fa0
Added icon for timestamp device class (#7117)
chemelli74 Sep 24, 2020
b2e2dbe
Merge ha-paper-slider into ha-slider (#7114)
thomasloven Sep 24, 2020
dac6ede
Humidifier icon for off state (#7113)
Shulyaka Sep 24, 2020
4ba6698
Support twice daily forecasts in weather-forecast-card (#6065)
rajlaud Sep 24, 2020
245c825
Add humidifier entity row (#6213)
Shulyaka Sep 24, 2020
a349e34
Card Editor: Special Row doesn't show warning (#7093)
zsarnett Sep 24, 2020
98dd21b
Revert lazy loading more info controls (#7123)
bramkragten Sep 24, 2020
003d559
Added icon for power on/off (#7124)
chemelli74 Sep 24, 2020
ea9f227
[ci skip] Translation update
homeassistant Sep 25, 2020
28050fc
Add upload snapshot dialog (#7115)
ludeeus Sep 25, 2020
9cf9e6e
Allow initial View in Calendar Card (#6982)
zsarnett Sep 25, 2020
412a5a6
[ci skip] Translation update
homeassistant Sep 26, 2020
da0658f
[ci skip] Translation update
homeassistant Sep 27, 2020
d9f4271
[ci skip] Translation update
homeassistant Sep 28, 2020
e9141d8
Calendar Card: Initial View Editor (#7135)
zsarnett Sep 28, 2020
dfb2a71
Add weekday to time contidion editor (#6848)
Misiu Sep 28, 2020
458ab9b
Add --ha-card-border-width (#7021)
KTibow Sep 28, 2020
4759c89
Bring back lazy load more info + helper (#7131)
bramkragten Sep 28, 2020
50e03d4
Add timeout to dev template renders (#7141)
bdraco Sep 28, 2020
6b77f08
Hide rpi_power entry during onboarding (#7001)
MartinHjelmare Sep 28, 2020
9dabce1
[ci skip] Translation update
homeassistant Sep 29, 2020
c445d4b
Update supported browsers for Cast
balloob Sep 29, 2020
51953bc
Change "persons" to "people" (#7037)
sampl Sep 29, 2020
f48a282
More-Info Dialog Logbook Bug Fix (#7152)
Brahmah Sep 29, 2020
590cd85
Restore snapshot from onboarding (#7132)
ludeeus Sep 29, 2020
2f21f6e
Add unit_of_measurement to input-number-entity-row (#6965)
ludeeus Sep 29, 2020
a214ab4
Add last_updated tooltip to more info dialog (#6926)
pszafer Sep 29, 2020
7d1f9f3
Add LocalizeMixin to state-info
bramkragten Sep 29, 2020
9ac777d
Add default to action editor (#7006)
zsarnett Sep 29, 2020
10d7158
[ci skip] Translation update
homeassistant Sep 30, 2020
4f5b4d4
Calendar Card: Fix Calendar not updating events on config change (#7165)
zsarnett Sep 30, 2020
d0c86ea
Use ieee for zha.remove service data (#7163)
Adminiuga Sep 30, 2020
2616281
Expand error msg on why yaml defined entities can't be changed from U…
mrand Sep 30, 2020
e2427c8
Logbook: Localize Message & Style updates (#6978)
zsarnett Sep 30, 2020
d2e9e22
Add media player to cast app (#7160)
bramkragten Sep 30, 2020
2eb7132
Merge branch 'master' into dev
bramkragten Sep 30, 2020
0456669
Bumped version to 20200930.0
bramkragten Sep 30, 2020
4f2bad0
Fix safari issues and move scrollable to own container (#7029)
bramkragten Sep 30, 2020
771c751
Custom Lovelace View Layouts (#6557)
zsarnett Sep 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adds hassio-system-metrics (#7105)
ludeeus authored Sep 22, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit bd511887a783512a727f9dfd33dc20ca9d8d9bcf
168 changes: 168 additions & 0 deletions hassio/src/system/hassio-system-metrics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
import "@material/mwc-button";
import "@material/mwc-list/mwc-list-item";
import {
css,
CSSResult,
customElement,
html,
internalProperty,
LitElement,
property,
TemplateResult,
} from "lit-element";
import { classMap } from "lit-html/directives/class-map";
import memoizeOne from "memoize-one";
import "../../../src/components/buttons/ha-progress-button";
import "../../../src/components/ha-bar";
import "../../../src/components/ha-button-menu";
import "../../../src/components/ha-card";
import "../../../src/components/ha-settings-row";
import { fetchHassioStats, HassioStats } from "../../../src/data/hassio/common";
import { HassioHostInfo } from "../../../src/data/hassio/host";
import { haStyle } from "../../../src/resources/styles";
import { HomeAssistant } from "../../../src/types";
import {
getValueInPercentage,
roundWithOneDecimal,
} from "../../../src/util/calculate";
import { hassioStyle } from "../resources/hassio-style";

@customElement("hassio-system-metrics")
class HassioSystemMetrics extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;

@property() public hostInfo!: HassioHostInfo;

@internalProperty() private _supervisorMetrics?: HassioStats;

@internalProperty() private _coreMetrics?: HassioStats;

protected render(): TemplateResult | void {
const usedSpace = this._getUsedSpace(this.hostInfo);
const metrics = [
{
description: "Core CPU usage",
value: this._coreMetrics?.cpu_percent,
},
{
description: "Core RAM usage",
value: this._coreMetrics?.memory_percent,
},
{
description: "Supervisor CPU usage",
value: this._supervisorMetrics?.cpu_percent,
},
{
description: "Supervisor RAM usage",
value: this._supervisorMetrics?.memory_percent,
},
{
description: "Used space",
value: usedSpace,
},
];

return html`
<ha-card header="System metrics">
<div class="card-content">
${metrics.map((metric) =>
this._renderMetric(metric.description, metric.value ?? 0)
)}
</div>
</ha-card>
`;
}

protected firstUpdated(): void {
this._loadData();
}

private _renderMetric(description: string, value: number): TemplateResult {
const roundedValue = roundWithOneDecimal(value);
return html`<ha-settings-row>
<span slot="heading">
${description}
</span>
<div slot="description">
<span class="value">
${roundedValue}%
</span>
<ha-bar
class="${classMap({
"target-warning": roundedValue > 50,
"target-critical": roundedValue > 85,
})}"
.value=${value}
></ha-bar>
</div>
</ha-settings-row>`;
}

private _getUsedSpace = memoizeOne((hostInfo: HassioHostInfo) =>
roundWithOneDecimal(
getValueInPercentage(hostInfo.disk_used, 0, hostInfo.disk_total)
)
);

private async _loadData(): Promise<void> {
const [supervisor, core] = await Promise.all([
fetchHassioStats(this.hass, "supervisor"),
fetchHassioStats(this.hass, "core"),
]);
this._supervisorMetrics = supervisor;
this._coreMetrics = core;
}

static get styles(): CSSResult[] {
return [
haStyle,
hassioStyle,
css`
ha-card {
height: 100%;
justify-content: space-between;
flex-direction: column;
display: flex;
}
ha-settings-row {
padding: 0;
height: 54px;
width: 100%;
}
ha-settings-row > div[slot="description"] {
white-space: normal;
color: var(--secondary-text-color);
display: flex;
justify-content: space-between;
}
ha-bar {
--ha-bar-primary-color: var(
--hassio-bar-ok-color,
var(--success-color)
);
}
.target-warning {
--ha-bar-primary-color: var(
--hassio-bar-warning-color,
var(--warning-color)
);
}
.target-critical {
--ha-bar-primary-color: var(
--hassio-bar-critical-color,
var(--error-color)
);
}
.value {
width: 42px;
}
`,
];
}
}

declare global {
interface HTMLElementTagNameMap {
"hassio-system-metrics": HassioSystemMetrics;
}
}
5 changes: 5 additions & 0 deletions hassio/src/system/hassio-system.ts
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ import { hassioStyle } from "../resources/hassio-style";
import "./hassio-host-info";
import "./hassio-supervisor-info";
import "./hassio-supervisor-log";
import "./hassio-system-metrics";

@customElement("hassio-system")
class HassioSystem extends LitElement {
@@ -64,6 +65,10 @@ class HassioSystem extends LitElement {
.hostInfo=${this.hostInfo}
.hassOsInfo=${this.hassOsInfo}
></hassio-host-info>
<hassio-system-metrics
.hass=${this.hass}
.hostInfo=${this.hostInfo}
></hassio-system-metrics>
</div>
<hassio-supervisor-log .hass=${this.hass}></hassio-supervisor-log>
</div>
25 changes: 25 additions & 0 deletions src/data/hassio/common.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import { HomeAssistant } from "../../types";

export interface HassioResponse<T> {
data: T;
result: "ok";
}

export interface HassioStats {
blk_read: number;
blk_write: number;
cpu_percent: number;
memory_limit: number;
memory_percent: number;
memory_usage: number;
network_rx: number;
network_tx: number;
}

export const hassioApiResultExtractor = <T>(response: HassioResponse<T>) =>
response.data;

@@ -15,3 +28,15 @@ export const extractApiErrorMessage = (error: any): string => {
};

export const ignoredStatusCodes = new Set([502, 503, 504]);

export const fetchHassioStats = async (
hass: HomeAssistant,
container: string
): Promise<HassioStats> => {
return hassioApiResultExtractor(
await hass.callApi<HassioResponse<HassioStats>>(
"GET",
`hassio/${container}/stats`
)
);
};