Skip to content

Commit eb4ba4f

Browse files
authored
Merge pull request home-assistant#5620 from home-assistant/dev
2 parents b2f424a + bf888b1 commit eb4ba4f

File tree

133 files changed

+1644
-785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+1644
-785
lines changed

.prettierignore

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,10 @@ build
22
build-translations/*
33
translations/*
44
node_modules/*
5-
npm-debug.log
6-
.DS_Store
75
hass_frontend/*
8-
.reify-cache
96
demo/hademo-icons.html
10-
11-
# Python stuff
12-
*.py[cod]
13-
*.egg
14-
*.egg-info
15-
16-
# venv stuff
17-
pyvenv.cfg
187
pip-selfcheck.json
19-
venv
20-
.venv
21-
lib
22-
bin
23-
dist
248

259
# vscode
2610
.vscode/*
2711
!.vscode/extensions.json
28-
29-
# Cast dev settings
30-
src/cast/dev_const.ts
31-
32-
# Secrets
33-
.lokalise_token
34-
yarn-error.log
35-
36-
#asdf
37-
.tool-versions

cast/src/launcher/layout/hc-cast.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
import "../../../../src/layouts/loading-screen";
3333
import { generateDefaultViewConfig } from "../../../../src/panels/lovelace/common/generate-lovelace-config";
3434
import "./hc-layout";
35+
import "@material/mwc-button/mwc-button";
3536

3637
@customElement("hc-cast")
3738
class HcCast extends LitElement {

hassio/src/addon-view/hassio-addon-view.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import "./hassio-addon-config";
2424
import "./hassio-addon-info";
2525
import "./hassio-addon-logs";
2626
import "./hassio-addon-network";
27+
import "../../../src/layouts/hass-subpage";
2728

2829
@customElement("hassio-addon-view")
2930
class HassioAddonView extends LitElement {

hassio/src/snapshots/hassio-snapshots.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class HassioSnapshots extends LitElement {
132132
(addon, idx) => html`
133133
<paper-checkbox
134134
.idx=${idx}
135-
.checked="{{item.checked}}"
135+
.checked=${addon.checked}
136136
@checked-changed=${this._addonChecked}
137137
>
138138
${addon.name}
@@ -202,7 +202,6 @@ class HassioSnapshots extends LitElement {
202202
.icon=${snapshot.type === "full"
203203
? "hassio:package-variant-closed"
204204
: "hassio:package-variant"}
205-
.
206205
.icon-class="snapshot"
207206
></hassio-card-content>
208207
</div>

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
"version": "1.0.0",
99
"scripts": {
1010
"build": "script/build_frontend",
11-
"lint:eslint": "eslint '{**/src,src}/**/*.{js,ts,html}' --ignore-path .gitignore",
12-
"format:eslint": "eslint '{**/src,src}/**/*.{js,ts,html}' --fix --ignore-path .gitignore",
13-
"lint:prettier": "prettier '{**/src,src}/**/*.{js,ts,json,css,md}' --check",
14-
"format:prettier": "prettier '{**/src,src}/**/*.{js,ts,json,css,md}' --write",
11+
"lint:eslint": "eslint '**/src/**/*.{js,ts,html}' --ignore-path .gitignore",
12+
"format:eslint": "eslint '**/src/**/*.{js,ts,html}' --fix --ignore-path .gitignore",
13+
"lint:prettier": "prettier '**/src/**/*.{js,ts,json,css,md}' --check",
14+
"format:prettier": "prettier '**/src/**/*.{js,ts,json,css,md}' --write",
1515
"lint:types": "tsc",
16-
"lint:lit": "lit-analyzer '{**/src,src}/**/*.ts'",
16+
"lint:lit": "lit-analyzer '**/src/**/*.ts'",
1717
"lint": "npm run lint:eslint && npm run lint:prettier && npm run lint:types",
1818
"format": "npm run format:eslint && npm run format:prettier",
1919
"mocha": "node_modules/.bin/ts-mocha -p test-mocha/tsconfig.test.json --opts test-mocha/mocha.opts",

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="home-assistant-frontend",
5-
version="20200422.0",
5+
version="20200424.0",
66
description="The Home Assistant frontend",
77
url="https://github.com/home-assistant/home-assistant-polymer",
88
author="The Home Assistant Authors",

