Update deps (#1678)

* Update deps

* Lint

* Fix lint
This commit is contained in:
Paulus Schoutsen 2018-09-19 15:15:16 +02:00 committed by GitHub
parent 085db3e0a6
commit 17ac6f96a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
123 changed files with 2036 additions and 1854 deletions

View File

@ -9,6 +9,7 @@
"parser": "babel-eslint", "parser": "babel-eslint",
"rules": { "rules": {
"import/no-unresolved": 2, "import/no-unresolved": 2,
"linebreak-style": 0 "linebreak-style": 0,
"implicit-arrow-linebreak": 0
} }
} }

View File

@ -43,11 +43,11 @@ class HassioAddonStore extends PolymerElement {
sortRepos(a, b) { sortRepos(a, b) {
if (a.slug === 'local') { if (a.slug === 'local') {
return -1; return -1;
} else if (b.slug === 'local') { } if (b.slug === 'local') {
return 1; return 1;
} else if (a.slug === 'core') { } if (a.slug === 'core') {
return -1; return -1;
} else if (b.slug === 'core') { } if (b.slug === 'core') {
return 1; return 1;
} }
return a.name < b.name ? -1 : 1; return a.name < b.name ? -1 : 1;

View File

@ -195,8 +195,8 @@ class HassioAddonInfo extends EventsMixin(PolymerElement) {
openChangelog() { openChangelog() {
this.hass.callApi('get', `hassio/addons/${this.addonSlug}/changelog`) this.hass.callApi('get', `hassio/addons/${this.addonSlug}/changelog`)
.then( .then(
resp => resp resp => resp,
, () => 'Error getting changelog' () => 'Error getting changelog'
).then((content) => { ).then((content) => {
this.fire('hassio-markdown-dialog', { this.fire('hassio-markdown-dialog', {
title: 'Changelog', title: 'Changelog',

View File

@ -2,4 +2,3 @@ window.loadES5Adapter().then(() => {
import(/* webpackChunkName: "hassio-icons" */ './resources/hassio-icons.js'); import(/* webpackChunkName: "hassio-icons" */ './resources/hassio-icons.js');
import(/* webpackChunkName: "hassio-main" */ './hassio-main.js'); import(/* webpackChunkName: "hassio-main" */ './hassio-main.js');
}); });

View File

@ -84,9 +84,9 @@ class HassioMain extends NavigateMixin(PolymerElement) {
} }
computeIsLoaded(supervisorInfo, hostInfo, hassInfo) { computeIsLoaded(supervisorInfo, hostInfo, hassInfo) {
return (supervisorInfo !== null && return (supervisorInfo !== null
hostInfo !== null && && hostInfo !== null
hassInfo !== null); && hassInfo !== null);
} }
routeChanged(route) { routeChanged(route) {

View File

@ -166,8 +166,9 @@ class HassioSnapshot extends PolymerElement {
return; return;
} }
const addons = this.snapshot.addons.filter(addon => addon.checked).map(addon => addon.slug); const addons = this.snapshot.addons.filter(addon => addon.checked).map(addon => addon.slug);
const folders = const folders = this.snapshot.folders.filter(
this.snapshot.folders.filter(folder => folder.checked).map(folder => folder.slug); folder => folder.checked
).map(folder => folder.slug);
const data = { const data = {
homeassistant: this.restoreHass, homeassistant: this.restoreHass,

View File

@ -145,8 +145,8 @@ class HassioHostInfo extends EventsMixin(PolymerElement) {
_showHardware() { _showHardware() {
this.hass.callApi('get', 'hassio/hardware/info') this.hass.callApi('get', 'hassio/hardware/info')
.then( .then(
resp => this._objectToMarkdown(resp.data) resp => this._objectToMarkdown(resp.data),
, () => 'Error getting hardware info' () => 'Error getting hardware info'
).then((content) => { ).then((content) => {
this.fire('hassio-markdown-dialog', { this.fire('hassio-markdown-dialog', {
title: 'Hardware', title: 'Hardware',

View File

@ -17,79 +17,79 @@
"author": "Paulus Schoutsen <Paulus@PaulusSchoutsen.nl> (http://paulusschoutsen.nl)", "author": "Paulus Schoutsen <Paulus@PaulusSchoutsen.nl> (http://paulusschoutsen.nl)",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@mdi/svg": "^2.4.85", "@mdi/svg": "^2.7.94",
"@polymer/app-layout": "^3.0.0-pre.19", "@polymer/app-layout": "^3.0.1",
"@polymer/app-localize-behavior": "^3.0.0-pre.19", "@polymer/app-localize-behavior": "^3.0.1",
"@polymer/app-route": "^3.0.0-pre.19", "@polymer/app-route": "^3.0.2",
"@polymer/app-storage": "^3.0.0-pre.19", "@polymer/app-storage": "^3.0.2",
"@polymer/font-roboto": "^3.0.0-pre.19", "@polymer/font-roboto": "^3.0.2",
"@polymer/font-roboto-local": "^3.0.0-pre.19", "@polymer/font-roboto-local": "^3.0.2",
"@polymer/iron-autogrow-textarea": "^3.0.0-pre.19", "@polymer/iron-autogrow-textarea": "^3.0.1",
"@polymer/iron-flex-layout": "^3.0.0-pre.19", "@polymer/iron-flex-layout": "^3.0.1",
"@polymer/iron-icon": "^3.0.0-pre.19", "@polymer/iron-icon": "^3.0.1",
"@polymer/iron-iconset-svg": "^3.0.0-pre.19", "@polymer/iron-iconset-svg": "^3.0.1",
"@polymer/iron-image": "^3.0.0-pre.19", "@polymer/iron-image": "^3.0.1",
"@polymer/iron-input": "^3.0.0-pre.19", "@polymer/iron-input": "^3.0.1",
"@polymer/iron-label": "^3.0.0-pre.19", "@polymer/iron-label": "^3.0.1",
"@polymer/iron-media-query": "^3.0.0-pre.19", "@polymer/iron-media-query": "^3.0.1",
"@polymer/iron-pages": "^3.0.0-pre.19", "@polymer/iron-pages": "^3.0.1",
"@polymer/iron-resizable-behavior": "^3.0.0-pre.19", "@polymer/iron-resizable-behavior": "^3.0.1",
"@polymer/neon-animation": "^3.0.0-pre.19", "@polymer/neon-animation": "^3.0.1",
"@polymer/paper-button": "^3.0.0-pre.19", "@polymer/paper-button": "^3.0.1",
"@polymer/paper-card": "^3.0.0-pre.19", "@polymer/paper-card": "^3.0.1",
"@polymer/paper-checkbox": "^3.0.0-pre.19", "@polymer/paper-checkbox": "^3.0.1",
"@polymer/paper-dialog": "^3.0.0-pre.19", "@polymer/paper-dialog": "^3.0.1",
"@polymer/paper-dialog-behavior": "^3.0.0-pre.19", "@polymer/paper-dialog-behavior": "^3.0.1",
"@polymer/paper-dialog-scrollable": "^3.0.0-pre.19", "@polymer/paper-dialog-scrollable": "^3.0.1",
"@polymer/paper-drawer-panel": "^3.0.0-pre.19", "@polymer/paper-drawer-panel": "^3.0.1",
"@polymer/paper-dropdown-menu": "^3.0.0-pre.19", "@polymer/paper-dropdown-menu": "^3.0.1",
"@polymer/paper-fab": "^3.0.0-pre.19", "@polymer/paper-fab": "^3.0.1",
"@polymer/paper-icon-button": "^3.0.0-pre.19", "@polymer/paper-icon-button": "^3.0.1",
"@polymer/paper-input": "^3.0.0-pre.19", "@polymer/paper-input": "^3.0.1",
"@polymer/paper-item": "^3.0.0-pre.19", "@polymer/paper-item": "^3.0.1",
"@polymer/paper-listbox": "^3.0.0-pre.19", "@polymer/paper-listbox": "^3.0.1",
"@polymer/paper-menu-button": "^3.0.0-pre.19", "@polymer/paper-menu-button": "^3.0.1",
"@polymer/paper-progress": "^3.0.0-pre.19", "@polymer/paper-progress": "^3.0.1",
"@polymer/paper-radio-button": "^3.0.0-pre.19", "@polymer/paper-radio-button": "^3.0.1",
"@polymer/paper-radio-group": "^3.0.0-pre.19", "@polymer/paper-radio-group": "^3.0.1",
"@polymer/paper-ripple": "^3.0.0-pre.19", "@polymer/paper-ripple": "^3.0.1",
"@polymer/paper-scroll-header-panel": "^3.0.0-pre.19", "@polymer/paper-scroll-header-panel": "^3.0.1",
"@polymer/paper-slider": "^3.0.0-pre.19", "@polymer/paper-slider": "^3.0.1",
"@polymer/paper-spinner": "^3.0.0-pre.19", "@polymer/paper-spinner": "^3.0.1",
"@polymer/paper-styles": "^3.0.0-pre.19", "@polymer/paper-styles": "^3.0.1",
"@polymer/paper-tabs": "^3.0.0-pre.19", "@polymer/paper-tabs": "^3.0.1",
"@polymer/paper-toast": "^3.0.0-pre.19", "@polymer/paper-toast": "^3.0.1",
"@polymer/paper-toggle-button": "^3.0.0-pre.19", "@polymer/paper-toggle-button": "^3.0.1",
"@polymer/paper-tooltip": "^3.0.0-pre.26", "@polymer/paper-tooltip": "^3.0.1",
"@polymer/polymer": "^3.0.2", "@polymer/polymer": "^3.0.5",
"@vaadin/vaadin-combo-box": "4.1.0-alpha2", "@vaadin/vaadin-combo-box": "4.2.0-alpha3",
"@vaadin/vaadin-date-picker": "3.2.0-alpha3", "@vaadin/vaadin-date-picker": "3.3.0-alpha1",
"@webcomponents/shadycss": "^1.3.1", "@webcomponents/shadycss": "^1.5.2",
"@webcomponents/webcomponentsjs": "^2.0.2", "@webcomponents/webcomponentsjs": "^2.1.3",
"chart.js": "~2.7.2", "chart.js": "~2.7.2",
"chartjs-chart-timeline": "^0.2.1", "chartjs-chart-timeline": "^0.2.1",
"es6-object-assign": "^1.1.0", "es6-object-assign": "^1.1.0",
"eslint-import-resolver-webpack": "^0.10.0", "eslint-import-resolver-webpack": "^0.10.1",
"fecha": "^2.3.3", "fecha": "^2.3.3",
"home-assistant-js-websocket": "^3.1.2", "home-assistant-js-websocket": "^3.1.4",
"intl-messageformat": "^2.2.0", "intl-messageformat": "^2.2.0",
"js-yaml": "^3.12.0", "js-yaml": "^3.12.0",
"leaflet": "^1.3.1", "leaflet": "^1.3.4",
"marked": "^0.4.0", "marked": "^0.5.0",
"mdn-polyfills": "^5.8.0", "mdn-polyfills": "^5.12.0",
"moment": "^2.22.2", "moment": "^2.22.2",
"preact": "^8.2.9", "preact": "^8.3.1",
"preact-compat": "^3.18.0", "preact-compat": "^3.18.4",
"react-big-calendar": "^0.19.1", "react-big-calendar": "^0.19.2",
"regenerator-runtime": "^0.11.1", "regenerator-runtime": "^0.12.1",
"unfetch": "^3.0.0", "unfetch": "^4.0.1",
"web-animations-js": "^2.3.1", "web-animations-js": "^2.3.1",
"xss": "^1.0.3" "xss": "^1.0.3"
}, },
"devDependencies": { "devDependencies": {
"@gfx/zopfli": "^1.0.8", "@gfx/zopfli": "^1.0.9",
"babel-core": "^6.26.3", "babel-core": "^6.26.3",
"babel-eslint": "^8.2.3", "babel-eslint": "^9.0.0",
"babel-loader": "^7.1.4", "babel-loader": "^7.1.4",
"babel-plugin-external-helpers": "^6.22.0", "babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0", "babel-plugin-syntax-dynamic-import": "^6.18.0",
@ -98,12 +98,12 @@
"babel-preset-es2015": "^6.24.1", "babel-preset-es2015": "^6.24.1",
"chai": "^4.1.2", "chai": "^4.1.2",
"compression-webpack-plugin": "^2.0.0", "compression-webpack-plugin": "^2.0.0",
"copy-webpack-plugin": "^4.5.1", "copy-webpack-plugin": "^4.5.2",
"del": "^3.0.0", "del": "^3.0.0",
"eslint": "^4.19.1", "eslint": "^5.6.0",
"eslint-config-airbnb-base": "^12.1.0", "eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.12.0", "eslint-plugin-import": "^2.14.0",
"eslint-plugin-react": "^7.9.1", "eslint-plugin-react": "^7.11.1",
"gulp": "^3.9.1", "gulp": "^3.9.1",
"gulp-foreach": "^0.1.0", "gulp-foreach": "^0.1.0",
"gulp-hash": "^4.2.2", "gulp-hash": "^4.2.2",
@ -111,36 +111,38 @@
"gulp-json-transform": "^0.4.5", "gulp-json-transform": "^0.4.5",
"gulp-jsonminify": "^1.1.0", "gulp-jsonminify": "^1.1.0",
"gulp-merge-json": "^1.3.1", "gulp-merge-json": "^1.3.1",
"gulp-rename": "^1.3.0", "gulp-rename": "^1.4.0",
"html-loader": "^0.5.5", "html-loader": "^0.5.5",
"html-minifier": "^3.5.16", "html-minifier": "^3.5.20",
"html-webpack-plugin": "^3.2.0", "html-webpack-plugin": "^3.2.0",
"merge-stream": "^1.0.1", "merge-stream": "^1.0.1",
"mocha": "^5.2.0", "mocha": "^5.2.0",
"parse5": "^5.0.0", "parse5": "^5.1.0",
"polymer-analyzer": "^3.0.1", "polymer-analyzer": "^3.1.2",
"polymer-bundler": "^4.0.1", "polymer-bundler": "^4.0.2",
"polymer-cli": "^1.7.4", "polymer-cli": "^1.8.0",
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
"reify": "^0.16.2", "reify": "^0.17.3",
"require-dir": "^1.0.0", "require-dir": "^1.0.0",
"sinon": "^6.0.0", "sinon": "^6.3.4",
"uglifyjs-webpack-plugin": "^1.2.6", "uglifyjs-webpack-plugin": "^1.2.6",
"wct-browser-legacy": "^1.0.1", "wct-browser-legacy": "^1.0.1",
"web-component-tester": "^6.7.0", "web-component-tester": "^6.8.0",
"webpack": "^4.12.0", "webpack": "^4.19.1",
"webpack-cli": "^3.0.8", "webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.4", "webpack-dev-server": "^3.1.8",
"workbox-webpack-plugin": "^3.3.0" "workbox-webpack-plugin": "^3.5.0"
}, },
"resolutions": { "resolutions": {
"inherits": "2.0.3", "inherits": "2.0.3",
"samsam": "1.1.3", "samsam": "1.1.3",
"supports-color": "3.1.2", "supports-color": "3.1.2",
"type-detect": "1.0.0", "type-detect": "1.0.0",
"@webcomponents/webcomponentsjs": "2.0.2", "@polymer/polymer": "3.0.5",
"@webcomponents/shadycss": "^1.3.1", "@webcomponents/webcomponentsjs": "2.1.3",
"@vaadin/vaadin-overlay": "3.0.2-pre.2", "@webcomponents/shadycss": "^1.5.2",
"@vaadin/vaadin-overlay": "3.2.0-alpha3",
"@vaadin/vaadin-lumo-styles": "1.2.0",
"fecha": "https://github.com/balloob/fecha/archive/51d14fd0eb4781e2ecf265d1c3080706259133b5.tar.gz" "fecha": "https://github.com/balloob/fecha/archive/51d14fd0eb4781e2ecf265d1c3080706259133b5.tar.gz"
}, },
"main": "src/home-assistant.js" "main": "src/home-assistant.js"

View File

@ -24,7 +24,7 @@
], ],
"lint": { "lint": {
"rules": ["polymer-3"], "rules": ["polymer-3"],
"ignoreWarnings": ["could-not-resolve-reference"], "ignoreWarnings": ["could-not-resolve-reference", "could-not-load"],
"filesToIgnore": [ "filesToIgnore": [
"**/*.html", "**/*.html",
"**/src/panels/config/js/**/*.js", "**/src/panels/config/js/**/*.js",

View File

@ -137,8 +137,8 @@ class HaAuthFlow extends LocalizeLiteMixin(PolymerElement) {
_state: 'step', _state: 'step',
}; };
if (this._step && if (this._step
(step.flow_id !== this._step.flow_id || step.step_id !== this._step.step_id)) { && (step.flow_id !== this._step.flow_id || step.step_id !== this._step.step_id)) {
props._stepData = {}; props._stepData = {};
} }

View File

@ -7,7 +7,7 @@ import '../components/ha-markdown.js';
import LocalizeLiteMixin from '../mixins/localize-lite-mixin.js'; import LocalizeLiteMixin from '../mixins/localize-lite-mixin.js';
import '../auth/ha-auth-flow.js'; import './ha-auth-flow.js';
class HaAuthorize extends LocalizeLiteMixin(PolymerElement) { class HaAuthorize extends LocalizeLiteMixin(PolymerElement) {
static get template() { static get template() {
@ -125,15 +125,14 @@ class HaAuthorize extends LocalizeLiteMixin(PolymerElement) {
} }
_computeInactiveProvders(curProvider, providers) { _computeInactiveProvders(curProvider, providers) {
return providers.filter(prv => return providers.filter(prv => prv.type !== curProvider.type || prv.id !== curProvider.id);
prv.type !== curProvider.type || prv.id !== curProvider.id);
} }
_computeIntro(localize, clientId, authProvider) { _computeIntro(localize, clientId, authProvider) {
return ( return (
localize('ui.panel.page-authorize.authorizing_client', 'clientId', clientId) + localize('ui.panel.page-authorize.authorizing_client', 'clientId', clientId)
'\n\n' + + '\n\n'
localize('ui.panel.page-authorize.logging_in_with', 'authProviderName', authProvider.name) + localize('ui.panel.page-authorize.logging_in_with', 'authProviderName', authProvider.name)
); );
} }
} }

View File

@ -58,8 +58,7 @@ class HaCardChooser extends PolymerElement {
if (!newData) return; if (!newData) return;
// ha-entities-card is exempt from observer as it doesn't load heavy resources. // ha-entities-card is exempt from observer as it doesn't load heavy resources.
// and usually doesn't load external resources (except for entity_picture). // and usually doesn't load external resources (except for entity_picture).
const eligibleToObserver = const eligibleToObserver = (window.IntersectionObserver && newData.cardType !== 'entities');
(window.IntersectionObserver && newData.cardType !== 'entities');
if (!eligibleToObserver) { if (!eligibleToObserver) {
if (this.observer) { if (this.observer) {
this.observer.unobserve(this); this.observer.unobserve(this);

View File

@ -134,8 +134,8 @@ class HaEntitiesCard extends LocalizeMixin(EventsMixin(PolymerElement)) {
} }
showGroupToggle(groupEntity, states) { showGroupToggle(groupEntity, states) {
if (!groupEntity || !states || groupEntity.attributes.control === 'hidden' || if (!groupEntity || !states || groupEntity.attributes.control === 'hidden'
(groupEntity.state !== 'on' && groupEntity.state !== 'off')) { || (groupEntity.state !== 'on' && groupEntity.state !== 'off')) {
return false; return false;
} }

View File

@ -76,9 +76,9 @@ class HaHistoryGraphCard extends EventsMixin(PolymerElement) {
stateObjObserver(stateObj) { stateObjObserver(stateObj) {
if (!stateObj) return; if (!stateObj) return;
if (this.cacheConfig.cacheKey !== stateObj.entity_id || if (this.cacheConfig.cacheKey !== stateObj.entity_id
this.cacheConfig.refresh !== (stateObj.attributes.refresh || 0) || || this.cacheConfig.refresh !== (stateObj.attributes.refresh || 0)
this.cacheConfig.hoursToShow !== (stateObj.attributes.hours_to_show || 24)) { || this.cacheConfig.hoursToShow !== (stateObj.attributes.hours_to_show || 24)) {
this.cacheConfig = Object.assign({}, { this.cacheConfig = Object.assign({}, {
refresh: stateObj.attributes.refresh || 0, refresh: stateObj.attributes.refresh || 0,
cacheKey: stateObj.entity_id, cacheKey: stateObj.entity_id,

View File

@ -219,7 +219,7 @@ class HaMediaPlayerCard extends LocalizeMixin(EventsMixin(PolymerElement)) {
if (picture !== oldPicture && !picture) { if (picture !== oldPicture && !picture) {
this.$.cover.style.backgroundImage = ''; this.$.cover.style.backgroundImage = '';
return; return;
} else if (picture === oldPicture) { } if (picture === oldPicture) {
return; return;
} }
@ -275,7 +275,7 @@ class HaMediaPlayerCard extends LocalizeMixin(EventsMixin(PolymerElement)) {
computePlaybackControlIcon(playerObj) { computePlaybackControlIcon(playerObj) {
if (playerObj.isPlaying) { if (playerObj.isPlaying) {
return playerObj.supportsPause ? 'hass:pause' : 'hass:stop'; return playerObj.supportsPause ? 'hass:pause' : 'hass:stop';
} else if (playerObj.hasMediaControl || playerObj.isOff || playerObj.isIdle) { } if (playerObj.hasMediaControl || playerObj.isOff || playerObj.isIdle) {
if (playerObj.hasMediaControl && playerObj.supportsPause && !playerObj.isPaused) { if (playerObj.hasMediaControl && playerObj.supportsPause && !playerObj.isPaused) {
return 'hass:play-pause'; return 'hass:play-pause';
} }

View File

@ -60,8 +60,8 @@ class HaPersistentNotificationCard extends LocalizeMixin(PolymerElement) {
} }
computeTitle(stateObj) { computeTitle(stateObj) {
return (stateObj.attributes.title || return (stateObj.attributes.title
computeStateName(stateObj)); || computeStateName(stateObj));
} }
dismissTap(ev) { dismissTap(ev) {

View File

@ -113,7 +113,7 @@ class HaPlantCard extends EventsMixin(PolymerElement) {
if (attr === 'battery') { if (attr === 'battery') {
if (batLvl <= 5) { if (batLvl <= 5) {
return `${icon}-alert`; return `${icon}-alert`;
} else if (batLvl < 95) { } if (batLvl < 95) {
return `${icon}-${Math.round((batLvl / 10) - 0.01) * 10}`; return `${icon}-${Math.round((batLvl / 10) - 0.01) * 10}`;
} }
} }

View File

@ -10,8 +10,8 @@ function toLocaleDateStringSupportsOptions() {
return false; return false;
} }
export default (toLocaleDateStringSupportsOptions() ? export default (toLocaleDateStringSupportsOptions()
function (dateObj, locales) { ? function (dateObj, locales) {
return dateObj.toLocaleDateString( return dateObj.toLocaleDateString(
locales, locales,
{ year: 'numeric', month: 'long', day: 'numeric' }, { year: 'numeric', month: 'long', day: 'numeric' },

View File

@ -10,8 +10,8 @@ function toLocaleStringSupportsOptions() {
return false; return false;
} }
export default (toLocaleStringSupportsOptions() ? export default (toLocaleStringSupportsOptions()
function (dateObj, locales) { ? function (dateObj, locales) {
return dateObj.toLocaleString(locales, { return dateObj.toLocaleString(locales, {
year: 'numeric', year: 'numeric',
month: 'long', month: 'long',

View File

@ -10,8 +10,8 @@ function toLocaleTimeStringSupportsOptions() {
return false; return false;
} }
export default (toLocaleTimeStringSupportsOptions() ? export default (toLocaleTimeStringSupportsOptions()
function (dateObj, locales) { ? function (dateObj, locales) {
return dateObj.toLocaleTimeString( return dateObj.toLocaleTimeString(
locales, locales,
{ hour: 'numeric', minute: '2-digit' } { hour: 'numeric', minute: '2-digit' }

View File

@ -7,9 +7,9 @@ export default function secondsToDuration(d) {
if (h > 0) { if (h > 0) {
return `${h}:${leftPad(m)}:${leftPad(s)}`; return `${h}:${leftPad(m)}:${leftPad(s)}`;
} else if (m > 0) { } if (m > 0) {
return `${m}:${leftPad(s)}`; return `${m}:${leftPad(s)}`;
} else if (s > 0) { } if (s > 0) {
return '' + s; return '' + s;
} }
return null; return null;

View File

@ -4,7 +4,7 @@ export default function canToggleDomain(hass, domain) {
if (domain === 'lock') { if (domain === 'lock') {
return 'lock' in services; return 'lock' in services;
} else if (domain === 'cover') { } if (domain === 'cover') {
return 'open_cover' in services; return 'open_cover' in services;
} }
return 'turn_on' in services; return 'turn_on' in services;

View File

@ -9,8 +9,7 @@ export default function computeStateDisplay(localize, stateObj, language) {
if (domain === 'binary_sensor') { if (domain === 'binary_sensor') {
// Try device class translation, then default binary sensor translation // Try device class translation, then default binary sensor translation
if (stateObj.attributes.device_class) { if (stateObj.attributes.device_class) {
stateObj._stateDisplay = stateObj._stateDisplay = localize(`state.${domain}.${stateObj.attributes.device_class}.${stateObj.state}`);
localize(`state.${domain}.${stateObj.attributes.device_class}.${stateObj.state}`);
} }
if (!stateObj._stateDisplay) { if (!stateObj._stateDisplay) {
stateObj._stateDisplay = localize(`state.${domain}.default.${stateObj.state}`); stateObj._stateDisplay = localize(`state.${domain}.default.${stateObj.state}`);

View File

@ -3,8 +3,8 @@ import computeObjectId from './compute_object_id';
export default function computeStateName(stateObj) { export default function computeStateName(stateObj) {
if (stateObj._entityDisplay === undefined) { if (stateObj._entityDisplay === undefined) {
stateObj._entityDisplay = ( stateObj._entityDisplay = (
stateObj.attributes.friendly_name || stateObj.attributes.friendly_name
computeObjectId(stateObj.entity_id).replace(/_/g, ' ')); || computeObjectId(stateObj.entity_id).replace(/_/g, ' '));
} }
return stateObj._entityDisplay; return stateObj._entityDisplay;

View File

@ -71,8 +71,8 @@ export default function domainIcon(domain, state) {
return state && state === 'unlocked' ? 'hass:lock-open' : 'hass:lock'; return state && state === 'unlocked' ? 'hass:lock-open' : 'hass:lock';
case 'media_player': case 'media_player':
return state && state !== 'off' && state !== 'idle' ? return state && state !== 'off' && state !== 'idle'
'hass:cast-connected' : 'hass:cast'; ? 'hass:cast-connected' : 'hass:cast';
case 'zwave': case 'zwave':
switch (state) { switch (state) {

View File

@ -14,7 +14,7 @@ export default function extractViews(entities) {
views.sort((view1, view2) => { views.sort((view1, view2) => {
if (view1.entity_id === DEFAULT_VIEW_ENTITY_ID) { if (view1.entity_id === DEFAULT_VIEW_ENTITY_ID) {
return -1; return -1;
} else if (view2.entity_id === DEFAULT_VIEW_ENTITY_ID) { } if (view2.entity_id === DEFAULT_VIEW_ENTITY_ID) {
return 1; return 1;
} }
return view1.attributes.order - view2.attributes.order; return view1.attributes.order - view2.attributes.order;

View File

@ -1,4 +1,4 @@
export default function hasLocation(stateObj) { export default function hasLocation(stateObj) {
return ('latitude' in stateObj.attributes && return ('latitude' in stateObj.attributes
'longitude' in stateObj.attributes); && 'longitude' in stateObj.attributes);
} }

View File

@ -4,7 +4,7 @@ import domainIcon from './domain_icon.js';
export default function inputDateTimeIcon(state) { export default function inputDateTimeIcon(state) {
if (!state.attributes.has_date) { if (!state.attributes.has_date) {
return 'hass:clock'; return 'hass:clock';
} else if (!state.attributes.has_time) { } if (!state.attributes.has_time) {
return 'hass:calendar'; return 'hass:calendar';
} }
return domainIcon('input_datetime'); return domainIcon('input_datetime');

View File

@ -13,7 +13,7 @@ export default function sensorIcon(state) {
if (dclass in fixedDeviceClassIcons) { if (dclass in fixedDeviceClassIcons) {
return fixedDeviceClassIcons[dclass]; return fixedDeviceClassIcons[dclass];
} else if (dclass === 'battery') { } if (dclass === 'battery') {
if (isNaN(state.state)) { if (isNaN(state.state)) {
return 'hass:battery-unknown'; return 'hass:battery-unknown';
} }

View File

@ -17,8 +17,9 @@ export default function splitByGroups(entities) {
} }
}); });
groups.forEach(group => groups.forEach(group => group.attributes.entity_id.forEach((entityId) => {
group.attributes.entity_id.forEach((entityId) => { delete ungrouped[entityId]; })); delete ungrouped[entityId];
}));
return { groups, ungrouped }; return { groups, ungrouped };
} }

View File

@ -11,8 +11,8 @@ export default function stateCardType(hass, stateObj) {
if (DOMAINS_WITH_CARD.includes(domain)) { if (DOMAINS_WITH_CARD.includes(domain)) {
return domain; return domain;
} else if (canToggleState(hass, stateObj) && } if (canToggleState(hass, stateObj)
stateObj.attributes.control !== 'hidden') { && stateObj.attributes.control !== 'hidden') {
return 'toggle'; return 'toggle';
} }
return 'display'; return 'display';

View File

@ -19,7 +19,7 @@ const domainIcons = {
export default function stateIcon(state) { export default function stateIcon(state) {
if (!state) { if (!state) {
return DEFAULT_DOMAIN_ICON; return DEFAULT_DOMAIN_ICON;
} else if (state.attributes.icon) { } if (state.attributes.icon) {
return state.attributes.icon; return state.attributes.icon;
} }

View File

@ -13,9 +13,9 @@ export default function parseAspectRatio(input) {
return null; return null;
} }
return arr.length === 1 ? return arr.length === 1
{ w: parseOrThrow(arr[0]), h: 1 } : ? { w: parseOrThrow(arr[0]), h: 1 }
{ w: parseOrThrow(arr[0]), h: parseOrThrow(arr[1]) }; : { w: parseOrThrow(arr[0]), h: parseOrThrow(arr[1]) };
} }
} catch (err) { } catch (err) {
// Ignore the error // Ignore the error

View File

@ -219,12 +219,14 @@ class HaChartBase extends mixinBehaviors([
this._resizeTimer = undefined; this._resizeTimer = undefined;
} }
} }
onPropsChange() { onPropsChange() {
if (!this._isAttached || !this.ChartClass || !this.data) { if (!this._isAttached || !this.ChartClass || !this.data) {
return; return;
} }
this.drawChart(); this.drawChart();
} }
_customTooltips(tooltip) { _customTooltips(tooltip) {
// Hide if no tooltip // Hide if no tooltip
if (tooltip.opacity === 0) { if (tooltip.opacity === 0) {
@ -285,18 +287,18 @@ class HaChartBase extends mixinBehaviors([
this.set(['metas', index, 'hidden'], this._chart.isDatasetVisible(index) ? null : 'hidden'); this.set(['metas', index, 'hidden'], this._chart.isDatasetVisible(index) ? null : 'hidden');
this._chart.update(); this._chart.update();
} }
_drawLegend() { _drawLegend() {
const chart = this._chart; const chart = this._chart;
// New data for old graph. Keep metadata. // New data for old graph. Keep metadata.
const preserveVisibility = const preserveVisibility = this._oldIdentifier && this.identifier === this._oldIdentifier;
this._oldIdentifier && this.identifier === this._oldIdentifier;
this._oldIdentifier = this.identifier; this._oldIdentifier = this.identifier;
this.set('metas', this._chart.data.datasets.map((x, i) => ({ this.set('metas', this._chart.data.datasets.map((x, i) => ({
label: x.label, label: x.label,
color: x.color, color: x.color,
bgColor: x.backgroundColor, bgColor: x.backgroundColor,
hidden: preserveVisibility && i < this.metas.length ? hidden: preserveVisibility && i < this.metas.length
this.metas[i].hidden : !chart.isDatasetVisible(i), ? this.metas[i].hidden : !chart.isDatasetVisible(i),
}))); })));
let updateNeeded = false; let updateNeeded = false;
if (preserveVisibility) { if (preserveVisibility) {
@ -311,6 +313,7 @@ class HaChartBase extends mixinBehaviors([
} }
this.unit = this.data.unit; this.unit = this.data.unit;
} }
_formatTickValue(value, index, values) { _formatTickValue(value, index, values) {
if (values.length === 0) { if (values.length === 0) {
return value; return value;
@ -318,6 +321,7 @@ class HaChartBase extends mixinBehaviors([
const date = new Date(values[index].value); const date = new Date(values[index].value);
return formatTime(date); return formatTime(date);
} }
drawChart() { drawChart() {
const data = this.data.data; const data = this.data.data;
const ctx = this.$.chartCanvas; const ctx = this.$.chartCanvas;
@ -493,6 +497,7 @@ class HaChartBase extends mixinBehaviors([
} }
return result; return result;
} }
static getColorGenerator(staticColors, startIndex) { static getColorGenerator(staticColors, startIndex) {
// Known colors for static data, // Known colors for static data,
// should add for very common state string manually. // should add for very common state string manually.

View File

@ -133,15 +133,15 @@ class HaStateLabelBadge extends
case 'alarm_control_panel': case 'alarm_control_panel':
if (state.state === 'pending') { if (state.state === 'pending') {
return 'hass:clock-fast'; return 'hass:clock-fast';
} else if (state.state === 'armed_away') { } if (state.state === 'armed_away') {
return 'hass:nature'; return 'hass:nature';
} else if (state.state === 'armed_home') { } if (state.state === 'armed_home') {
return 'hass:home-variant'; return 'hass:home-variant';
} else if (state.state === 'armed_night') { } if (state.state === 'armed_night') {
return 'hass:weather-night'; return 'hass:weather-night';
} else if (state.state === 'armed_custom_bypass') { } if (state.state === 'armed_custom_bypass') {
return 'hass:security-home'; return 'hass:security-home';
} else if (state.state === 'triggered') { } if (state.state === 'triggered') {
return 'hass:alert-circle'; return 'hass:alert-circle';
} }
// state == 'disarmed' // state == 'disarmed'
@ -151,8 +151,8 @@ class HaStateLabelBadge extends
case 'updater': case 'updater':
return stateIcon(state); return stateIcon(state);
case 'sun': case 'sun':
return state.state === 'above_horizon' ? return state.state === 'above_horizon'
domainIcon(domain) : 'hass:brightness-3'; ? domainIcon(domain) : 'hass:brightness-3';
case 'timer': case 'timer':
return state.state === 'active' ? 'hass:timer' : 'hass:timer-off'; return state.state === 'active' ? 'hass:timer' : 'hass:timer-off';
default: default:
@ -166,8 +166,8 @@ class HaStateLabelBadge extends
computeLabel(localize, state, _timerTimeRemaining) { computeLabel(localize, state, _timerTimeRemaining) {
const domain = computeStateDomain(state); const domain = computeStateDomain(state);
if (state.state === 'unavailable' || if (state.state === 'unavailable'
['device_tracker', 'alarm_control_panel'].includes(domain)) { || ['device_tracker', 'alarm_control_panel'].includes(domain)) {
// Localize the state with a special state_badge namespace, which has variations of // Localize the state with a special state_badge namespace, which has variations of
// the state translations that are truncated to fit within the badge label. Translations // the state translations that are truncated to fit within the badge label. Translations
// are only added for device_tracker and alarm_control_panel. // are only added for device_tracker and alarm_control_panel.

View File

@ -44,17 +44,15 @@ const PRIORITY = {
mailbox: 7, mailbox: 7,
}; };
const getPriority = domain => const getPriority = domain => ((domain in PRIORITY) ? PRIORITY[domain] : 100);
((domain in PRIORITY) ? PRIORITY[domain] : 100);
const sortPriority = (domainA, domainB) => const sortPriority = (domainA, domainB) => domainA.priority - domainB.priority;
domainA.priority - domainB.priority;
const entitySortBy = (entityA, entityB) => { const entitySortBy = (entityA, entityB) => {
const nameA = (entityA.attributes.friendly_name || const nameA = (entityA.attributes.friendly_name
entityA.entity_id).toLowerCase(); || entityA.entity_id).toLowerCase();
const nameB = (entityB.attributes.friendly_name || const nameB = (entityB.attributes.friendly_name
entityB.entity_id).toLowerCase(); || entityB.entity_id).toLowerCase();
if (nameA < nameB) { if (nameA < nameB) {
return -1; return -1;
@ -187,7 +185,7 @@ class HaCards extends PolymerElement {
this.$.main.parentNode.removeChild(this.$.main); this.$.main.parentNode.removeChild(this.$.main);
} }
return; return;
} else if (!this.$.main.parentNode && this.$.main._parentNode) { } if (!this.$.main.parentNode && this.$.main._parentNode) {
this.$.main._parentNode.appendChild(this.$.main); this.$.main._parentNode.appendChild(this.$.main);
} }
this._debouncer = Debouncer.debounce( this._debouncer = Debouncer.debounce(
@ -284,8 +282,8 @@ class HaCards extends PolymerElement {
const splitted = splitByGroups(states); const splitted = splitByGroups(states);
if (orderedGroupEntities) { if (orderedGroupEntities) {
splitted.groups.sort((gr1, gr2) => orderedGroupEntities[gr1.entity_id] - splitted.groups.sort((gr1, gr2) => orderedGroupEntities[gr1.entity_id]
orderedGroupEntities[gr2.entity_id]); - orderedGroupEntities[gr2.entity_id]);
} else { } else {
splitted.groups.sort((gr1, gr2) => gr1.attributes.order - gr2.attributes.order); splitted.groups.sort((gr1, gr2) => gr1.attributes.order - gr2.attributes.order);
} }
@ -332,8 +330,8 @@ class HaCards extends PolymerElement {
cards.badges.push.apply(cards.badges, domain.states); cards.badges.push.apply(cards.badges, domain.states);
}); });
cards.badges.sort((e1, e2) => orderedGroupEntities[e1.entity_id] - cards.badges.sort((e1, e2) => orderedGroupEntities[e1.entity_id]
orderedGroupEntities[e2.entity_id]); - orderedGroupEntities[e2.entity_id]);
} else { } else {
iterateDomainSorted(badgesColl, (domain) => { iterateDomainSorted(badgesColl, (domain) => {
cards.badges.push.apply(cards.badges, domain.states); cards.badges.push.apply(cards.badges, domain.states);

View File

@ -72,9 +72,11 @@ class HaClimateControl extends EventsMixin(PolymerElement) {
}, },
}; };
} }
temperatureStateInFlux(inFlux) { temperatureStateInFlux(inFlux) {
this.$.target_temperature.classList.toggle('in-flux', inFlux); this.$.target_temperature.classList.toggle('in-flux', inFlux);
} }
incrementValue() { incrementValue() {
const newval = this.value + this.step; const newval = this.value + this.step;
if (this.value < this.max) { if (this.value < this.max) {
@ -94,6 +96,7 @@ class HaClimateControl extends EventsMixin(PolymerElement) {
this.value = this.max; this.value = this.max;
} }
} }
decrementValue() { decrementValue() {
const newval = this.value - this.step; const newval = this.value - this.step;
if (this.value > this.min) { if (this.value > this.min) {
@ -106,6 +109,7 @@ class HaClimateControl extends EventsMixin(PolymerElement) {
this.value = this.min; this.value = this.min;
} }
} }
valueChanged() { valueChanged() {
// when the last_changed timestamp is changed, // when the last_changed timestamp is changed,
// trigger a potential event fire in // trigger a potential event fire in

View File

@ -71,15 +71,15 @@ class HaClimateState extends LocalizeMixin(PolymerElement) {
computeTarget(hass, stateObj) { computeTarget(hass, stateObj) {
if (!hass || !stateObj) return null; if (!hass || !stateObj) return null;
// We're using "!= null" on purpose so that we match both null and undefined. // We're using "!= null" on purpose so that we match both null and undefined.
if (stateObj.attributes.target_temp_low != null && if (stateObj.attributes.target_temp_low != null
stateObj.attributes.target_temp_high != null) { && stateObj.attributes.target_temp_high != null) {
return `${stateObj.attributes.target_temp_low} - ${stateObj.attributes.target_temp_high} ${hass.config.unit_system.temperature}`; return `${stateObj.attributes.target_temp_low} - ${stateObj.attributes.target_temp_high} ${hass.config.unit_system.temperature}`;
} else if (stateObj.attributes.temperature != null) { } if (stateObj.attributes.temperature != null) {
return `${stateObj.attributes.temperature} ${hass.config.unit_system.temperature}`; return `${stateObj.attributes.temperature} ${hass.config.unit_system.temperature}`;
} else if (stateObj.attributes.target_humidity_low != null && } if (stateObj.attributes.target_humidity_low != null
stateObj.attributes.target_humidity_high != null) { && stateObj.attributes.target_humidity_high != null) {
return `${stateObj.attributes.target_humidity_low} - ${stateObj.attributes.target_humidity_high} %`; return `${stateObj.attributes.target_humidity_low} - ${stateObj.attributes.target_humidity_high} %`;
} else if (stateObj.attributes.humidity != null) { } if (stateObj.attributes.humidity != null) {
return `${stateObj.attributes.humidity} %`; return `${stateObj.attributes.humidity} %`;
} }

View File

@ -302,9 +302,9 @@ class HaColorPicker extends EventsMixin(PolymerElement) {
applyHsColor(hs) { applyHsColor(hs) {
// do nothing is we already have the same color // do nothing is we already have the same color
if (this.hsColor && if (this.hsColor
this.hsColor.h === hs.h && && this.hsColor.h === hs.h
this.hsColor.s === hs.s) { && this.hsColor.s === hs.s) {
return; return;
} }
this.setMarkerOnColor(hs); // marker is always set on 'raw' hs position this.setMarkerOnColor(hs); // marker is always set on 'raw' hs position

View File

@ -38,25 +38,31 @@ class HaCoverControls extends PolymerElement {
}, },
}; };
} }
computeEntityObj(hass, stateObj) { computeEntityObj(hass, stateObj) {
return new CoverEntity(hass, stateObj); return new CoverEntity(hass, stateObj);
} }
computeOpenDisabled(stateObj, entityObj) { computeOpenDisabled(stateObj, entityObj) {
var assumedState = stateObj.attributes.assumed_state === true; var assumedState = stateObj.attributes.assumed_state === true;
return (entityObj.isFullyOpen || entityObj.isOpening) && !assumedState; return (entityObj.isFullyOpen || entityObj.isOpening) && !assumedState;
} }
computeClosedDisabled(stateObj, entityObj) { computeClosedDisabled(stateObj, entityObj) {
var assumedState = (stateObj.attributes.assumed_state === true); var assumedState = (stateObj.attributes.assumed_state === true);
return (entityObj.isFullyClosed || entityObj.isClosing) && !assumedState; return (entityObj.isFullyClosed || entityObj.isClosing) && !assumedState;
} }
onOpenTap(ev) { onOpenTap(ev) {
ev.stopPropagation(); ev.stopPropagation();
this.entityObj.openCover(); this.entityObj.openCover();
} }
onCloseTap(ev) { onCloseTap(ev) {
ev.stopPropagation(); ev.stopPropagation();
this.entityObj.closeCover(); this.entityObj.closeCover();
} }
onStopTap(ev) { onStopTap(ev) {
ev.stopPropagation(); ev.stopPropagation();
this.entityObj.stopCover(); this.entityObj.stopCover();

View File

@ -37,25 +37,31 @@ class HaCoverTiltControls extends PolymerElement {
}, },
}; };
} }
computeEntityObj(hass, stateObj) { computeEntityObj(hass, stateObj) {
return new CoverEntity(hass, stateObj); return new CoverEntity(hass, stateObj);
} }
computeOpenDisabled(stateObj, entityObj) { computeOpenDisabled(stateObj, entityObj) {
var assumedState = stateObj.attributes.assumed_state === true; var assumedState = stateObj.attributes.assumed_state === true;
return entityObj.isFullyOpenTilt && !assumedState; return entityObj.isFullyOpenTilt && !assumedState;
} }
computeClosedDisabled(stateObj, entityObj) { computeClosedDisabled(stateObj, entityObj) {
var assumedState = (stateObj.attributes.assumed_state === true); var assumedState = (stateObj.attributes.assumed_state === true);
return entityObj.isFullyClosedTilt && !assumedState; return entityObj.isFullyClosedTilt && !assumedState;
} }
onOpenTiltTap(ev) { onOpenTiltTap(ev) {
ev.stopPropagation(); ev.stopPropagation();
this.entityObj.openCoverTilt(); this.entityObj.openCoverTilt();
} }
onCloseTiltTap(ev) { onCloseTiltTap(ev) {
ev.stopPropagation(); ev.stopPropagation();
this.entityObj.closeCoverTilt(); this.entityObj.closeCoverTilt();
} }
onStopTiltTap(ev) { onStopTiltTap(ev) {
ev.stopPropagation(); ev.stopPropagation();
this.entityObj.stopCoverTilt(); this.entityObj.stopCoverTilt();

View File

@ -73,8 +73,8 @@ class HaMarkdown extends EventsMixin(PolymerElement) {
const node = walker.currentNode; const node = walker.currentNode;
// Open external links in a new window // Open external links in a new window
if (node.tagName === 'A' && if (node.tagName === 'A'
node.host !== document.location.host) { && node.host !== document.location.host) {
node.target = '_blank'; node.target = '_blank';
// Fire a resize event when images loaded to notify content resized // Fire a resize event when images loaded to notify content resized

View File

@ -5,10 +5,10 @@ import { PolymerElement } from '@polymer/polymer/polymer-element.js';
import EventsMixin from '../mixins/events-mixin.js'; import EventsMixin from '../mixins/events-mixin.js';
export const pushSupported = ( export const pushSupported = (
'serviceWorker' in navigator && 'PushManager' in window && 'serviceWorker' in navigator && 'PushManager' in window
(document.location.protocol === 'https:' || && (document.location.protocol === 'https:'
document.location.hostname === 'localhost' || || document.location.hostname === 'localhost'
document.location.hostname === '127.0.0.1')); || document.location.hostname === '127.0.0.1'));
/* /*
* @appliesMixin EventsMixin * @appliesMixin EventsMixin

View File

@ -34,7 +34,7 @@ class HaServicePicker extends LocalizeMixin(PolymerElement) {
if (!hass) { if (!hass) {
this._services = []; this._services = [];
return; return;
} else if (oldHass && hass.services === oldHass.services) { } if (oldHass && hass.services === oldHass.services) {
return; return;
} }
const result = []; const result = [];

View File

@ -6,7 +6,7 @@ import '@polymer/paper-item/paper-item.js';
import '@polymer/paper-listbox/paper-listbox.js'; import '@polymer/paper-listbox/paper-listbox.js';
import { html } from '@polymer/polymer/lib/utils/html-tag.js'; import { html } from '@polymer/polymer/lib/utils/html-tag.js';
import { PolymerElement } from '@polymer/polymer/polymer-element.js'; import { PolymerElement } from '@polymer/polymer/polymer-element.js';
import '../components/ha-icon.js'; import './ha-icon.js';
import '../util/hass-translation.js'; import '../util/hass-translation.js';
import LocalizeMixin from '../mixins/localize-mixin.js'; import LocalizeMixin from '../mixins/localize-mixin.js';
@ -305,9 +305,9 @@ class HaSidebar extends LocalizeMixin(PolymerElement) {
if (aBuiltIn && bBuiltIn) { if (aBuiltIn && bBuiltIn) {
return sortValue[a.component_name] - sortValue[b.component_name]; return sortValue[a.component_name] - sortValue[b.component_name];
} else if (aBuiltIn) { } if (aBuiltIn) {
return -1; return -1;
} else if (bBuiltIn) { } if (bBuiltIn) {
return 1; return 1;
} }
// both not built in, sort by title // both not built in, sort by title

View File

@ -32,8 +32,8 @@ class HaStartVoiceButton extends EventsMixin(PolymerElement) {
} }
computeCanListen(hass) { computeCanListen(hass) {
return ('webkitSpeechRecognition' in window && return ('webkitSpeechRecognition' in window
isComponentLoaded(hass, 'conversation')); && isComponentLoaded(hass, 'conversation'));
} }
handleListenClick() { handleListenClick() {

View File

@ -40,4 +40,3 @@ class HaTextarea extends PolymerElement {
} }
customElements.define('ha-textarea', HaTextarea); customElements.define('ha-textarea', HaTextarea);

View File

@ -74,8 +74,8 @@ class HaVacuumState extends LocalizeMixin(PolymerElement) {
} }
_computeLabel(state, interceptable) { _computeLabel(state, interceptable) {
return interceptable ? return interceptable
this.localize(`ui.card.vacuum.actions.${STATES_INTERCEPTABLE[state].action}`) ? this.localize(`ui.card.vacuum.actions.${STATES_INTERCEPTABLE[state].action}`)
: this.localize(`state.vacuum.${state}`); : this.localize(`state.vacuum.${state}`);
} }

View File

@ -42,6 +42,7 @@ class StateHistoryChartLine extends PolymerElement {
} }
}; };
} }
static get observers() { static get observers() {
return ['dataChanged(data, endTime, isSingleDevice)']; return ['dataChanged(data, endTime, isSingleDevice)'];
} }
@ -85,9 +86,11 @@ class StateHistoryChartLine extends PolymerElement {
return isFinite(parsed) ? parsed : null; return isFinite(parsed) ? parsed : null;
} }
endTime = this.endTime ||
new Date(Math.max.apply(null, deviceStates.map(states => endTime = this.endTime
new Date(states.states[states.states.length - 1].last_changed)))); // Get the highest date from the last date of each device
|| new Date(Math.max.apply(null, deviceStates.map(devSts =>
new Date(devSts.states[devSts.states.length - 1].last_changed))));
if (endTime > new Date()) { if (endTime > new Date()) {
endTime = new Date(); endTime = new Date();
} }
@ -138,8 +141,8 @@ class StateHistoryChartLine extends PolymerElement {
// range versus ones that have just a target temperature // range versus ones that have just a target temperature
// Using step chart by step-before so manually interpolation not needed. // Using step chart by step-before so manually interpolation not needed.
const hasTargetRange = states.states.some(state => state.attributes && const hasTargetRange = states.states.some(state => state.attributes
state.attributes.target_temp_high !== state.attributes.target_temp_low); && state.attributes.target_temp_high !== state.attributes.target_temp_low);
const hasHeat = states.states.some(state => state.state === 'heat'); const hasHeat = states.states.some(state => state.state === 'heat');
const hasCool = states.states.some(state => state.state === 'cool'); const hasCool = states.states.some(state => state.state === 'cool');
@ -208,8 +211,8 @@ class StateHistoryChartLine extends PolymerElement {
const dateTime = date.getTime(); const dateTime = date.getTime();
const lastNullDateTime = lastNullDate.getTime(); const lastNullDateTime = lastNullDate.getTime();
const lastDateTime = lastDate.getTime(); const lastDateTime = lastDate.getTime();
const tmpValue = ((value - lastValue) * const tmpValue = ((value - lastValue)
((lastNullDateTime - lastDateTime) / (dateTime - lastDateTime))) + lastValue; * ((lastNullDateTime - lastDateTime) / (dateTime - lastDateTime))) + lastValue;
pushData(lastNullDate, [tmpValue]); pushData(lastNullDate, [tmpValue]);
pushData(new Date(lastNullDateTime + 1), [null]); pushData(new Date(lastNullDateTime + 1), [null]);
pushData(date, [value]); pushData(date, [value]);

View File

@ -83,8 +83,8 @@ class StateHistoryChartTimeline extends PolymerElement {
)); ));
// end time is Math.max(startTime, last_event) // end time is Math.max(startTime, last_event)
let endTime = this.endTime || let endTime = this.endTime
new Date(stateHistory.reduce((maxTime, stateInfo) => Math.max( || new Date(stateHistory.reduce((maxTime, stateInfo) => Math.max(
maxTime, maxTime,
new Date(stateInfo.data[stateInfo.data.length - 1].last_changed) new Date(stateInfo.data[stateInfo.data.length - 1].last_changed)
), startTime)); ), startTime));

View File

@ -67,9 +67,9 @@ class StateHistoryCharts extends LocalizeMixin(PolymerElement) {
} }
_computeIsEmpty(isLoadingData, historyData) { _computeIsEmpty(isLoadingData, historyData) {
const historyDataEmpty = (!historyData || !historyData.timeline || !historyData.line || const historyDataEmpty = (!historyData || !historyData.timeline || !historyData.line
(historyData.timeline.length === 0 && || (historyData.timeline.length === 0
historyData.line.length === 0)); && historyData.line.length === 0));
return !isLoadingData && historyDataEmpty; return !isLoadingData && historyDataEmpty;
} }

View File

@ -236,8 +236,8 @@ class HaStateHistoryData extends LocalizeMixin(PolymerElement) {
const oldLine = cacheLines.find(cacheLine => cacheLine.unit === unit); const oldLine = cacheLines.find(cacheLine => cacheLine.unit === unit);
if (oldLine) { if (oldLine) {
line.data.forEach((entity) => { line.data.forEach((entity) => {
const oldEntity = const oldEntity = oldLine.data.find(cacheEntity =>
oldLine.data.find(cacheEntity => entity.entity_id === cacheEntity.entity_id); entity.entity_id === cacheEntity.entity_id);
if (oldEntity) { if (oldEntity) {
oldEntity.states = oldEntity.states.concat(entity.states); oldEntity.states = oldEntity.states.concat(entity.states);
} else { } else {
@ -252,8 +252,8 @@ class HaStateHistoryData extends LocalizeMixin(PolymerElement) {
mergeTimeline(historyTimelines, cacheTimelines) { mergeTimeline(historyTimelines, cacheTimelines) {
historyTimelines.forEach((timeline) => { historyTimelines.forEach((timeline) => {
const oldTimeline = const oldTimeline = cacheTimelines.find(cacheTimeline =>
cacheTimelines.find(cacheTimeline => cacheTimeline.entity_id === timeline.entity_id); cacheTimeline.entity_id === timeline.entity_id);
if (oldTimeline) { if (oldTimeline) {
oldTimeline.data = oldTimeline.data.concat(timeline.data); oldTimeline.data = oldTimeline.data.concat(timeline.data);
} else { } else {

View File

@ -4,17 +4,15 @@ const fetchNotifications = conn => conn.sendMessagePromise({
type: 'persistent_notification/get' type: 'persistent_notification/get'
}); });
const subscribeUpdates = (conn, store) => const subscribeUpdates = (conn, store) => conn.subscribeEvents(
conn.subscribeEvents(
() => fetchNotifications(conn).then(ntf => store.setState(ntf, true)), () => fetchNotifications(conn).then(ntf => store.setState(ntf, true)),
'persistent_notifications_updated' 'persistent_notifications_updated'
); );
export const subscribeNotifications = (conn, onChange) => export const subscribeNotifications = (conn, onChange) => createCollection(
createCollection(
'_ntf', '_ntf',
fetchNotifications, fetchNotifications,
subscribeUpdates, subscribeUpdates,
conn, conn,
onChange onChange
); );

View File

@ -1,10 +1,9 @@
import { createCollection } from 'home-assistant-js-websocket'; import { createCollection } from 'home-assistant-js-websocket';
export const subscribePanels = (conn, onChange) => export const subscribePanels = (conn, onChange) => createCollection(
createCollection(
'_pnl', '_pnl',
conn_ => conn_.sendMessagePromise({ type: 'get_panels' }), conn_ => conn_.sendMessagePromise({ type: 'get_panels' }),
null, null,
conn, conn,
onChange onChange
); );

View File

@ -4,17 +4,15 @@ const fetchThemes = conn => conn.sendMessagePromise({
type: 'frontend/get_themes' type: 'frontend/get_themes'
}); });
const subscribeUpdates = (conn, store) => const subscribeUpdates = (conn, store) => conn.subscribeEvents(
conn.subscribeEvents(
event => store.setState(event.data, true), event => store.setState(event.data, true),
'themes_updated' 'themes_updated'
); );
export const subscribeThemes = (conn, onChange) => export const subscribeThemes = (conn, onChange) => createCollection(
createCollection(
'_thm', '_thm',
fetchThemes, fetchThemes,
subscribeUpdates, subscribeUpdates,
conn, conn,
onChange onChange
); );

View File

@ -1,10 +1,9 @@
import { createCollection, getUser } from 'home-assistant-js-websocket'; import { createCollection, getUser } from 'home-assistant-js-websocket';
export const subscribeUser = (conn, onChange) => export const subscribeUser = (conn, onChange) => createCollection(
createCollection(
'_usr', '_usr',
conn_ => getUser(conn_), conn_ => getUser(conn_),
null, null,
conn, conn,
onChange onChange
); );

View File

@ -145,8 +145,8 @@ class HaMoreInfoDialog extends DialogMixin(PolymerElement) {
this.opened = true; this.opened = true;
})); }));
if (!isComponentLoaded(this.hass, 'config.entity_registry') || if (!isComponentLoaded(this.hass, 'config.entity_registry')
(oldVal && oldVal.entity_id === newVal.entity_id)) { || (oldVal && oldVal.entity_id === newVal.entity_id)) {
return; return;
} }

View File

@ -134,8 +134,8 @@ class MoreInfoAlarmControlPanel extends LocalizeMixin(EventsMixin(PolymerElement
const props = { const props = {
_codeFormat: newVal.attributes.code_format, _codeFormat: newVal.attributes.code_format,
_armVisible: state === 'disarmed', _armVisible: state === 'disarmed',
_disarmVisible: this._armedStates.includes(state) || _disarmVisible: this._armedStates.includes(state)
state === 'pending' || state === 'triggered' || state === 'arming' || state === 'pending' || state === 'triggered' || state === 'arming'
}; };
props._inputEnabled = props._disarmVisible || props._armVisible; props._inputEnabled = props._disarmVisible || props._armVisible;
this.setProperties(props); this.setProperties(props);

View File

@ -63,9 +63,9 @@ class MoreInfoCamera extends EventsMixin(PolymerElement) {
computeCameraImageUrl(hass, stateObj, isVisible) { computeCameraImageUrl(hass, stateObj, isVisible) {
if (hass.demo) { if (hass.demo) {
return '/demo/webcam.jpg'; return '/demo/webcam.jpg';
} else if (stateObj && isVisible) { } if (stateObj && isVisible) {
return '/api/camera_proxy_stream/' + stateObj.entity_id + return '/api/camera_proxy_stream/' + stateObj.entity_id
'?token=' + stateObj.attributes.access_token; + '?token=' + stateObj.attributes.access_token;
} }
// Return an empty image if no stateObj (= dialog not open) or in cleanup mode. // Return an empty image if no stateObj (= dialog not open) or in cleanup mode.
return emptyImageBase64; return emptyImageBase64;

View File

@ -267,8 +267,9 @@ class MoreInfoClimate extends LocalizeMixin(EventsMixin(PolymerElement)) {
// force polymer to recognize selected item change (to update actual label) // force polymer to recognize selected item change (to update actual label)
this.operationIndex = -1; this.operationIndex = -1;
if (this.stateObj.attributes.operation_list) { if (this.stateObj.attributes.operation_list) {
this.operationIndex = this.operationIndex = (
this.stateObj.attributes.operation_list.indexOf(this.stateObj.attributes.operation_mode); this.stateObj.attributes.operation_list.indexOf(this.stateObj.attributes.operation_mode)
);
} }
} }
@ -276,8 +277,9 @@ class MoreInfoClimate extends LocalizeMixin(EventsMixin(PolymerElement)) {
// force polymer to recognize selected item change (to update actual label) // force polymer to recognize selected item change (to update actual label)
this.swingIndex = -1; this.swingIndex = -1;
if (this.stateObj.attributes.swing_list) { if (this.stateObj.attributes.swing_list) {
this.swingIndex = this.swingIndex = (
this.stateObj.attributes.swing_list.indexOf(this.stateObj.attributes.swing_mode); this.stateObj.attributes.swing_list.indexOf(this.stateObj.attributes.swing_mode)
);
} }
} }
@ -285,23 +287,24 @@ class MoreInfoClimate extends LocalizeMixin(EventsMixin(PolymerElement)) {
// force polymer to recognize selected item change (to update actual label) // force polymer to recognize selected item change (to update actual label)
this.fanIndex = -1; this.fanIndex = -1;
if (this.stateObj.attributes.fan_list) { if (this.stateObj.attributes.fan_list) {
this.fanIndex = this.fanIndex = (
this.stateObj.attributes.fan_list.indexOf(this.stateObj.attributes.fan_mode); this.stateObj.attributes.fan_list.indexOf(this.stateObj.attributes.fan_mode)
);
} }
} }
computeTemperatureStepSize(hass, stateObj) { computeTemperatureStepSize(hass, stateObj) {
if (stateObj.attributes.target_temp_step) { if (stateObj.attributes.target_temp_step) {
return stateObj.attributes.target_temp_step; return stateObj.attributes.target_temp_step;
} else if (hass.config.unit_system.temperature.indexOf('F') !== -1) { } if (hass.config.unit_system.temperature.indexOf('F') !== -1) {
return 1; return 1;
} }
return 0.5; return 0.5;
} }
supportsTemperatureControls(stateObj) { supportsTemperatureControls(stateObj) {
return this.supportsTemperature(stateObj) || return this.supportsTemperature(stateObj)
this.supportsTemperatureRange(stateObj); || this.supportsTemperatureRange(stateObj);
} }
supportsTemperature(stateObj) { supportsTemperature(stateObj) {

View File

@ -103,8 +103,8 @@ class MoreInfoFan extends LocalizeMixin(EventsMixin(PolymerElement)) {
if (newVal) { if (newVal) {
this.setProperties({ this.setProperties({
oscillationToggleChecked: newVal.attributes.oscillating, oscillationToggleChecked: newVal.attributes.oscillating,
speedIndex: newVal.attributes.speed_list ? speedIndex: newVal.attributes.speed_list
newVal.attributes.speed_list.indexOf(newVal.attributes.speed) : -1, ? newVal.attributes.speed_list.indexOf(newVal.attributes.speed) : -1,
}); });
} }

View File

@ -194,7 +194,7 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) {
computePlaybackControlIcon(playerObj) { computePlaybackControlIcon(playerObj) {
if (playerObj.isPlaying) { if (playerObj.isPlaying) {
return playerObj.supportsPause ? 'hass:pause' : 'hass:stop'; return playerObj.supportsPause ? 'hass:pause' : 'hass:stop';
} else if (playerObj.hasMediaControl || playerObj.isOff || playerObj.isIdle) { } if (playerObj.hasMediaControl || playerObj.isOff || playerObj.isIdle) {
if (playerObj.hasMediaControl && playerObj.supportsPause && !playerObj.isPaused) { if (playerObj.hasMediaControl && playerObj.supportsPause && !playerObj.isPaused) {
return 'hass:play-pause'; return 'hass:play-pause';
} }

View File

@ -25,8 +25,8 @@ class MoreInfoUpdater extends PolymerElement {
} }
computeReleaseNotes(stateObj) { computeReleaseNotes(stateObj) {
return (stateObj.attributes.release_notes || return (stateObj.attributes.release_notes
'https://www.home-assistant.io/docs/installation/updating/'); || 'https://www.home-assistant.io/docs/installation/updating/');
} }
} }

View File

@ -128,9 +128,9 @@ class MoreInfoControls extends EventsMixin(PolymerElement) {
} }
_computeShowHistoryComponent(hass, stateObj) { _computeShowHistoryComponent(hass, stateObj) {
return hass && stateObj && return hass && stateObj
isComponentLoaded(hass, 'history') && && isComponentLoaded(hass, 'history')
!DOMAINS_MORE_INFO_NO_HISTORY.includes(computeStateDomain(stateObj)); && !DOMAINS_MORE_INFO_NO_HISTORY.includes(computeStateDomain(stateObj));
} }
_computeDomain(stateObj) { _computeDomain(stateObj) {

View File

@ -18,8 +18,7 @@ import '../layouts/app/home-assistant.js';
/* polyfill for paper-dropdown */ /* polyfill for paper-dropdown */
setTimeout( setTimeout(
() => () => import(/* webpackChunkName: "polyfill-web-animations-next" */ 'web-animations-js/web-animations-next-lite.min.js'),
import(/* webpackChunkName: "polyfill-web-animations-next" */ 'web-animations-js/web-animations-next-lite.min.js'),
2000 2000
); );

View File

@ -8,5 +8,4 @@ import '../resources/roboto.js';
import '../auth/ha-authorize.js'; import '../auth/ha-authorize.js';
/* polyfill for paper-dropdown */ /* polyfill for paper-dropdown */
setTimeout(() => setTimeout(() => import(/* webpackChunkName: "polyfill-web-animations-next" */ 'web-animations-js/web-animations-next-lite.min.js'), 2000);
import(/* webpackChunkName: "polyfill-web-animations-next" */ 'web-animations-js/web-animations-next-lite.min.js'), 2000);

View File

@ -15,10 +15,10 @@ import { subscribeUser } from '../data/ws-user.js';
const hassUrl = `${location.protocol}//${location.host}`; const hassUrl = `${location.protocol}//${location.host}`;
const isExternal = location.search.includes('external_auth=1'); const isExternal = location.search.includes('external_auth=1');
const authProm = isExternal ? const authProm = isExternal
() => import('../common/auth/external_auth.js') ? () => import('../common/auth/external_auth.js')
.then(mod => new mod.default(hassUrl)) : .then(mod => new mod.default(hassUrl))
() => getAuth({ : () => getAuth({
hassUrl, hassUrl,
saveTokens, saveTokens,
loadTokens: () => Promise.resolve(loadTokens()), loadTokens: () => Promise.resolve(loadTokens()),

View File

@ -4,9 +4,9 @@ import createCustomPanelElement from '../util/custom-panel/create-custom-panel-e
import setCustomPanelProperties from '../util/custom-panel/set-custom-panel-properties.js'; import setCustomPanelProperties from '../util/custom-panel/set-custom-panel-properties.js';
const webComponentsSupported = ( const webComponentsSupported = (
'customElements' in window && 'customElements' in window
'import' in document.createElement('link') && && 'import' in document.createElement('link')
'content' in document.createElement('template')); && 'content' in document.createElement('template'));
let es5Loaded = null; let es5Loaded = null;

View File

@ -9,8 +9,7 @@ export default superClass => class extends superClass {
super.ready(); super.ready();
this.addEventListener('hass-logout', () => this._handleLogout()); this.addEventListener('hass-logout', () => this._handleLogout());
// HACK :( We don't have a way yet to trigger an update of `subscribeUser` // HACK :( We don't have a way yet to trigger an update of `subscribeUser`
this.addEventListener('hass-refresh-current-user', () => this.addEventListener('hass-refresh-current-user', () => getUser(this.hass.connection).then(user => this._updateHass({ user })));
getUser(this.hass.connection).then(user => this._updateHass({ user })));
} }
hassConnected() { hassConnected() {

View File

@ -18,8 +18,7 @@ import hassCallApi from '../../util/hass-call-api.js';
import computeStateName from '../../common/entity/compute_state_name.js'; import computeStateName from '../../common/entity/compute_state_name.js';
import { subscribePanels } from '../../data/ws-panels'; import { subscribePanels } from '../../data/ws-panels';
export default superClass => export default superClass => class extends EventsMixin(LocalizeMixin(superClass)) {
class extends EventsMixin(LocalizeMixin(superClass)) {
ready() { ready() {
super.ready(); super.ready();
this._handleConnProm(); this._handleConnProm();
@ -60,8 +59,8 @@ export default superClass =>
let message; let message;
let name; let name;
if (serviceData.entity_id && this.hass.states && if (serviceData.entity_id && this.hass.states
this.hass.states[serviceData.entity_id]) { && this.hass.states[serviceData.entity_id]) {
name = computeStateName(this.hass.states[serviceData.entity_id]); name = computeStateName(this.hass.states[serviceData.entity_id]);
} }
if (service === 'turn_on' && serviceData.entity_id) { if (service === 'turn_on' && serviceData.entity_id) {
@ -90,8 +89,7 @@ export default superClass =>
throw err; throw err;
} }
}, },
callApi: async (method, path, parameters) => callApi: async (method, path, parameters) => hassCallApi(auth, method, path, parameters),
hassCallApi(auth, method, path, parameters),
fetchWithAuth: (path, init) => fetchWithAuth(auth, `${auth.data.hassUrl}${path}`, init), fetchWithAuth: (path, init) => fetchWithAuth(auth, `${auth.data.hassUrl}${path}`, init),
// For messages that do not get a response // For messages that do not get a response
sendWS: (msg) => { sendWS: (msg) => {
@ -146,4 +144,4 @@ export default superClass =>
super.hassDisconnected(); super.hassDisconnected();
this._updateHass({ connected: false }); this._updateHass({ connected: false });
} }
}; };

View File

@ -1,5 +1,4 @@
export default superClass => export default superClass => class extends superClass {
class extends superClass {
ready() { ready() {
super.ready(); super.ready();
this.addEventListener('register-dialog', e => this.registerDialog(e.detail)); this.addEventListener('register-dialog', e => this.registerDialog(e.detail));
@ -20,4 +19,4 @@ export default superClass =>
loaded.then(dialogEl => dialogEl.showDialog(showEv.detail)); loaded.then(dialogEl => dialogEl.showDialog(showEv.detail));
}); });
} }
}; };

View File

@ -1,7 +1,6 @@
import LocalizeMixin from '../../mixins/localize-mixin.js'; import LocalizeMixin from '../../mixins/localize-mixin.js';
export default superClass => export default superClass => class extends LocalizeMixin(superClass) {
class extends LocalizeMixin(superClass) {
hassConnected() { hassConnected() {
super.hassConnected(); super.hassConnected();
// Need to load in advance because when disconnected, can't dynamically load code. // Need to load in advance because when disconnected, can't dynamically load code.
@ -24,4 +23,4 @@ export default superClass =>
} }
this.__discToast.opened = true; this.__discToast.opened = true;
} }
}; };

View File

@ -8,9 +8,13 @@ export default superClass => class extends superClass {
// Exists so all methods can safely call super method // Exists so all methods can safely call super method
hassConnected() {} hassConnected() {}
hassReconnected() {} hassReconnected() {}
hassDisconnected() {} hassDisconnected() {}
panelUrlChanged(newPanelUrl) {} panelUrlChanged(newPanelUrl) {}
hassChanged(hass, oldHass) { hassChanged(hass, oldHass) {
this.__provideHass.forEach((el) => { this.__provideHass.forEach((el) => {
el.hass = hass; el.hass = hass;

View File

@ -5,8 +5,8 @@ import { html } from '@polymer/polymer/lib/utils/html-tag.js';
import { PolymerElement } from '@polymer/polymer/polymer-element.js'; import { PolymerElement } from '@polymer/polymer/polymer-element.js';
import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js'; import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
import '../../layouts/home-assistant-main.js'; import '../home-assistant-main.js';
import '../../layouts/ha-init-page.js'; import '../ha-init-page.js';
import '../../resources/ha-style.js'; import '../../resources/ha-style.js';
import registerServiceWorker from '../../util/register-service-worker.js'; import registerServiceWorker from '../../util/register-service-worker.js';

View File

@ -1,14 +1,12 @@
import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js'; import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
export default superClass => export default superClass => class extends superClass {
class extends superClass {
ready() { ready() {
super.ready(); super.ready();
this.addEventListener('hass-more-info', e => this._handleMoreInfo(e)); this.addEventListener('hass-more-info', e => this._handleMoreInfo(e));
// Load it once we are having the initial rendering done. // Load it once we are having the initial rendering done.
afterNextRender(null, () => afterNextRender(null, () => import(/* webpackChunkName: "more-info-dialog" */ '../../dialogs/ha-more-info-dialog.js'));
import(/* webpackChunkName: "more-info-dialog" */ '../../dialogs/ha-more-info-dialog.js'));
} }
async _handleMoreInfo(ev) { async _handleMoreInfo(ev) {
@ -19,4 +17,4 @@ export default superClass =>
} }
this._updateHass({ moreInfoEntityId: ev.detail.entityId }); this._updateHass({ moreInfoEntityId: ev.detail.entityId });
} }
}; };

View File

@ -1,5 +1,4 @@
export default superClass => export default superClass => class extends superClass {
class extends superClass {
ready() { ready() {
super.ready(); super.ready();
this.registerDialog({ this.registerDialog({
@ -8,4 +7,4 @@ export default superClass =>
dialogImport: () => import(/* webpackChunkName: "notification-manager" */ '../../managers/notification-manager.js'), dialogImport: () => import(/* webpackChunkName: "notification-manager" */ '../../managers/notification-manager.js'),
}); });
} }
}; };

View File

@ -1,15 +1,13 @@
import { storeState } from '../../util/ha-pref-storage.js'; import { storeState } from '../../util/ha-pref-storage.js';
export default superClass => export default superClass => class extends superClass {
class extends superClass {
ready() { ready() {
super.ready(); super.ready();
this.addEventListener('hass-dock-sidebar', e => this.addEventListener('hass-dock-sidebar', e => this._handleDockSidebar(e));
this._handleDockSidebar(e));
} }
_handleDockSidebar(ev) { _handleDockSidebar(ev) {
this._updateHass({ dockedSidebar: ev.detail.dock }); this._updateHass({ dockedSidebar: ev.detail.dock });
storeState(this.hass); storeState(this.hass);
} }
}; };

View File

@ -284,8 +284,8 @@ class PartialCards extends EventsMixin(NavigateMixin(PolymerElement)) {
} }
isView(currentView, defaultView) { isView(currentView, defaultView) {
return (currentView || defaultView) && return (currentView || defaultView)
this.hass.states[currentView || DEFAULT_VIEW_ENTITY_ID]; && this.hass.states[currentView || DEFAULT_VIEW_ENTITY_ID];
} }
_defaultViewFilter(hass, entityId) { _defaultViewFilter(hass, entityId) {

View File

@ -5,8 +5,7 @@ import EventsMixin from './events-mixin';
* @polymerMixin * @polymerMixin
* @appliesMixin EventsMixin * @appliesMixin EventsMixin
*/ */
export default dedupingMixin(superClass => export default dedupingMixin(superClass => class extends EventsMixin(superClass) {
class extends EventsMixin(superClass) {
navigate(path, replace = false) { navigate(path, replace = false) {
if (replace) { if (replace) {
history.replaceState(null, null, path); history.replaceState(null, null, path);
@ -15,4 +14,4 @@ export default dedupingMixin(superClass =>
} }
this.fire('location-changed'); this.fire('location-changed');
} }
}); });

View File

@ -231,9 +231,9 @@ class HaAutomationEditor extends
} }
backTapped() { backTapped() {
if (this.dirty && if (this.dirty
// eslint-disable-next-line // eslint-disable-next-line
!confirm(this.localize('ui.panel.config.automation.editor.unsaved_confirm'))) { && !confirm(this.localize('ui.panel.config.automation.editor.unsaved_confirm'))) {
return; return;
} }
history.back(); history.back();

View File

@ -76,17 +76,17 @@ class HaConfigAutomation extends PolymerElement {
Object.keys(hass.states).forEach(function (key) { Object.keys(hass.states).forEach(function (key) {
var entity = hass.states[key]; var entity = hass.states[key];
if (computeStateDomain(entity) === 'automation' && if (computeStateDomain(entity) === 'automation'
'id' in entity.attributes) { && 'id' in entity.attributes) {
automations.push(entity); automations.push(entity);
} }
}); });
return automations.sort(function entitySortBy(entityA, entityB) { return automations.sort(function entitySortBy(entityA, entityB) {
var nameA = (entityA.attributes.alias || var nameA = (entityA.attributes.alias
entityA.entity_id).toLowerCase(); || entityA.entity_id).toLowerCase();
var nameB = (entityB.attributes.alias || var nameB = (entityB.attributes.alias
entityB.entity_id).toLowerCase(); || entityB.entity_id).toLowerCase();
if (nameA < nameB) { if (nameA < nameB) {
return -1; return -1;

View File

@ -178,7 +178,7 @@ class HaConfigCloudAccount extends EventsMixin(PolymerElement) {
this._accountUpdater = null; this._accountUpdater = null;
} }
return; return;
} else if (this._accountUpdater) { } if (this._accountUpdater) {
return; return;
} }
setTimeout(() => { setTimeout(() => {

View File

@ -114,8 +114,8 @@ class HaConfigCloudForgotPassword extends EventsMixin(PolymerElement) {
}); });
}, err => this.setProperties({ }, err => this.setProperties({
_requestInProgress: false, _requestInProgress: false,
_error: err && err.body && err.body.message ? _error: err && err.body && err.body.message
err.body.message : 'Unknown error', ? err.body.message : 'Unknown error',
})); }));
} }
} }

View File

@ -155,8 +155,7 @@ class HaConfigCloudLogin extends
super.connectedCallback(); super.connectedCallback();
if (this.flashMessage) { if (this.flashMessage) {
// Wait for DOM to be drawn // Wait for DOM to be drawn
requestAnimationFrame(() => requestAnimationFrame(() => requestAnimationFrame(() =>
requestAnimationFrame(() =>
this.$.flashRipple.simulatedRipple())); this.$.flashRipple.simulatedRipple()));
} }
} }

View File

@ -80,11 +80,10 @@ class HaConfigEntryPage extends NavigateMixin(EventsMixin(PolymerElement)) {
_computeConfigEntryDevices(configEntry, devices) { _computeConfigEntryDevices(configEntry, devices) {
if (!devices) return []; if (!devices) return [];
return devices.filter(device => return devices
device.config_entries.includes(configEntry.entry_id)).sort((dev1, dev2) => .filter(device => device.config_entries.includes(configEntry.entry_id))
// Put hub devices first, then sort by name .sort((dev1, dev2) => (!!dev1.hub_device_id - !!dev2.hub_device_id)
(!!dev1.hub_device_id - !!dev2.hub_device_id) || || compare(dev1.name, dev2.name));
compare(dev1.name, dev2.name));
} }
_removeEntry() { _removeEntry() {
@ -104,4 +103,3 @@ class HaConfigEntryPage extends NavigateMixin(EventsMixin(PolymerElement)) {
} }
customElements.define('ha-config-entry-page', HaConfigEntryPage); customElements.define('ha-config-entry-page', HaConfigEntryPage);

View File

@ -178,9 +178,9 @@ class HaConfigFlow extends
this._loading = true; this._loading = true;
this._opened = true; this._opened = true;
const fetchStep = continueFlowId ? const fetchStep = continueFlowId
this.hass.callApi('get', `config/config_entries/flow/${continueFlowId}`) : ? this.hass.callApi('get', `config/config_entries/flow/${continueFlowId}`)
this.hass.callApi('post', 'config/config_entries/flow', { handler: newFlowForHandler }); : this.hass.callApi('post', 'config/config_entries/flow', { handler: newFlowForHandler });
const curInstance = this._instance; const curInstance = this._instance;
@ -300,9 +300,8 @@ class HaConfigFlow extends
_computeCanSubmit(step, stepData) { _computeCanSubmit(step, stepData) {
// We can submit if all required fields are filled in // We can submit if all required fields are filled in
return step !== null && step.type === 'form' && stepData !== null && return step !== null && step.type === 'form' && stepData !== null
step.data_schema.every(field => && step.data_schema.every(field => field.optional || !['', undefined].includes(stepData[field.name]));
field.optional || !['', undefined].includes(stepData[field.name]));
} }
_increaseCounter() { _increaseCounter() {

View File

@ -62,8 +62,7 @@ class HaConfigCustomize extends LocalizeMixin(PolymerElement) {
type: Object, type: Object,
value: { value: {
component: 'ha-form-customize', component: 'ha-form-customize',
computeSelectCaption: stateObj => computeSelectCaption: stateObj => computeStateName(stateObj) + ' (' + computeStateDomain(stateObj) + ')'
computeStateName(stateObj) + ' (' + computeStateDomain(stateObj) + ')'
} }
}, },
}; };

View File

@ -195,12 +195,11 @@ class HaFormCustomize extends PolymerElement {
} }
getNewAttributesOptions(localAttributes, globalAttributes, existingAttributes, newAttributes) { getNewAttributesOptions(localAttributes, globalAttributes, existingAttributes, newAttributes) {
const knownKeys = const knownKeys = Object.keys(hassAttributeUtil.LOGIC_STATE_ATTRIBUTES)
Object.keys(hassAttributeUtil.LOGIC_STATE_ATTRIBUTES)
.filter((key) => { .filter((key) => {
const conf = hassAttributeUtil.LOGIC_STATE_ATTRIBUTES[key]; const conf = hassAttributeUtil.LOGIC_STATE_ATTRIBUTES[key];
return conf && (!conf.domains || !this.entity || return conf && (!conf.domains || !this.entity
conf.domains.includes(computeStateDomain(this.entity))); || conf.domains.includes(computeStateDomain(this.entity)));
}) })
.filter(this.filterFromAttributes(localAttributes)) .filter(this.filterFromAttributes(localAttributes))
.filter(this.filterFromAttributes(globalAttributes)) .filter(this.filterFromAttributes(globalAttributes))
@ -249,14 +248,14 @@ class HaFormCustomize extends PolymerElement {
} }
attributesObserver() { attributesObserver() {
this.hasLocalAttributes = this.hasLocalAttributes = (this.localAttributes
this.localAttributes && this.localAttributes.some(attr => !attr.closed); && this.localAttributes.some(attr => !attr.closed));
this.hasGlobalAttributes = this.hasGlobalAttributes = (this.globalAttributes
this.globalAttributes && this.globalAttributes.some(attr => !attr.closed); && this.globalAttributes.some(attr => !attr.closed));
this.hasExistingAttributes = this.hasExistingAttributes = (this.existingAttributes
this.existingAttributes && this.existingAttributes.some(attr => !attr.closed); && this.existingAttributes.some(attr => !attr.closed));
this.hasNewAttributes = this.hasNewAttributes = (this.newAttributes
this.newAttributes && this.newAttributes.some(attr => !attr.closed); && this.newAttributes.some(attr => !attr.closed));
this.newAttributesOptions = this.getNewAttributesOptions( this.newAttributesOptions = this.getNewAttributesOptions(
this.localAttributes, this.localAttributes,
this.globalAttributes, this.globalAttributes,

View File

@ -125,9 +125,9 @@ class HaEntityConfig extends PolymerElement {
} }
computeSelectCaption(stateObj) { computeSelectCaption(stateObj) {
return this.config.computeSelectCaption ? return this.config.computeSelectCaption
this.config.computeSelectCaption(stateObj) : ? this.config.computeSelectCaption(stateObj)
computeStateName(stateObj); : computeStateName(stateObj);
} }
computeShowNoDevices(formState) { computeShowNoDevices(formState) {
@ -156,7 +156,7 @@ class HaEntityConfig extends PolymerElement {
if (entities.length === 0) { if (entities.length === 0) {
this.formState = 'no-devices'; this.formState = 'no-devices';
return; return;
} else if (!oldEntities) { } if (!oldEntities) {
this.selectedEntity = 0; this.selectedEntity = 0;
return; return;
} }

View File

@ -227,9 +227,9 @@ class HaScriptEditor extends
} }
backTapped() { backTapped() {
if (this.dirty && if (this.dirty
// eslint-disable-next-line // eslint-disable-next-line
!confirm('You have unsaved changes. Are you sure you want to leave?')) { && !confirm('You have unsaved changes. Are you sure you want to leave?')) {
return; return;
} }
history.back(); history.back();
@ -251,8 +251,8 @@ class HaScriptEditor extends
} }
saveScript() { saveScript() {
var id = this.creatingNew ? var id = this.creatingNew
'' + Date.now() : computeObjectId(this.script.entity_id); ? '' + Date.now() : computeObjectId(this.script.entity_id);
this.hass.callApi('post', 'config/script/config/' + id, this.config).then(() => { this.hass.callApi('post', 'config/script/config/' + id, this.config).then(() => {
this.dirty = false; this.dirty = false;

View File

@ -421,10 +421,10 @@ class HaConfigZwave extends LocalizeMixin(EventsMixin(PolymerElement)) {
if (ent.attributes.node_id === undefined) { if (ent.attributes.node_id === undefined) {
return false; return false;
} }
return (!ent.attributes.hidden && return (!ent.attributes.hidden
'node_id' in ent.attributes && && 'node_id' in ent.attributes
ent.attributes.node_id === nodeid && && ent.attributes.node_id === nodeid
(!(ent.entity_id).match('zwave[.]'))); && (!(ent.entity_id).match('zwave[.]')));
}) })
.sort(sortByName); .sort(sortByName);
} }
@ -488,9 +488,9 @@ class HaConfigZwave extends LocalizeMixin(EventsMixin(PolymerElement)) {
} }
computeSelectCaption(stateObj) { computeSelectCaption(stateObj) {
return computeStateName(stateObj) + ' (Node:' + return computeStateName(stateObj) + ' (Node:'
stateObj.attributes.node_id + ' ' + + stateObj.attributes.node_id + ' '
stateObj.attributes.query_stage + ')'; + stateObj.attributes.query_stage + ')';
} }
computeSelectCaptionEnt(stateObj) { computeSelectCaptionEnt(stateObj) {
@ -534,6 +534,7 @@ class HaConfigZwave extends LocalizeMixin(EventsMixin(PolymerElement)) {
_nodeMoreInfo() { _nodeMoreInfo() {
this.fire('hass-more-info', { entityId: this.nodes[this.selectedNode].entity_id }); this.fire('hass-more-info', { entityId: this.nodes[this.selectedNode].entity_id });
} }
_entityMoreInfo() { _entityMoreInfo() {
this.fire('hass-more-info', { entityId: this.entities[this.selectedEntity].entity_id }); this.fire('hass-more-info', { entityId: this.entities[this.selectedEntity].entity_id });
} }

View File

@ -231,8 +231,8 @@ class ZwaveGroups extends PolymerElement {
} }
_computeAssocServiceData(selectedGroup, type) { _computeAssocServiceData(selectedGroup, type) {
if (!this.groups === -1 || selectedGroup === -1 || if (!this.groups === -1 || selectedGroup === -1
this.selectedNode === -1 || this._selectedTargetNode === -1) return -1; || this.selectedNode === -1 || this._selectedTargetNode === -1) return -1;
return { return {
node_id: this.nodes[this.selectedNode].attributes.node_id, node_id: this.nodes[this.selectedNode].attributes.node_id,
association: type, association: type,

View File

@ -206,8 +206,8 @@ class ZwaveNodeConfig extends PolymerElement {
_nodesChanged() { _nodesChanged() {
if (!this.nodes) return; if (!this.nodes) return;
this.setProperties({ _selectedConfigParameter: -1 }); this.setProperties({ _selectedConfigParameter: -1 });
this._wakeupNode = (this.nodes[this.selectedNode].attributes.wake_up_interval === 0 || this._wakeupNode = (this.nodes[this.selectedNode].attributes.wake_up_interval === 0
this.nodes[this.selectedNode].attributes.wake_up_interval); || this.nodes[this.selectedNode].attributes.wake_up_interval);
if (this._wakeupNode) { if (this._wakeupNode) {
if (this.nodes[this.selectedNode].attributes.wake_up_interval === 0) this.setProperties({ _wakeupInput: '' }); if (this.nodes[this.selectedNode].attributes.wake_up_interval === 0) this.setProperties({ _wakeupInput: '' });
else { else {
@ -218,8 +218,8 @@ class ZwaveNodeConfig extends PolymerElement {
} }
_computeGetWakeupValue(selectedNode) { _computeGetWakeupValue(selectedNode) {
if (this.selectedNode === -1 || if (this.selectedNode === -1
!this.nodes[selectedNode].attributes.wake_up_interval) return 'unknown'; || !this.nodes[selectedNode].attributes.wake_up_interval) return 'unknown';
return (this.nodes[selectedNode].attributes.wake_up_interval); return (this.nodes[selectedNode].attributes.wake_up_interval);
} }

View File

@ -124,8 +124,8 @@ class HaPanelDevEvent extends EventsMixin(PolymerElement) {
} }
computeFormClasses(narrow) { computeFormClasses(narrow) {
return narrow ? return narrow
'content fit' : 'content fit layout horizontal'; ? 'content fit' : 'content fit layout horizontal';
} }
} }

View File

@ -341,8 +341,8 @@ class HaPanelDevInfo extends EventsMixin(PolymerElement) {
const dateTime = new Date(date * 1000); const dateTime = new Date(date * 1000);
const dateTimeDay = new Date(date * 1000).setHours(0, 0, 0, 0); const dateTimeDay = new Date(date * 1000).setHours(0, 0, 0, 0);
return dateTimeDay < today ? return dateTimeDay < today
formatDateTime(dateTime) : formatTime(dateTime); ? formatDateTime(dateTime) : formatTime(dateTime);
} }
openLog(event) { openLog(event) {
@ -360,8 +360,8 @@ class HaPanelDevInfo extends EventsMixin(PolymerElement) {
} }
_defaultPageText() { _defaultPageText() {
return `>> ${localStorage.defaultPage === 'lovelace' ? return `>> ${localStorage.defaultPage === 'lovelace'
'Remove' : 'Set'} lovelace as default page on this device <<`; ? 'Remove' : 'Set'} lovelace as default page on this device <<`;
} }
_toggleDefaultPage() { _toggleDefaultPage() {

View File

@ -214,8 +214,8 @@ class HaPanelDevState extends EventsMixin(PolymerElement) {
var attr; var attr;
var attrRaw = this._stateAttributes.replace(/^\s+|\s+$/g, ''); var attrRaw = this._stateAttributes.replace(/^\s+|\s+$/g, '');
try { try {
attr = attrRaw ? attr = attrRaw
JSON.parse(attrRaw) : {}; ? JSON.parse(attrRaw) : {};
} catch (err) { } catch (err) {
/* eslint-disable no-alert */ /* eslint-disable no-alert */
alert('Error parsing JSON: ' + err); alert('Error parsing JSON: ' + err);
@ -261,7 +261,7 @@ class HaPanelDevState extends EventsMixin(PolymerElement) {
if (key.includes(keyFilter) && !multiMode) { if (key.includes(keyFilter) && !multiMode) {
return true; // in single mode we're already satisfied with this match return true; // in single mode we're already satisfied with this match
} else if (!key.includes(keyFilter) && multiMode) { } if (!key.includes(keyFilter) && multiMode) {
continue; continue;
} }

View File

@ -161,8 +161,8 @@ For loop example:
} }
computeFormClasses(narrow) { computeFormClasses(narrow) {
return narrow ? return narrow
'content fit' : 'content fit layout horizontal'; ? 'content fit' : 'content fit layout horizontal';
} }
computeRenderedClasses(error) { computeRenderedClasses(error) {

View File

@ -32,8 +32,8 @@ class HuiConditionalCard extends PolymerElement {
} }
setConfig(config) { setConfig(config) {
if (!config || !config.card || !Array.isArray(config.conditions) || if (!config || !config.card || !Array.isArray(config.conditions)
!config.conditions.every(c => c.entity && (c.state || c.state_not))) { || !config.conditions.every(c => c.entity && (c.state || c.state_not))) {
throw new Error('Error in card configuration.'); throw new Error('Error in card configuration.');
} }

View File

@ -134,8 +134,7 @@ class HuiEntitiesCard extends EventsMixin(PolymerElement) {
} }
_filterEntities(items) { _filterEntities(items) {
return items.filter(item => (typeof item === 'string' || item.entity)).map(item => return items.filter(item => (typeof item === 'string' || item.entity)).map(item => (typeof item === 'string' ? item : item.entity));
(typeof item === 'string' ? item : item.entity));
} }
} }

View File

@ -102,8 +102,8 @@ class HuiPictureEntityCard extends EventsMixin(LocalizeMixin(PolymerElement)) {
} }
this._entityDomain = computeDomain(config.entity); this._entityDomain = computeDomain(config.entity);
if (this._entityDomain !== 'camera' && if (this._entityDomain !== 'camera'
(!config.image && !config.state_image && !config.camera_image)) { && (!config.image && !config.state_image && !config.camera_image)) {
throw new Error('No image source configured.'); throw new Error('No image source configured.');
} }
@ -116,8 +116,8 @@ class HuiPictureEntityCard extends EventsMixin(LocalizeMixin(PolymerElement)) {
const stateObj = hass.states[entityId]; const stateObj = hass.states[entityId];
// Nothing changed // Nothing changed
if ((!stateObj && this._oldState === UNAVAILABLE) || if ((!stateObj && this._oldState === UNAVAILABLE)
(stateObj && stateObj.state === this._oldState)) { || (stateObj && stateObj.state === this._oldState)) {
return; return;
} }

View File

@ -123,9 +123,9 @@ class HuiPictureGlanceCard extends NavigateMixin(LocalizeMixin(EventsMixin(Polym
} }
setConfig(config) { setConfig(config) {
if (!config || !config.entities || !Array.isArray(config.entities) || if (!config || !config.entities || !Array.isArray(config.entities)
!(config.image || config.camera_image || config.state_image) || || !(config.image || config.camera_image || config.state_image)
(config.state_image && !config.entity)) { || (config.state_image && !config.entity)) {
throw new Error('Invalid card configuration'); throw new Error('Invalid card configuration');
} }
const entities = processConfigEntities(config.entities); const entities = processConfigEntities(config.entities);

View File

@ -27,7 +27,7 @@ function computeUsedEntities(config) {
export default function computeUnusedEntities(hass, config) { export default function computeUnusedEntities(hass, config) {
const usedEntities = computeUsedEntities(config); const usedEntities = computeUsedEntities(config);
return Object.keys(hass.states).filter(entity => !usedEntities.has(entity) && return Object.keys(hass.states).filter(entity => !usedEntities.has(entity)
!(config.excluded_entities && config.excluded_entities.includes(entity)) && && !(config.excluded_entities && config.excluded_entities.includes(entity))
!EXCLUDED_DOMAINS.includes(entity.split('.', 1)[0])).sort(); && !EXCLUDED_DOMAINS.includes(entity.split('.', 1)[0])).sort();
} }

View File

@ -6,8 +6,8 @@ export default function turnOnOffEntities(hass, entityIds, turnOn = true) {
entityIds.forEach((entityId) => { entityIds.forEach((entityId) => {
if ((STATES_OFF.includes(hass.states[entityId].state)) === turnOn) { if ((STATES_OFF.includes(hass.states[entityId].state)) === turnOn) {
const stateDomain = computeDomain(entityId); const stateDomain = computeDomain(entityId);
const serviceDomain = ['cover', 'lock'].includes(stateDomain) ? const serviceDomain = ['cover', 'lock'].includes(stateDomain)
stateDomain : 'homeassistant'; ? stateDomain : 'homeassistant';
if (!(serviceDomain in domainsToCall)) domainsToCall[serviceDomain] = []; if (!(serviceDomain in domainsToCall)) domainsToCall[serviceDomain] = [];
domainsToCall[serviceDomain].push(entityId); domainsToCall[serviceDomain].push(entityId);

View File

@ -38,8 +38,8 @@ class HuiEntitiesToggle extends PolymerElement {
} }
_computeToggleEntities(hass, entityIds) { _computeToggleEntities(hass, entityIds) {
return entityIds.filter(entityId => (entityId in hass.states && return entityIds.filter(entityId => (entityId in hass.states
DOMAINS_TOGGLE.has(entityId.split('.', 1)[0]))); && DOMAINS_TOGGLE.has(entityId.split('.', 1)[0])));
} }
_computeIsChecked(hass, entityIds) { _computeIsChecked(hass, entityIds) {

View File

@ -65,15 +65,15 @@ class HuiLockEntityRow extends LocalizeMixin(PolymerElement) {
} }
_computeButtonTitle(state) { _computeButtonTitle(state) {
return state === 'locked' ? return state === 'locked'
this.localize('ui.card.lock.unlock') : this.localize('ui.card.lock.lock'); ? this.localize('ui.card.lock.unlock') : this.localize('ui.card.lock.lock');
} }
_callService(ev) { _callService(ev) {
ev.stopPropagation(); ev.stopPropagation();
const stateObj = this._stateObj; const stateObj = this._stateObj;
this.hass.callService('lock', stateObj.state === 'locked' ? this.hass.callService('lock', stateObj.state === 'locked'
'unlock' : 'lock', { entity_id: stateObj.entity_id }); ? 'unlock' : 'lock', { entity_id: stateObj.entity_id });
} }
} }
customElements.define('hui-lock-entity-row', HuiLockEntityRow); customElements.define('hui-lock-entity-row', HuiLockEntityRow);

View File

@ -37,8 +37,7 @@ class HuiUnusedEntities extends PolymerElement {
const root = this.$.root; const root = this.$.root;
if (root.lastChild) root.removeChild(root.lastChild); if (root.lastChild) root.removeChild(root.lastChild);
const entities = computeUnusedEntities(this.hass, config).map(entity => const entities = computeUnusedEntities(this.hass, config).map(entity => ({ entity, secondary_info: 'entity-id' }));
({ entity, secondary_info: 'entity-id' }));
const cardConfig = { const cardConfig = {
type: 'entities', type: 'entities',
title: 'Unused entities', title: 'Unused entities',

View File

@ -9,8 +9,7 @@ import computeStateName from '../../../common/entity/compute_state_name';
* @appliesMixin EventsMixin * @appliesMixin EventsMixin
* @appliesMixin NavigateMixin * @appliesMixin NavigateMixin
*/ */
export default dedupingMixin(superClass => export default dedupingMixin(superClass => class extends NavigateMixin(EventsMixin(superClass)) {
class extends NavigateMixin(EventsMixin(superClass)) {
handleClick(hass, config) { handleClick(hass, config) {
const tapAction = config.tap_action || 'more-info'; const tapAction = config.tap_action || 'more-info';
if (tapAction === 'none') return; if (tapAction === 'none') return;
@ -39,8 +38,8 @@ export default dedupingMixin(superClass =>
computeTooltip(hass, config) { computeTooltip(hass, config) {
if (config.title) return config.title; if (config.title) return config.title;
const stateName = (config.entity in hass.states) ? const stateName = (config.entity in hass.states)
computeStateName(hass.states[config.entity]) : config.entity; ? computeStateName(hass.states[config.entity]) : config.entity;
let tooltip; let tooltip;
switch (config.tap_action) { switch (config.tap_action) {
@ -59,4 +58,4 @@ export default dedupingMixin(superClass =>
return tooltip; return tooltip;
} }
}); });

View File

@ -60,8 +60,8 @@ class HuiCallServiceRow extends PolymerElement {
} }
setConfig(config) { setConfig(config) {
if (!config || !config.icon || !config.name || !config.action_name || if (!config || !config.icon || !config.name || !config.action_name
!config.service || !config.service_data) { || !config.service || !config.service_data) {
throw new Error('Error in card configuration.'); throw new Error('Error in card configuration.');
} }
this._config = config; this._config = config;

View File

@ -102,11 +102,11 @@ class HaPanelMap extends LocalizeMixin(PolymerElement) {
var entity = hass.states[entityId]; var entity = hass.states[entityId];
var title = computeStateName(entity); var title = computeStateName(entity);
if ((entity.attributes.hidden && if ((entity.attributes.hidden
computeStateDomain(entity) !== 'zone') || && computeStateDomain(entity) !== 'zone')
entity.state === 'home' || || entity.state === 'home'
!('latitude' in entity.attributes) || || !('latitude' in entity.attributes)
!('longitude' in entity.attributes)) { || !('longitude' in entity.attributes)) {
return; return;
} }

View File

@ -156,12 +156,12 @@ class HaMfaModuleSetupFlow extends
this._loading = true; this._loading = true;
this._opened = true; this._opened = true;
const fetchStep = continueFlowId ? const fetchStep = continueFlowId
this.hass.callWS({ ? this.hass.callWS({
type: 'auth/setup_mfa', type: 'auth/setup_mfa',
flow_id: continueFlowId, flow_id: continueFlowId,
}) : })
this.hass.callWS({ : this.hass.callWS({
type: 'auth/setup_mfa', type: 'auth/setup_mfa',
mfa_module_id: mfaModuleId, mfa_module_id: mfaModuleId,
}); });

View File

@ -53,6 +53,7 @@ class HaPickLanguageRow extends
}, },
}; };
} }
static get observers() { return ['setLanguageSelection(language)']; } static get observers() { return ['setLanguageSelection(language)']; }
computeLanguages(hass) { computeLanguages(hass) {

View File

@ -70,8 +70,8 @@ class HaPickThemeRow extends
} }
_compHasThemes(hass) { _compHasThemes(hass) {
return hass.themes && hass.themes.themes && return hass.themes && hass.themes.themes
Object.keys(hass.themes.themes).length; && Object.keys(hass.themes.themes).length;
} }
ready() { ready() {

View File

@ -152,4 +152,3 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
from HTML and may be out of place here. Review them and from HTML and may be out of place here. Review them and
then delete this comment! then delete this comment!
*/ */

View File

@ -15,12 +15,12 @@ export default function loadCustomPanel(panelConfig) {
return Promise.all(toLoad).then(([{ importHrefPromise }]) => return Promise.all(toLoad).then(([{ importHrefPromise }]) =>
importHrefPromise(panelConfig.html_url)); importHrefPromise(panelConfig.html_url));
} else if (panelConfig.js_url) { } if (panelConfig.js_url) {
if (!(panelConfig.js_url in JS_CACHE)) { if (!(panelConfig.js_url in JS_CACHE)) {
JS_CACHE[panelConfig.js_url] = loadJS(panelConfig.js_url); JS_CACHE[panelConfig.js_url] = loadJS(panelConfig.js_url);
} }
return JS_CACHE[panelConfig.js_url]; return JS_CACHE[panelConfig.js_url];
} else if (panelConfig.module_url) { } if (panelConfig.module_url) {
return loadModule(panelConfig.module_url); return loadModule(panelConfig.module_url);
} }
return Promise.reject('No valid url found in panel config.'); return Promise.reject('No valid url found in panel config.');

View File

@ -23,7 +23,7 @@ class HaUrlSync extends EventsMixin(PolymerElement) {
if (DEBUG) console.log('ignore hasschange'); if (DEBUG) console.log('ignore hasschange');
this.ignoreNextHassChange = false; this.ignoreNextHassChange = false;
return; return;
} else if (!oldHass || oldHass.moreInfoEntityId === newHass.moreInfoEntityId) { } if (!oldHass || oldHass.moreInfoEntityId === newHass.moreInfoEntityId) {
return; return;
} }

View File

@ -51,8 +51,7 @@ hassAttributeUtil.TYPE_TO_TAG = {
// 1) Any key of this object won't be shown in more-info window. // 1) Any key of this object won't be shown in more-info window.
// 2) Any key which has value other than undefined will appear in customization // 2) Any key which has value other than undefined will appear in customization
// config according to its value. // config according to its value.
hassAttributeUtil.LOGIC_STATE_ATTRIBUTES = hassAttributeUtil.LOGIC_STATE_ATTRIBUTES = hassAttributeUtil.LOGIC_STATE_ATTRIBUTES || {
hassAttributeUtil.LOGIC_STATE_ATTRIBUTES || {
entity_picture: undefined, entity_picture: undefined,
friendly_name: { type: 'string', description: 'Name' }, friendly_name: { type: 'string', description: 'Name' },
icon: { type: 'icon' }, icon: { type: 'icon' },
@ -88,6 +87,6 @@ hassAttributeUtil.LOGIC_STATE_ATTRIBUTES =
domains: ['automation'] domains: ['automation']
}, },
unit_of_measurement: { type: 'string' }, unit_of_measurement: { type: 'string' },
}; };
export default hassAttributeUtil; export default hassAttributeUtil;

View File

@ -44,17 +44,17 @@ export default class MediaPlayerEntity {
get showProgress() { get showProgress() {
return ( return (
(this.isPlaying || this.isPaused) && (this.isPlaying || this.isPaused)
'media_duration' in this.stateObj.attributes && && 'media_duration' in this.stateObj.attributes
'media_position' in this.stateObj.attributes && && 'media_position' in this.stateObj.attributes
'media_position_updated_at' in this.stateObj.attributes); && 'media_position_updated_at' in this.stateObj.attributes);
} }
get currentProgress() { get currentProgress() {
var progress = this._attr.media_position; var progress = this._attr.media_position;
if (this.isPlaying) { if (this.isPlaying) {
progress += (Date.now() - progress += (Date.now()
new Date(this._attr.media_position_updated_at).getTime()) / 1000.0; - new Date(this._attr.media_position_updated_at).getTime()) / 1000.0;
} }
return progress; return progress;
} }
@ -118,7 +118,7 @@ export default class MediaPlayerEntity {
get secondaryTitle() { get secondaryTitle() {
if (this.isMusic) { if (this.isMusic) {
return this._attr.media_artist; return this._attr.media_artist;
} else if (this.isTVShow) { } if (this.isTVShow) {
var text = this._attr.media_series_title; var text = this._attr.media_series_title;
if (this._attr.media_season) { if (this._attr.media_season) {
@ -130,7 +130,7 @@ export default class MediaPlayerEntity {
} }
return text; return text;
} else if (this._attr.app_name) { } if (this._attr.app_name) {
return this._attr.app_name; return this._attr.app_name;
} }
return ''; return '';

View File

@ -79,8 +79,7 @@ export function getTranslation(fragment, translationInput) {
// Create a promise to fetch translation from the server // Create a promise to fetch translation from the server
if (!translations[translationFingerprint]) { if (!translations[translationFingerprint]) {
translations[translationFingerprint] = translations[translationFingerprint] = fetch(`/static/translations/${translationFingerprint}`, { credentials: 'same-origin' })
fetch(`/static/translations/${translationFingerprint}`, { credentials: 'same-origin' })
.then(response => response.json()).then(data => ({ .then(response => response.json()).then(data => ({
language: translation, language: translation,
data: data, data: data,

View File

@ -1,5 +1,5 @@
const serviceWorkerUrl = __BUILD__ === 'latest' ? const serviceWorkerUrl = __BUILD__ === 'latest'
'/service_worker.js' : '/service_worker_es5.js'; ? '/service_worker.js' : '/service_worker_es5.js';
export default () => { export default () => {
if (!('serviceWorker' in navigator)) return; if (!('serviceWorker' in navigator)) return;
@ -8,9 +8,9 @@ export default () => {
reg.addEventListener('updatefound', () => { reg.addEventListener('updatefound', () => {
const installingWorker = reg.installing; const installingWorker = reg.installing;
installingWorker.addEventListener('statechange', () => { installingWorker.addEventListener('statechange', () => {
if (installingWorker.state === 'installed' && if (installingWorker.state === 'installed'
navigator.serviceWorker.controller && && navigator.serviceWorker.controller
!__DEV__) { && !__DEV__) {
// Notify users here of a new frontend being available. // Notify users here of a new frontend being available.
import('./show-new-frontend-toast.js').then(mod => mod.default(installingWorker)); import('./show-new-frontend-toast.js').then(mod => mod.default(installingWorker));
} }

View File

@ -8,8 +8,7 @@ export default (installingWorker) => {
toast.duration = 0; toast.duration = 0;
const button = document.createElement('paper-button'); const button = document.createElement('paper-button');
button.addEventListener('click', () => button.addEventListener('click', () => installingWorker.postMessage({ type: 'skipWaiting' }));
installingWorker.postMessage({ type: 'skipWaiting' }));
button.style.color = 'var(--primary-color)'; button.style.color = 'var(--primary-color)';
button.style.fontWeight = 'bold'; button.style.fontWeight = 'bold';
button.innerHTML = 'reload'; button.innerHTML = 'reload';

View File

@ -54,7 +54,7 @@ function createConfig(isProdBuild, latestBuild) {
return { return {
mode: isProdBuild ? 'production' : 'development', mode: isProdBuild ? 'production' : 'development',
devtool: isProdBuild ? 'source-map ' : 'inline-source-map', devtool: isProdBuild ? 'cheap-source-map ' : 'inline-cheap-module-source-map',
entry, entry,
module: { module: {
rules: [ rules: [

2429
yarn.lock

File diff suppressed because it is too large Load Diff