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",
"rules": {
"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) {
if (a.slug === 'local') {
return -1;
} else if (b.slug === 'local') {
} if (b.slug === 'local') {
return 1;
} else if (a.slug === 'core') {
} if (a.slug === 'core') {
return -1;
} else if (b.slug === 'core') {
} if (b.slug === 'core') {
return 1;
}
return a.name < b.name ? -1 : 1;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -58,8 +58,7 @@ class HaCardChooser extends PolymerElement {
if (!newData) return;
// 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).
const eligibleToObserver =
(window.IntersectionObserver && newData.cardType !== 'entities');
const eligibleToObserver = (window.IntersectionObserver && newData.cardType !== 'entities');
if (!eligibleToObserver) {
if (this.observer) {
this.observer.unobserve(this);

View File

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

View File

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

View File

@ -219,7 +219,7 @@ class HaMediaPlayerCard extends LocalizeMixin(EventsMixin(PolymerElement)) {
if (picture !== oldPicture && !picture) {
this.$.cover.style.backgroundImage = '';
return;
} else if (picture === oldPicture) {
} if (picture === oldPicture) {
return;
}
@ -275,7 +275,7 @@ class HaMediaPlayerCard extends LocalizeMixin(EventsMixin(PolymerElement)) {
computePlaybackControlIcon(playerObj) {
if (playerObj.isPlaying) {
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) {
return 'hass:play-pause';
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,8 +9,7 @@ export default function computeStateDisplay(localize, stateObj, language) {
if (domain === 'binary_sensor') {
// Try device class translation, then default binary sensor translation
if (stateObj.attributes.device_class) {
stateObj._stateDisplay =
localize(`state.${domain}.${stateObj.attributes.device_class}.${stateObj.state}`);
stateObj._stateDisplay = localize(`state.${domain}.${stateObj.attributes.device_class}.${stateObj.state}`);
}
if (!stateObj._stateDisplay) {
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) {
if (stateObj._entityDisplay === undefined) {
stateObj._entityDisplay = (
stateObj.attributes.friendly_name ||
computeObjectId(stateObj.entity_id).replace(/_/g, ' '));
stateObj.attributes.friendly_name
|| computeObjectId(stateObj.entity_id).replace(/_/g, ' '));
}
return stateObj._entityDisplay;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -133,15 +133,15 @@ class HaStateLabelBadge extends
case 'alarm_control_panel':
if (state.state === 'pending') {
return 'hass:clock-fast';
} else if (state.state === 'armed_away') {
} if (state.state === 'armed_away') {
return 'hass:nature';
} else if (state.state === 'armed_home') {
} if (state.state === 'armed_home') {
return 'hass:home-variant';
} else if (state.state === 'armed_night') {
} if (state.state === 'armed_night') {
return 'hass:weather-night';
} else if (state.state === 'armed_custom_bypass') {
} if (state.state === 'armed_custom_bypass') {
return 'hass:security-home';
} else if (state.state === 'triggered') {
} if (state.state === 'triggered') {
return 'hass:alert-circle';
}
// state == 'disarmed'
@ -151,8 +151,8 @@ class HaStateLabelBadge extends
case 'updater':
return stateIcon(state);
case 'sun':
return state.state === 'above_horizon' ?
domainIcon(domain) : 'hass:brightness-3';
return state.state === 'above_horizon'
? domainIcon(domain) : 'hass:brightness-3';
case 'timer':
return state.state === 'active' ? 'hass:timer' : 'hass:timer-off';
default:
@ -166,8 +166,8 @@ class HaStateLabelBadge extends
computeLabel(localize, state, _timerTimeRemaining) {
const domain = computeStateDomain(state);
if (state.state === 'unavailable' ||
['device_tracker', 'alarm_control_panel'].includes(domain)) {
if (state.state === 'unavailable'
|| ['device_tracker', 'alarm_control_panel'].includes(domain)) {
// 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
// are only added for device_tracker and alarm_control_panel.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -73,8 +73,8 @@ class HaMarkdown extends EventsMixin(PolymerElement) {
const node = walker.currentNode;
// Open external links in a new window
if (node.tagName === 'A' &&
node.host !== document.location.host) {
if (node.tagName === 'A'
&& node.host !== document.location.host) {
node.target = '_blank';
// 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';
export const pushSupported = (
'serviceWorker' in navigator && 'PushManager' in window &&
(document.location.protocol === 'https:' ||
document.location.hostname === 'localhost' ||
document.location.hostname === '127.0.0.1'));
'serviceWorker' in navigator && 'PushManager' in window
&& (document.location.protocol === 'https:'
|| document.location.hostname === 'localhost'
|| document.location.hostname === '127.0.0.1'));
/*
* @appliesMixin EventsMixin

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -63,9 +63,9 @@ class MoreInfoCamera extends EventsMixin(PolymerElement) {
computeCameraImageUrl(hass, stateObj, isVisible) {
if (hass.demo) {
return '/demo/webcam.jpg';
} else if (stateObj && isVisible) {
return '/api/camera_proxy_stream/' + stateObj.entity_id +
'?token=' + stateObj.attributes.access_token;
} if (stateObj && isVisible) {
return '/api/camera_proxy_stream/' + stateObj.entity_id
+ '?token=' + stateObj.attributes.access_token;
}
// Return an empty image if no stateObj (= dialog not open) or in cleanup mode.
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)
this.operationIndex = -1;
if (this.stateObj.attributes.operation_list) {
this.operationIndex =
this.stateObj.attributes.operation_list.indexOf(this.stateObj.attributes.operation_mode);
this.operationIndex = (
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)
this.swingIndex = -1;
if (this.stateObj.attributes.swing_list) {
this.swingIndex =
this.stateObj.attributes.swing_list.indexOf(this.stateObj.attributes.swing_mode);
this.swingIndex = (
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)
this.fanIndex = -1;
if (this.stateObj.attributes.fan_list) {
this.fanIndex =
this.stateObj.attributes.fan_list.indexOf(this.stateObj.attributes.fan_mode);
this.fanIndex = (
this.stateObj.attributes.fan_list.indexOf(this.stateObj.attributes.fan_mode)
);
}
}
computeTemperatureStepSize(hass, stateObj) {
if (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 0.5;
}
supportsTemperatureControls(stateObj) {
return this.supportsTemperature(stateObj) ||
this.supportsTemperatureRange(stateObj);
return this.supportsTemperature(stateObj)
|| this.supportsTemperatureRange(stateObj);
}
supportsTemperature(stateObj) {

View File

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

View File

@ -194,7 +194,7 @@ class MoreInfoMediaPlayer extends LocalizeMixin(EventsMixin(PolymerElement)) {
computePlaybackControlIcon(playerObj) {
if (playerObj.isPlaying) {
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) {
return 'hass:play-pause';
}

View File

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

View File

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

View File

@ -18,8 +18,7 @@ import '../layouts/app/home-assistant.js';
/* polyfill for paper-dropdown */
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
);

View File

@ -8,5 +8,4 @@ import '../resources/roboto.js';
import '../auth/ha-authorize.js';
/* polyfill for paper-dropdown */
setTimeout(() =>
import(/* webpackChunkName: "polyfill-web-animations-next" */ 'web-animations-js/web-animations-next-lite.min.js'), 2000);
setTimeout(() => 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 isExternal = location.search.includes('external_auth=1');
const authProm = isExternal ?
() => import('../common/auth/external_auth.js')
.then(mod => new mod.default(hassUrl)) :
() => getAuth({
const authProm = isExternal
? () => import('../common/auth/external_auth.js')
.then(mod => new mod.default(hassUrl))
: () => getAuth({
hassUrl,
saveTokens,
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';
const webComponentsSupported = (
'customElements' in window &&
'import' in document.createElement('link') &&
'content' in document.createElement('template'));
'customElements' in window
&& 'import' in document.createElement('link')
&& 'content' in document.createElement('template'));
let es5Loaded = null;

View File

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

View File

@ -18,132 +18,130 @@ import hassCallApi from '../../util/hass-call-api.js';
import computeStateName from '../../common/entity/compute_state_name.js';
import { subscribePanels } from '../../data/ws-panels';
export default superClass =>
class extends EventsMixin(LocalizeMixin(superClass)) {
ready() {
super.ready();
this._handleConnProm();
export default superClass => class extends EventsMixin(LocalizeMixin(superClass)) {
ready() {
super.ready();
this._handleConnProm();
}
async _handleConnProm() {
let auth;
let conn;
try {
const result = await window.hassConnection;
auth = result.auth;
conn = result.conn;
} catch (err) {
this._error = true;
return;
}
async _handleConnProm() {
let auth;
let conn;
try {
const result = await window.hassConnection;
auth = result.auth;
conn = result.conn;
} catch (err) {
this._error = true;
return;
}
this.hass = Object.assign({
auth,
connection: conn,
connected: true,
states: null,
config: null,
themes: null,
panels: null,
panelUrl: this.panelUrl,
this.hass = Object.assign({
auth,
connection: conn,
connected: true,
states: null,
config: null,
themes: null,
panels: null,
panelUrl: this.panelUrl,
language: getActiveTranslation(),
// If resources are already loaded, don't discard them
resources: (this.hass && this.hass.resources) || null,
language: getActiveTranslation(),
// If resources are already loaded, don't discard them
resources: (this.hass && this.hass.resources) || null,
translationMetadata: translationMetadata,
dockedSidebar: false,
moreInfoEntityId: null,
callService: async (domain, service, serviceData = {}) => {
try {
await callService(conn, domain, service, serviceData);
translationMetadata: translationMetadata,
dockedSidebar: false,
moreInfoEntityId: null,
callService: async (domain, service, serviceData = {}) => {
try {
await callService(conn, domain, service, serviceData);
let message;
let name;
if (serviceData.entity_id && this.hass.states &&
this.hass.states[serviceData.entity_id]) {
name = computeStateName(this.hass.states[serviceData.entity_id]);
}
if (service === 'turn_on' && serviceData.entity_id) {
message = this.localize(
'ui.notification_toast.entity_turned_on',
'entity', name || serviceData.entity_id
);
} else if (service === 'turn_off' && serviceData.entity_id) {
message = this.localize(
'ui.notification_toast.entity_turned_off',
'entity', name || serviceData.entity_id
);
} else {
message = this.localize(
'ui.notification_toast.service_called',
'service', `${domain}/${service}`
);
}
this.fire('hass-notification', { message });
} catch (err) {
const message = this.localize(
'ui.notification_toast.service_call_failed',
let message;
let name;
if (serviceData.entity_id && this.hass.states
&& this.hass.states[serviceData.entity_id]) {
name = computeStateName(this.hass.states[serviceData.entity_id]);
}
if (service === 'turn_on' && serviceData.entity_id) {
message = this.localize(
'ui.notification_toast.entity_turned_on',
'entity', name || serviceData.entity_id
);
} else if (service === 'turn_off' && serviceData.entity_id) {
message = this.localize(
'ui.notification_toast.entity_turned_off',
'entity', name || serviceData.entity_id
);
} else {
message = this.localize(
'ui.notification_toast.service_called',
'service', `${domain}/${service}`
);
this.fire('hass-notification', { message });
throw err;
}
},
callApi: async (method, path, parameters) =>
hassCallApi(auth, method, path, parameters),
fetchWithAuth: (path, init) => fetchWithAuth(auth, `${auth.data.hassUrl}${path}`, init),
// For messages that do not get a response
sendWS: (msg) => {
// eslint-disable-next-line
if (__DEV__) console.log('Sending', msg);
conn.sendMessage(msg);
},
// For messages that expect a response
callWS: (msg) => {
/* eslint-disable no-console */
this.fire('hass-notification', { message });
} catch (err) {
const message = this.localize(
'ui.notification_toast.service_call_failed',
'service', `${domain}/${service}`
);
this.fire('hass-notification', { message });
throw err;
}
},
callApi: async (method, path, parameters) => hassCallApi(auth, method, path, parameters),
fetchWithAuth: (path, init) => fetchWithAuth(auth, `${auth.data.hassUrl}${path}`, init),
// For messages that do not get a response
sendWS: (msg) => {
// eslint-disable-next-line
if (__DEV__) console.log('Sending', msg);
conn.sendMessage(msg);
},
// For messages that expect a response
callWS: (msg) => {
/* eslint-disable no-console */
if (__DEV__) console.log('Sending', msg);
const resp = conn.sendMessagePromise(msg);
const resp = conn.sendMessagePromise(msg);
if (__DEV__) {
resp.then(
result => console.log('Received', result),
err => console.log('Error', err),
);
}
return resp;
},
}, getState());
if (__DEV__) {
resp.then(
result => console.log('Received', result),
err => console.log('Error', err),
);
}
return resp;
},
}, getState());
this.hassConnected();
}
this.hassConnected();
}
hassConnected() {
super.hassConnected();
hassConnected() {
super.hassConnected();
const conn = this.hass.connection;
const conn = this.hass.connection;
conn.addEventListener('ready', () => this.hassReconnected());
conn.addEventListener('disconnected', () => this.hassDisconnected());
// If we reconnect after losing connection and auth is no longer valid.
conn.addEventListener('reconnect-error', (_conn, err) => {
if (err === ERR_INVALID_AUTH) location.reload();
});
conn.addEventListener('ready', () => this.hassReconnected());
conn.addEventListener('disconnected', () => this.hassDisconnected());
// If we reconnect after losing connection and auth is no longer valid.
conn.addEventListener('reconnect-error', (_conn, err) => {
if (err === ERR_INVALID_AUTH) location.reload();
});
subscribeEntities(conn, states => this._updateHass({ states }));
subscribeConfig(conn, config => this._updateHass({ config }));
subscribeServices(conn, services => this._updateHass({ services }));
subscribePanels(conn, panels => this._updateHass({ panels }));
}
subscribeEntities(conn, states => this._updateHass({ states }));
subscribeConfig(conn, config => this._updateHass({ config }));
subscribeServices(conn, services => this._updateHass({ services }));
subscribePanels(conn, panels => this._updateHass({ panels }));
}
hassReconnected() {
super.hassReconnected();
this._updateHass({ connected: true });
}
hassReconnected() {
super.hassReconnected();
this._updateHass({ connected: true });
}
hassDisconnected() {
super.hassDisconnected();
this._updateHass({ connected: false });
}
};
hassDisconnected() {
super.hassDisconnected();
this._updateHass({ connected: false });
}
};

View File

@ -1,23 +1,22 @@
export default superClass =>
class extends superClass {
ready() {
super.ready();
this.addEventListener('register-dialog', e => this.registerDialog(e.detail));
}
export default superClass => class extends superClass {
ready() {
super.ready();
this.addEventListener('register-dialog', e => this.registerDialog(e.detail));
}
registerDialog({ dialogShowEvent, dialogTag, dialogImport }) {
let loaded = null;
registerDialog({ dialogShowEvent, dialogTag, dialogImport }) {
let loaded = null;
this.addEventListener(dialogShowEvent, (showEv) => {
if (!loaded) {
loaded = dialogImport().then(() => {
const dialogEl = document.createElement(dialogTag);
this.shadowRoot.appendChild(dialogEl);
this.provideHass(dialogEl);
return dialogEl;
});
}
loaded.then(dialogEl => dialogEl.showDialog(showEv.detail));
});
}
};
this.addEventListener(dialogShowEvent, (showEv) => {
if (!loaded) {
loaded = dialogImport().then(() => {
const dialogEl = document.createElement(dialogTag);
this.shadowRoot.appendChild(dialogEl);
this.provideHass(dialogEl);
return dialogEl;
});
}
loaded.then(dialogEl => dialogEl.showDialog(showEv.detail));
});
}
};

View File

@ -1,27 +1,26 @@
import LocalizeMixin from '../../mixins/localize-mixin.js';
export default superClass =>
class extends LocalizeMixin(superClass) {
hassConnected() {
super.hassConnected();
export default superClass => class extends LocalizeMixin(superClass) {
hassConnected() {
super.hassConnected();
// Need to load in advance because when disconnected, can't dynamically load code.
import(/* webpackChunkName: "ha-toast" */ '../../components/ha-toast.js');
}
}
hassReconnected() {
super.hassReconnected();
this.__discToast.opened = false;
}
hassReconnected() {
super.hassReconnected();
this.__discToast.opened = false;
}
hassDisconnected() {
super.hassDisconnected();
if (!this.__discToast) {
const el = document.createElement('ha-toast');
el.duration = 0;
el.text = this.localize('ui.notification_toast.connection_lost');
this.__discToast = el;
this.shadowRoot.appendChild(el);
}
this.__discToast.opened = true;
hassDisconnected() {
super.hassDisconnected();
if (!this.__discToast) {
const el = document.createElement('ha-toast');
el.duration = 0;
el.text = this.localize('ui.notification_toast.connection_lost');
this.__discToast = el;
this.shadowRoot.appendChild(el);
}
};
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
hassConnected() {}
hassReconnected() {}
hassDisconnected() {}
panelUrlChanged(newPanelUrl) {}
hassChanged(hass, oldHass) {
this.__provideHass.forEach((el) => {
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 { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
import '../../layouts/home-assistant-main.js';
import '../../layouts/ha-init-page.js';
import '../home-assistant-main.js';
import '../ha-init-page.js';
import '../../resources/ha-style.js';
import registerServiceWorker from '../../util/register-service-worker.js';

View File

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

View File

@ -1,11 +1,10 @@
export default superClass =>
class extends superClass {
ready() {
super.ready();
this.registerDialog({
dialogShowEvent: 'hass-notification',
dialogTag: 'notification-manager',
dialogImport: () => import(/* webpackChunkName: "notification-manager" */ '../../managers/notification-manager.js'),
});
}
};
export default superClass => class extends superClass {
ready() {
super.ready();
this.registerDialog({
dialogShowEvent: 'hass-notification',
dialogTag: 'notification-manager',
dialogImport: () => import(/* webpackChunkName: "notification-manager" */ '../../managers/notification-manager.js'),
});
}
};

View File

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

View File

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

View File

@ -32,10 +32,10 @@ export default dedupingMixin(superClass =>
}
if (!this.translationFragment) {
// In dev mode, we will issue a warning if after a second we are still
// not configured correctly.
// In dev mode, we will issue a warning if after a second we are still
// not configured correctly.
if (__DEV__) {
// eslint-disable-next-line
// eslint-disable-next-line
setTimeout(() => !this.resources && console.error(
'Forgot to pass in resources or set translationFragment for',
this.nodeName

View File

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

View File

@ -231,9 +231,9 @@ class HaAutomationEditor extends
}
backTapped() {
if (this.dirty &&
if (this.dirty
// 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;
}
history.back();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -227,9 +227,9 @@ class HaScriptEditor extends
}
backTapped() {
if (this.dirty &&
if (this.dirty
// 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;
}
history.back();
@ -251,8 +251,8 @@ class HaScriptEditor extends
}
saveScript() {
var id = this.creatingNew ?
'' + Date.now() : computeObjectId(this.script.entity_id);
var id = this.creatingNew
? '' + Date.now() : computeObjectId(this.script.entity_id);
this.hass.callApi('post', 'config/script/config/' + id, this.config).then(() => {
this.dirty = false;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

Some files were not shown because too many files have changed in this diff Show More