src/common/entity/compute_state_display.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { HassEntity } from "home-assistant-js-websocket";
2+
import { UNAVAILABLE, UNKNOWN } from "../../data/entity";
3+
import { atLeastCachedVersion } from "../config/version";
24
import { formatDate } from "../datetime/format_date";
35
import { formatDateTime } from "../datetime/format_date_time";
46
import { formatTime } from "../datetime/format_time";
57
import { LocalizeFunc } from "../translations/localize";
68
import { computeStateDomain } from "./compute_state_domain";
7-
import { UNKNOWN, UNAVAILABLE } from "../../data/entity";
8-
import { atLeastCachedVersion } from "../config/version";
99

1010
const legacyComputeStateDisplay = (
1111
localize: LocalizeFunc,
@@ -96,7 +96,6 @@ export const computeStateDisplay = (
9696
return legacyComputeStateDisplay(localize, stateObj, language);
9797
}
9898

99-
// Real code.
10099
if (stateObj.state === UNKNOWN || stateObj.state === UNAVAILABLE) {
101100
return localize(`state.default.${stateObj.state}`);
102101
}
@@ -141,9 +140,15 @@ export const computeStateDisplay = (
141140
return formatDateTime(date, language);
142141
}
143142

144-
const deviceClass = stateObj.attributes.device_class || "_";
145143
return (
146-
localize(`component.${domain}.state.${deviceClass}.${stateObj.state}`) ||
144+
// Return device class translation
145+
(stateObj.attributes.device_class &&
146+
localize(
147+
`component.${domain}.state.${stateObj.attributes.device_class}.${stateObj.state}`
148+
)) ||
149+
// Return default translation
150+
localize(`component.${domain}.state._.${stateObj.state}`) ||
151+
// We don't know! Return the raw state.
147152
stateObj.state
148153
);
149154
};

src/components/device/ha-area-devices-picker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import "@material/mwc-button/mwc-button";
2+
import "@polymer/paper-icon-button/paper-icon-button";
13
import "@polymer/paper-input/paper-input";
24
import "@polymer/paper-item/paper-item";
35
import "@polymer/paper-item/paper-item-body";

src/components/device/ha-device-picker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "@polymer/paper-icon-button/paper-icon-button";
12
import "@polymer/paper-input/paper-input";
23
import "@polymer/paper-item/paper-item";
34
import "@polymer/paper-item/paper-item-body";

