Merge branch 'master' into glance-column-change

This commit is contained in:
Zack Arnett 2018-10-17 15:06:29 -04:00 committed by GitHub
commit a113c71de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 12037 additions and 12034 deletions

View File

@ -91,7 +91,6 @@
"devDependencies": { "devDependencies": {
"@babel/core": "^7.1.2", "@babel/core": "^7.1.2",
"@babel/plugin-external-helpers": "^7.0.0", "@babel/plugin-external-helpers": "^7.0.0",
"@babel/plugin-proposal-class-properties": "7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0", "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0", "@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-transform-react-jsx": "^7.0.0", "@babel/plugin-transform-react-jsx": "^7.0.0",
@ -165,9 +164,14 @@
} }
}, },
"lint-staged": { "lint-staged": {
"*.{js,json,css,md}": [ "linters": {
"prettier --write", "*.{js,json,css,md}": [
"git add" "prettier --write",
"git add"
]
},
"ignore": [
"translations/**"
] ]
}, },
"prettier": { "prettier": {

View File

@ -28,7 +28,7 @@ mkdir -p ${LOCAL_DIR}
docker run \ docker run \
-v ${LOCAL_DIR}:/opt/dest/locale \ -v ${LOCAL_DIR}:/opt/dest/locale \
lokalise/lokalise-cli@sha256:ddf5677f58551261008342df5849731c88bcdc152ab645b133b21819aede8218 lokalise \ lokalise/lokalise-cli@sha256:b8329d20280263cad04f65b843e54b9e8e6909a348a678eac959550b5ef5c75f lokalise \
--token ${LOKALISE_TOKEN} \ --token ${LOKALISE_TOKEN} \
export ${PROJECT_ID} \ export ${PROJECT_ID} \
--export_empty skip \ --export_empty skip \

View File

@ -1,7 +1,7 @@
from setuptools import setup, find_packages from setuptools import setup, find_packages
setup(name='home-assistant-frontend', setup(name='home-assistant-frontend',
version='20181014.0', version='20181017.0',
description='The Home Assistant frontend', description='The Home Assistant frontend',
url='https://github.com/home-assistant/home-assistant-polymer', url='https://github.com/home-assistant/home-assistant-polymer',
author='The Home Assistant Authors', author='The Home Assistant Authors',

View File

@ -11,13 +11,13 @@ import {
LocalizeMixin, LocalizeMixin,
} from "./localize-base-mixin"; } from "./localize-base-mixin";
export const HassLocalizeLitMixin = ( export const HassLocalizeLitMixin = <T extends LitElement>(
superClass: Constructor<LitElement> superClass: Constructor<T>
): Constructor<LitElement & LocalizeMixin> => ): Constructor<T & LocalizeMixin> =>
// @ts-ignore // @ts-ignore
class extends LocalizeBaseMixin(superClass) { class extends LocalizeBaseMixin(superClass) {
protected hass?: HomeAssistant; protected hass?: HomeAssistant;
protected localize?: LocalizeFunc; protected localize!: LocalizeFunc;
static get properties(): PropertyDeclarations { static get properties(): PropertyDeclarations {
return { return {

View File

@ -199,15 +199,23 @@ class HaConfigCloudAccount extends EventsMixin(LocalizeMixin(PolymerElement)) {
} }
_formatSubscription(subInfo) { _formatSubscription(subInfo) {
return subInfo === null if (subInfo === null) {
? "Fetching subscription…" return "Fetching subscription…";
: subInfo.human_description.replace( }
"{periodEnd}",
formatDateTime( let description = subInfo.human_description;
new Date(subInfo.subscription.current_period_end * 1000),
this.language if (subInfo.plan_renewal_date) {
) description = description.replace(
); "{periodEnd}",
formatDateTime(
new Date(subInfo.plan_renewal_date * 1000),
this.language
)
);
}
return description;
} }
_alexaChanged(ev) { _alexaChanged(ev) {

View File

@ -107,8 +107,9 @@ class HaConfigCloud extends NavigateMixin(PolymerElement) {
timeOut.after(0), timeOut.after(0),
() => { () => {
if ( if (
!this.cloudStatus.logged_in && !this.cloudStatus ||
!NOT_LOGGED_IN_URLS.includes(route.path) (!this.cloudStatus.logged_in &&
!NOT_LOGGED_IN_URLS.includes(route.path))
) { ) {
this.navigate("/config/cloud/login", true); this.navigate("/config/cloud/login", true);
} else if ( } else if (

View File

@ -8,6 +8,7 @@ import isValidEntityId from "../../../common/entity/valid_entity_id.js";
import stateIcon from "../../../common/entity/state_icon.js"; import stateIcon from "../../../common/entity/state_icon.js";
import computeStateDomain from "../../../common/entity/compute_state_domain.js"; import computeStateDomain from "../../../common/entity/compute_state_domain.js";
import computeStateName from "../../../common/entity/compute_state_name.js"; import computeStateName from "../../../common/entity/compute_state_name.js";
import applyThemesOnElement from "../../../common/dom/apply_themes_on_element.js";
import { styleMap } from "lit-html/directives/styleMap.js"; import { styleMap } from "lit-html/directives/styleMap.js";
import { HomeAssistant } from "../../../types.js"; import { HomeAssistant } from "../../../types.js";
import { HassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin"; import { HassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
@ -17,34 +18,36 @@ interface Config extends LovelaceConfig {
entity: string; entity: string;
name?: string; name?: string;
icon?: string; icon?: string;
theme?: string;
tap_action?: "toggle" | "call-service" | "more-info"; tap_action?: "toggle" | "call-service" | "more-info";
service?: string; service?: string;
service_data?: object; service_data?: object;
} }
class HuiEntityButtonCard extends HassLocalizeLitMixin(LitElement) class HuiEntityButtonCard extends HassLocalizeLitMixin(LitElement)
implements LovelaceCard { implements LovelaceCard {
static get properties(): PropertyDeclarations {
return {
hass: {}
};
}
protected hass?: HomeAssistant; protected hass?: HomeAssistant;
protected config?: Config; protected config?: Config;
static get properties(): PropertyDeclarations {
return {
hass: {},
config: {},
};
}
public getCardSize() { public getCardSize() {
return 2; return 2;
} }
public setConfig(config: Config) { public setConfig(config: Config) {
if(!isValidEntityId(config.entity)) { if (!isValidEntityId(config.entity)) {
throw new Error("Invalid Entity"); throw new Error("Invalid Entity");
} }
this.config = config; this.config = { theme: "default", ...config };
if(this.hass) { if (this.hass) {
this.requestUpdate(); this.requestUpdate();
} }
} }
@ -54,26 +57,36 @@ implements LovelaceCard {
return html``; return html``;
} }
const stateObj = this.hass!.states[this.config.entity]; const stateObj = this.hass!.states[this.config.entity];
applyThemesOnElement(this, this.hass!.themes, this.config.theme);
return html` return html`
${this.renderStyle()} ${this.renderStyle()}
<ha-card @click="${this.handleClick}"> <ha-card @click="${this.handleClick}">
${ ${
!stateObj !stateObj
? html`<div class="not-found">Entity not available: ${this.config.entity}</div>` ? html`<div class="not-found">Entity not available: ${
: html` this.config.entity
}</div>`
: html`
<paper-button> <paper-button>
<div> <div>
<ha-icon <ha-icon
data-domain="${computeStateDomain(stateObj)}" data-domain="${computeStateDomain(stateObj)}"
data-state="${stateObj.state}" data-state="${stateObj.state}"
.icon="${this.config.icon ? this.config.icon : stateIcon(stateObj)}" .icon="${
style="${styleMap({filter: this._computeBrightness(stateObj), color: this._computeColor(stateObj)})}" this.config.icon ? this.config.icon : stateIcon(stateObj)
}"
style="${styleMap({
filter: this._computeBrightness(stateObj),
color: this._computeColor(stateObj),
})}"
></ha-icon> ></ha-icon>
<span> <span>
${this.config.name ${
? this.config.name this.config.name
: computeStateName(stateObj) ? this.config.name
: computeStateName(stateObj)
} }
</span> </span>
</div> </div>
@ -131,15 +144,15 @@ implements LovelaceCard {
const brightness = stateObj.attributes.brightness; const brightness = stateObj.attributes.brightness;
return `brightness(${(brightness + 245) / 5}%)`; return `brightness(${(brightness + 245) / 5}%)`;
} }
private _computeColor(stateObj) { private _computeColor(stateObj) {
if (!stateObj.attributes.hs_color) { if (!stateObj.attributes.hs_color) {
return ''; return "";
} }
const hue = stateObj.attributes.hs_color[0]; const hue = stateObj.attributes.hs_color[0];
const sat = stateObj.attributes.hs_color[1]; const sat = stateObj.attributes.hs_color[1];
if (sat <= 10) { if (sat <= 10) {
return ''; return "";
} }
return `hsl(${hue}, 100%, ${100 - sat / 2}%)`; return `hsl(${hue}, 100%, ${100 - sat / 2}%)`;
} }
@ -150,7 +163,7 @@ implements LovelaceCard {
return; return;
} }
const stateObj = this.hass!.states[config.entity]; const stateObj = this.hass!.states[config.entity];
if(!stateObj) { if (!stateObj) {
return; return;
} }
const entityId = stateObj.entity_id; const entityId = stateObj.entity_id;
@ -159,7 +172,7 @@ implements LovelaceCard {
toggleEntity(this.hass, entityId); toggleEntity(this.hass, entityId);
break; break;
case "call-service": { case "call-service": {
if(!config.service){ if (!config.service) {
return; return;
} }
const [domain, service] = config.service.split(".", 2); const [domain, service] = config.service.split(".", 2);

View File

@ -1,10 +1,11 @@
import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; import { html, LitElement } from "@polymer/lit-element";
import { classMap } from "lit-html/directives/classMap.js"; import { classMap } from "lit-html/directives/classMap.js";
import { repeat } from "lit-html/directives/repeat"; import { repeat } from "lit-html/directives/repeat";
import computeStateDisplay from "../../../common/entity/compute_state_display.js"; import computeStateDisplay from "../../../common/entity/compute_state_display.js";
import computeStateName from "../../../common/entity/compute_state_name.js"; import computeStateName from "../../../common/entity/compute_state_name.js";
import processConfigEntities from "../common/process-config-entities"; import processConfigEntities from "../common/process-config-entities";
import applyThemesOnElement from "../../../common/dom/apply_themes_on_element.js";
import toggleEntity from "../common/entity/toggle-entity.js"; import toggleEntity from "../common/entity/toggle-entity.js";
@ -30,27 +31,30 @@ interface Config extends LovelaceConfig {
show_name?: boolean; show_name?: boolean;
show_state?: boolean; show_state?: boolean;
title?: string; title?: string;
theming?: "primary"; column_width?: string;
theme?: string;
entities: EntityConfig[]; entities: EntityConfig[];
} }
class HuiGlanceCard extends HassLocalizeLitMixin(LitElement) export class HuiGlanceCard extends HassLocalizeLitMixin(LitElement)
implements LovelaceCard { implements LovelaceCard {
static get properties(): PropertyDeclarations {
return {
hass: {},
};
}
protected hass?: HomeAssistant; protected hass?: HomeAssistant;
protected config?: Config; protected config?: Config;
protected configEntities?: EntityConfig[]; protected configEntities?: EntityConfig[];
static get properties() {
return {
hass: {},
config: {},
};
}
public getCardSize() { public getCardSize() {
return 3; return 3;
} }
public setConfig(config: Config) { public setConfig(config: Config) {
this.config = config; this.config = { theme: "default", ...config };
const entities = processConfigEntities(config.entities); const entities = processConfigEntities(config.entities);
for (const entity of entities) { for (const entity of entities) {
@ -66,13 +70,6 @@ class HuiGlanceCard extends HassLocalizeLitMixin(LitElement)
this.style.setProperty("--glance-column-width", columnWidth); this.style.setProperty("--glance-column-width", columnWidth);
if (config.theming) {
if (typeof config.theming !== "string") {
throw new Error("Incorrect theming config.");
}
this.classList.add(`theme-${config.theming}`);
}
this.configEntities = entities; this.configEntities = entities;
if (this.hass) { if (this.hass) {
@ -90,6 +87,8 @@ class HuiGlanceCard extends HassLocalizeLitMixin(LitElement)
(conf) => conf.entity in states (conf) => conf.entity in states
); );
applyThemesOnElement(this, this.hass!.themes, this.config.theme);
return html` return html`
${this.renderStyle()} ${this.renderStyle()}
<ha-card .header="${title}"> <ha-card .header="${title}">
@ -107,11 +106,6 @@ class HuiGlanceCard extends HassLocalizeLitMixin(LitElement)
private renderStyle() { private renderStyle() {
return html` return html`
<style> <style>
:host(.theme-primary) {
--paper-card-background-color:var(--primary-color);
--paper-item-icon-color:var(--text-primary-color);
color:var(--text-primary-color);
}
.entities { .entities {
display: flex; display: flex;
padding: 0 16px 4px; padding: 0 16px 4px;

View File

@ -13,7 +13,7 @@ class HuiVerticalStackCard extends PolymerElement {
flex-direction: column; flex-direction: column;
} }
#root > * { #root > * {
margin: 4px 0 8px 0; margin: 4px 0 4px 0;
} }
#root > *:first-child { #root > *:first-child {
margin-top: 0; margin-top: 0;

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,8 @@
"dev-templates": "Skabeloner", "dev-templates": "Skabeloner",
"dev-mqtt": "MQTT", "dev-mqtt": "MQTT",
"dev-info": "Udvikler Information", "dev-info": "Udvikler Information",
"calendar": "Kalender" "calendar": "Kalender",
"profile": "Profil"
}, },
"state": { "state": {
"default": { "default": {
@ -379,7 +380,8 @@
"state": { "state": {
"label": "Tilstand", "label": "Tilstand",
"from": "Fra", "from": "Fra",
"to": "Til" "to": "Til",
"for": "Varighed"
}, },
"homeassistant": { "homeassistant": {
"label": "Home Assistant", "label": "Home Assistant",
@ -524,6 +526,31 @@
"deactivate_user": "Deaktiver bruger", "deactivate_user": "Deaktiver bruger",
"delete_user": "Slet bruger" "delete_user": "Slet bruger"
} }
},
"cloud": {
"caption": "Home Assistant Cloud",
"description_login": "Logget ind som {email}",
"description_not_login": "Ikke logget ind"
},
"integrations": {
"caption": "Integrationer",
"description": "Administrer tilsluttede enheder og tjenester",
"discovered": "Opdaget",
"configured": "Konfigureret",
"new": "Opret en ny integration",
"configure": "Konfigurer",
"none": "Ikke konfigureret",
"config_entry": {
"no_devices": "Denne integration har ingen enheder",
"no_device": "Entiteter uden enhed",
"delete_confirm": "Er du sikker på, at du vil fjerne denne integration?",
"restart_confirm": "Genstart Home Assistant for at afslutte fjernelsen af denne integration",
"manuf": "af {manufacturer}",
"hub": "Forbundet via",
"firmware": "Firmware: {version}",
"device_unavailable": "enhed utilgængelig",
"entity_unavailable": "entitet utilgængelig"
}
} }
}, },
"profile": { "profile": {
@ -571,6 +598,16 @@
"empty_state": "Du har ingen langtids adgangstokens endnu.", "empty_state": "Du har ingen langtids adgangstokens endnu.",
"last_used": "Sidst anvendt den {date} af {location}", "last_used": "Sidst anvendt den {date} af {location}",
"not_used": "Har aldrig været brugt" "not_used": "Har aldrig været brugt"
},
"current_user": "Du er logget ind som {fullName} .",
"is_owner": "Du er ejer.",
"logout": "Log af",
"mfa_setup": {
"title_aborted": "Afbrudt",
"title_success": "Succes!",
"step_done": "Opsætning af {step} færdig",
"close": "Luk",
"submit": "Gem og afslut"
} }
}, },
"page-authorize": { "page-authorize": {
@ -762,6 +799,7 @@
"target_humidity": "Ønsket luftfugtighed", "target_humidity": "Ønsket luftfugtighed",
"operation": "Drift", "operation": "Drift",
"fan_mode": "Ventilator tilstand", "fan_mode": "Ventilator tilstand",
"swing_mode": "Swing tilstand",
"away_mode": "Ude af huset-modus", "away_mode": "Ude af huset-modus",
"aux_heat": "Støtte-varme" "aux_heat": "Støtte-varme"
}, },
@ -778,6 +816,13 @@
"turn_on": "Tænd", "turn_on": "Tænd",
"turn_off": "Sluk" "turn_off": "Sluk"
} }
},
"water_heater": {
"currently": "Lige nu",
"on_off": "Tænd \/ sluk",
"target_temperature": "Ønsket temperatur",
"operation": "Drift",
"away_mode": "Ikke til stede"
} }
}, },
"components": { "components": {

View File

@ -833,7 +833,7 @@
}, },
"water_heater": { "water_heater": {
"currently": "Aktuell", "currently": "Aktuell",
"on_off": "An \/ aus", "on_off": "An \/ Aus",
"target_temperature": "Solltemperatur", "target_temperature": "Solltemperatur",
"operation": "Betrieb", "operation": "Betrieb",
"away_mode": "Abwesend-Modus" "away_mode": "Abwesend-Modus"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -391,7 +391,7 @@
}, },
"mqtt": { "mqtt": {
"label": "MQTT", "label": "MQTT",
"topic": "Заголовок", "topic": "Топик",
"payload": "Значение (опционально)" "payload": "Значение (опционально)"
}, },
"numeric_state": { "numeric_state": {
@ -427,7 +427,7 @@
}, },
"conditions": { "conditions": {
"header": "Условия", "header": "Условия",
"introduction": "Условия являются необязательной частью правила автоматизации и могут использоваться для предотвращения действия при срабатывании. С первого взгляда может показаться, что условия и триггеры это одно и то же, однако это не так. Триггер срабатывает непосредственно в момент, когда произошло событие, а условие лишь проверяет состояние системы в данный момент. Триггер может заметить, как был включен выключатель, условие же может видеть только текущее его состояние. \n\n[Подробнее об условиях.] (https:\/\/home-assistant.io\/docs\/scripts\/conditions\/)", "introduction": "Условия являются необязательной частью правила автоматизации и могут использоваться для предотвращения действия при срабатывании. С первого взгляда может показаться, что условия и триггеры это одно и то же, однако это не так. Триггер срабатывает непосредственно в момент, когда произошло событие, а условие лишь проверяет состояние системы в данный момент. Триггер может заметить, как был включен выключатель, условие же может видеть только текущее его состояние. \n\n[Подробнее об условиях.](https:\/\/home-assistant.io\/docs\/scripts\/conditions\/)",
"add": "Добавить условие", "add": "Добавить условие",
"duplicate": "Дублировать", "duplicate": "Дублировать",
"delete": "Удалить", "delete": "Удалить",
@ -443,7 +443,7 @@
"label": "Числовое состояние", "label": "Числовое состояние",
"above": "Выше", "above": "Выше",
"below": "Ниже", "below": "Ниже",
"value_template": "Значение шаблона (опционально)" "value_template": "Шаблон значения (опционально)"
}, },
"sun": { "sun": {
"label": "Солнце", "label": "Солнце",
@ -497,8 +497,8 @@
"label": "Условие" "label": "Условие"
}, },
"event": { "event": {
"label": "Событие", "label": "Создание события",
"event": "Событие", "event": "Событие:",
"service_data": "Данные службы" "service_data": "Данные службы"
} }
} }
@ -836,7 +836,7 @@
"on_off": "Вкл \/ Выкл", "on_off": "Вкл \/ Выкл",
"target_temperature": "Заданная температура", "target_temperature": "Заданная температура",
"operation": "Операция", "operation": "Операция",
"away_mode": "Режим ожидания" "away_mode": "Режим \"не дома\""
} }
}, },
"components": { "components": {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,6 @@
"noUnusedParameters": true, "noUnusedParameters": true,
"noImplicitReturns": true, "noImplicitReturns": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"experimentalDecorators": true,
"strict": true, "strict": true,
"noImplicitAny": false "noImplicitAny": false
} }

View File

@ -3,6 +3,7 @@
"rules": { "rules": {
"interface-name": false, "interface-name": false,
"no-submodule-imports": false, "no-submodule-imports": false,
"ordered-imports": false "ordered-imports": false,
"object-literal-sort-keys": false
} }
} }

673
yarn.lock

File diff suppressed because it is too large Load Diff