src/components/entity/ha-entity-picker.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
LitElement,
1212
property,
1313
PropertyValues,
14+
query,
1415
TemplateResult,
1516
} from "lit-element";
1617
import memoizeOne from "memoize-one";
@@ -91,12 +92,13 @@ class HaEntityPicker extends LitElement {
9192

9293
@property() public entityFilter?: HaEntityPickerEntityFilterFunc;
9394

94-
@property({ type: Boolean }) private _opened?: boolean;
95+
@property({ type: Boolean }) private _opened = false;
9596

96-
@property() private _hass?: HomeAssistant;
97+
@query("vaadin-combo-box-light") private _comboBox!: HTMLElement;
9798

9899
private _getStates = memoizeOne(
99100
(
101+
_opened: boolean,
100102
hass: this["hass"],
101103
includeDomains: this["includeDomains"],
102104
excludeDomains: this["excludeDomains"],
@@ -147,27 +149,28 @@ class HaEntityPicker extends LitElement {
147149
);
148150

149151
protected updated(changedProps: PropertyValues) {
150-
super.updated(changedProps);
151-
152-
if (changedProps.has("hass") && !this._opened) {
153-
this._hass = this.hass;
152+
if (changedProps.has("_opened") && this._opened) {
153+
const states = this._getStates(
154+
this._opened,
155+
this.hass,
156+
this.includeDomains,
157+
this.excludeDomains,
158+
this.entityFilter,
159+
this.includeDeviceClasses
160+
);
161+
(this._comboBox as any).items = states;
154162
}
155163
}
156164

157165
protected render(): TemplateResult {
158-
const states = this._getStates(
159-
this._hass,
160-
this.includeDomains,
161-
this.excludeDomains,
162-
this.entityFilter,
163-
this.includeDeviceClasses
164-
);
166+
if (!this.hass) {
167+
return html``;
168+
}
165169

166170
return html`
167171
<vaadin-combo-box-light
168172
item-value-path="entity_id"
169173
item-label-path="entity_id"
170-
.items=${states}
171174
.value=${this._value}
172175
.allowCustomValue=${this.allowCustomEntity}
173176
.renderer=${rowRenderer}
@@ -176,8 +179,8 @@ class HaEntityPicker extends LitElement {
176179
>
177180
<paper-input
178181
.autofocus=${this.autofocus}
179-
.label=${this.label === undefined && this._hass
180-
? this._hass.localize("ui.components.entity.entity-picker.entity")
182+
.label=${this.label === undefined
183+
? this.hass.localize("ui.components.entity.entity-picker.entity")
181184
: this.label}
182185
.value=${this._value}
183186
.disabled=${this.disabled}
@@ -190,7 +193,7 @@ class HaEntityPicker extends LitElement {
190193
${this.value
191194
? html`
192195
<paper-icon-button
193-
aria-label=${this.hass!.localize(
196+
aria-label=${this.hass.localize(
194197
"ui.components.entity.entity-picker.clear"
195198
)}
196199
slot="suffix"
@@ -203,20 +206,17 @@ class HaEntityPicker extends LitElement {
203206
</paper-icon-button>
204207
`
205208
: ""}
206-
${states.length > 0
207-
? html`
208-
<paper-icon-button
209-
aria-label=${this.hass!.localize(
210-
"ui.components.entity.entity-picker.show_entities"
211-
)}
212-
slot="suffix"
213-
class="toggle-button"
214-
.icon=${this._opened ? "hass:menu-up" : "hass:menu-down"}
215-
>
216-
Toggle
217-
</paper-icon-button>
218-
`
219-
: ""}
209+
210+
<paper-icon-button
211+
aria-label=${this.hass.localize(
212+
"ui.components.entity.entity-picker.show_entities"
213+
)}
214+
slot="suffix"
215+
class="toggle-button"
216+
.icon=${this._opened ? "hass:menu-up" : "hass:menu-down"}
217+
>
218+
Toggle
219+
</paper-icon-button>
220220
</paper-input>
221221
</vaadin-combo-box-light>
222222
`;

src/components/entity/ha-state-label-badge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import {
1111
} from "lit-element";
1212
import { classMap } from "lit-html/directives/class-map";
1313
import secondsToDuration from "../../common/datetime/seconds_to_duration";
14+
import { computeStateDisplay } from "../../common/entity/compute_state_display";
1415
import { computeStateDomain } from "../../common/entity/compute_state_domain";
1516
import { computeStateName } from "../../common/entity/compute_state_name";
1617
import { domainIcon } from "../../common/entity/domain_icon";
1718
import { stateIcon } from "../../common/entity/state_icon";
1819
import { timerTimeRemaining } from "../../common/entity/timer_time_remaining";
1920
import { HomeAssistant } from "../../types";
2021
import "../ha-label-badge";
21-
import { computeStateDisplay } from "../../common/entity/compute_state_display";
2222

2323
@customElement("ha-state-label-badge")
2424
export class HaStateLabelBadge extends LitElement {

src/components/ha-area-picker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "@polymer/paper-icon-button/paper-icon-button";
12
import "@polymer/paper-input/paper-input";
23
import "@polymer/paper-item/paper-item";
34
import "@polymer/paper-item/paper-item-body";

src/components/ha-climate-state.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class HaClimateState extends LocalizeMixin(PolymerElement) {
110110
}
111111

112112
_localizeState(localize, stateObj) {
113-
const stateString = localize(`state.climate.${stateObj.state}`);
113+
const stateString = localize(`component.climate.state._.${stateObj.state}`);
114114
return stateObj.attributes.hvac_action
115115
? `${localize(
116116
`state_attributes.climate.hvac_action.${stateObj.attributes.hvac_action}`

src/components/ha-fab.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ripple } from "@material/mwc-ripple/ripple-directive";
44
import { customElement, html, TemplateResult } from "lit-element";
55
import { classMap } from "lit-html/directives/class-map";
66
import type { Constructor } from "../types";
7+
import "./ha-icon";
78

89
const MwcFab = customElements.get("mwc-fab") as Constructor<Fab>;
910

src/components/ha-form/ha-form-multi_select.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "@polymer/iron-icon/iron-icon";
12
import "@polymer/paper-checkbox/paper-checkbox";
23
import "@polymer/paper-input/paper-input";
34
import "@polymer/paper-item/paper-icon-item";

src/components/ha-form/ha-form-positive_time_period_dict.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
TemplateResult,
88
} from "lit-element";
99
import { fireEvent } from "../../common/dom/fire_event";
10+
import "../paper-time-input";
1011
import { HaFormElement, HaFormTimeData, HaFormTimeSchema } from "./ha-form";
1112

1213
@customElement("ha-form-positive_time_period_dict")

src/components/ha-related-items.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable lit/no-invalid-html */
21
import { HassEntity, UnsubscribeFunc } from "home-assistant-js-websocket";
32
import {
43
css,
@@ -96,7 +95,7 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
9695
)}:
9796
</h3>
9897
<a
99-
href="/config/integrations#config_entry=${relatedConfigEntryId}"
98+
href=${`/config/integrations#config_entry=${relatedConfigEntryId}`}
10099
@click=${this._close}
101100
>
102101
${this.hass.localize(`component.${entry.domain}.title`)}:

src/components/ha-vacuum-state.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class HaVacuumState extends LocalizeMixin(PolymerElement) {
7676
? this.localize(
7777
`ui.card.vacuum.actions.${STATES_INTERCEPTABLE[state].action}`
7878
)
79-
: this.localize(`state.vacuum.${state}`);
79+
: this.localize(`component.vacuum._.${state}`);
8080
}
8181

8282
_callService(ev) {

src/components/ha-water_heater-state.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { html } from "@polymer/polymer/lib/utils/html-tag";
22
/* eslint-plugin-disable lit */
33
import { PolymerElement } from "@polymer/polymer/polymer-element";
4+
import { computeStateDisplay } from "../common/entity/compute_state_display";
45
import LocalizeMixin from "../mixins/localize-mixin";
56

67
/*
@@ -32,7 +33,7 @@ class HaWaterHeaterState extends LocalizeMixin(PolymerElement) {
3233
</style>
3334
3435
<div class="target">
35-
<span class="state-label"> [[_localizeState(stateObj.state)]] </span>
36+
<span class="state-label"> [[_localizeState(stateObj)]] </span>
3637
[[computeTarget(hass, stateObj)]]
3738
</div>
3839
@@ -67,8 +68,8 @@ class HaWaterHeaterState extends LocalizeMixin(PolymerElement) {
6768
return "";
6869
}
6970

70-
_localizeState(state) {
71-
return this.localize(`state.water_heater.${state}`) || state;
71+
_localizeState(stateObj) {
72+
return computeStateDisplay(this.hass.localize, stateObj);
7273
}
7374
}
7475
customElements.define("ha-water_heater-state", HaWaterHeaterState);

src/components/user/ha-user-picker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { fireEvent } from "../../common/dom/fire_event";
1717
import { compare } from "../../common/string/compare";
1818
import { fetchUsers, User } from "../../data/user";
1919
import { HomeAssistant } from "../../types";
20+
import "./ha-user-badge";
2021

2122
class HaUserPicker extends LitElement {
2223
public hass?: HomeAssistant;

src/dialogs/config-flow/show-dialog-config-flow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import {
88
getConfigFlowHandlers,
99
handleConfigFlowStep,
1010
} from "../../data/config_flow";
11+
import { domainToName } from "../../data/integration";
1112
import {
1213
DataEntryFlowDialogParams,
1314
loadDataEntryFlowDialog,
1415
showFlowDialog,
1516
} from "./show-dialog-data-entry-flow";
16-
import { domainToName } from "../../data/integration";
1717

1818
export const loadConfigFlowDialog = loadDataEntryFlowDialog;
1919

0 commit comments

Comments
 (0)