- [[stateObj.entityDisplay]]
+ [[computeStateName(stateObj)]]
(Error loading image)
@@ -99,9 +99,7 @@
},
cardTapped: function () {
- this.async(function () {
- this.hass.moreInfoActions.selectEntity(this.stateObj.entityId);
- }.bind(this), 1);
+ this.fire('hass-more-info', { entityId: this.stateObj.entity_id });
},
updateCameraFeedSrc: function (stateObj) {
@@ -117,5 +115,9 @@
imageLoadFail: function () {
this.imageLoaded = false;
},
+
+ computeStateName: function (stateObj) {
+ return window.hassUtil.computeStateName(stateObj);
+ },
});
diff --git a/src/cards/ha-entities-card.html b/src/cards/ha-entities-card.html
index 8f87acb268f1..8d1355fb0d8e 100644
--- a/src/cards/ha-entities-card.html
+++ b/src/cards/ha-entities-card.html
@@ -75,14 +75,16 @@
states: {
type: Array,
},
+
groupEntity: {
type: Object,
},
},
computeTitle: function (states, groupEntity) {
- return groupEntity ? groupEntity.entityDisplay :
- states[0].domain.replace(/_/g, ' ');
+ return groupEntity ?
+ window.hassUtil.computeStateName(groupEntity) :
+ window.hassUtil.computeDomain(states[0]).replace(/_/g, ' ');
},
computeTitleClass: function (groupEntity) {
@@ -105,26 +107,32 @@
ev.stopPropagation();
if (ev.model) {
- entityId = ev.model.item.entityId;
+ entityId = ev.model.item.entity_id;
} else {
- entityId = this.groupEntity.entityId;
+ entityId = this.groupEntity.entity_id;
}
- this.async(function () { this.hass.moreInfoActions.selectEntity(entityId); }.bind(this), 1);
+ this.fire('hass-more-info', { entityId: entityId });
},
showGroupToggle: function (groupEntity, states) {
- var canToggleCount;
-
if (!groupEntity || !states || groupEntity.attributes.control === 'hidden' ||
(groupEntity.state !== 'on' && groupEntity.state !== 'off')) {
return false;
}
// only show if we can toggle 2+ entities in group
- canToggleCount = states.reduce(
- function (sum, state) {
- return sum + window.hassUtil.canToggle(this.hass, state.entityId);
- }, 0);
+ var canToggleCount = 0;
+ for (var i = 0; i < states.length; i++) {
+ if (!window.hassUtil.canToggleState(this.hass, states[i])) {
+ continue;
+ }
+
+ canToggleCount++;
+
+ if (canToggleCount > 1) {
+ break;
+ }
+ }
return canToggleCount > 1;
},
diff --git a/src/cards/ha-media_player-card.html b/src/cards/ha-media_player-card.html
index a23e06f25d13..0b3f972b1aa1 100644
--- a/src/cards/ha-media_player-card.html
+++ b/src/cards/ha-media_player-card.html
@@ -6,6 +6,8 @@
+
+
-
+
-
+
+
+
-
-
+
+
No state history found.
+ data='[[historyData.timeline]]'>
-
+
+ is-single-device='[[_computeIsSingleLineChart(historyData)]]'>
-
+
@@ -56,101 +57,48 @@
is: 'state-history-charts',
properties: {
- stateHistory: {
+ historyData: {
type: Object,
+ value: null,
},
isLoadingData: {
type: Boolean,
- value: false,
+ value: true,
},
- apiLoaded: {
+ _apiLoaded: {
type: Boolean,
value: false,
},
- isLoading: {
+ _isLoading: {
type: Boolean,
- computed: 'computeIsLoading(isLoadingData, apiLoaded)',
- },
-
- groupedStateHistory: {
- type: Object,
- computed: 'computeGroupedStateHistory(isLoading, stateHistory)',
+ computed: '_computeIsLoading(isLoadingData, _apiLoaded)',
},
-
- isSingleDevice: {
- type: Boolean,
- computed: 'computeIsSingleDevice(stateHistory)',
- },
- },
-
- computeIsSingleDevice: function (stateHistory) {
- return stateHistory && stateHistory.size === 1;
},
- computeGroupedStateHistory: function (isLoading, stateHistory) {
- var lineChartDevices = {};
- var timelineDevices = [];
- var unitStates;
-
- if (isLoading || !stateHistory) {
- return { line: [], timeline: [] };
- }
-
- stateHistory.forEach(function (stateInfo) {
- var stateWithUnit;
- var unit;
-
- if (!stateInfo || stateInfo.size === 0) {
- return;
- }
-
- stateWithUnit = stateInfo.find(
- function (state) { return 'unit_of_measurement' in state.attributes; });
-
- unit = stateWithUnit ?
- stateWithUnit.attributes.unit_of_measurement : false;
-
- if (!unit) {
- timelineDevices.push(stateInfo.toArray());
- } else if (unit in lineChartDevices) {
- lineChartDevices[unit].push(stateInfo.toArray());
- } else {
- lineChartDevices[unit] = [stateInfo.toArray()];
- }
- });
-
- timelineDevices = timelineDevices.length > 0 && timelineDevices;
-
- unitStates = Object.keys(lineChartDevices).map(
- function (unit) {
- return { unit: unit, data: lineChartDevices[unit] };
- });
-
- return { line: unitStates, timeline: timelineDevices };
+ _computeIsSingleLineChart: function (historyData) {
+ return historyData && historyData.line.length === 1;
},
- googleApiLoaded: function () {
+ _googleApiLoaded: function () {
window.google.load('visualization', '1', {
packages: ['timeline', 'corechart'],
callback: function () {
- this.apiLoaded = true;
+ this._apiLoaded = true;
}.bind(this),
});
},
- computeContentClasses: function (isLoading) {
- return isLoading ? 'loading' : '';
- },
-
- computeIsLoading: function (isLoadingData, apiLoaded) {
- return isLoadingData || !apiLoaded;
+ _computeIsLoading: function (_isLoadingData, _apiLoaded) {
+ return _isLoadingData || !_apiLoaded;
},
- computeIsEmpty: function (stateHistory) {
- return stateHistory && stateHistory.size === 0;
+ _computeIsEmpty: function (historyData) {
+ return (historyData &&
+ historyData.timeline.length === 0 &&
+ historyData.line.length === 0);
},
});
diff --git a/src/data/ha-state-history-data.html b/src/data/ha-state-history-data.html
new file mode 100644
index 000000000000..8cc770435b23
--- /dev/null
+++ b/src/data/ha-state-history-data.html
@@ -0,0 +1,162 @@
+
+
+
diff --git a/src/dialogs/ha-voice-command-dialog.html b/src/dialogs/ha-voice-command-dialog.html
index ef42bd7537e9..9d096a125360 100644
--- a/src/dialogs/ha-voice-command-dialog.html
+++ b/src/dialogs/ha-voice-command-dialog.html
@@ -5,8 +5,6 @@
-
-
-
+
-
+
+
+
+
Polymer({
is: 'more-info-dialog',
- behaviors: [window.hassBehavior],
-
properties: {
hass: {
type: Object,
@@ -82,48 +88,26 @@
stateObj: {
type: Object,
- bindNuclear: function (hass) {
- return hass.moreInfoGetters.currentEntity;
- },
+ computed: 'computeStateObj(hass)',
observer: 'stateObjChanged',
},
stateHistory: {
type: Object,
- bindNuclear: function (hass) {
- return [
- hass.moreInfoGetters.currentEntityHistory,
- function (history) { return history ? [history] : false; },
- ];
- },
},
- isLoadingHistoryData: {
+ stateHistoryLoading: {
type: Boolean,
- computed: 'computeIsLoadingHistoryData(delayedDialogOpen, isLoadingEntityHistoryData)',
},
- isLoadingEntityHistoryData: {
+ isLoadingHistoryData: {
type: Boolean,
- bindNuclear: function (hass) {
- return hass.entityHistoryGetters.isLoadingEntityHistory;
- },
+ computed: 'computeIsLoadingHistoryData(delayedDialogOpen, stateHistoryLoading)',
},
hasHistoryComponent: {
type: Boolean,
- bindNuclear: function (hass) {
- return hass.configGetters.isComponentLoaded('history');
- },
- observer: 'fetchHistoryData',
- },
-
- shouldFetchHistory: {
- type: Boolean,
- bindNuclear: function (hass) {
- return hass.moreInfoGetters.isCurrentEntityHistoryStale;
- },
- observer: 'fetchHistoryData',
+ computed: 'computeHasHistoryComponent(hass)',
},
showHistoryComponent: {
@@ -142,32 +126,43 @@
type: Boolean,
value: false,
},
+
+ _filterType: {
+ type: String,
+ value: 'recent-entity',
+ },
},
ready: function () {
this.$.scrollable.dialogElement = this.$.dialog;
},
+ computeDomain: function (stateObj) {
+ return stateObj ? window.hassUtil.computeDomain(stateObj) : '';
+ },
+
+ computeStateObj: function (hass) {
+ return hass.states[hass.moreInfoEntityId] || null;
+ },
+
/**
* We depend on a delayed dialogOpen value to tell the chart component
* that the data is there. Otherwise the chart component will render
* before the dialog is attached to the screen and is unable to determine
* graph size resulting in scroll bars.
*/
- computeIsLoadingHistoryData: function (delayedDialogOpen, isLoadingEntityHistoryData) {
- return !delayedDialogOpen || isLoadingEntityHistoryData;
+ computeIsLoadingHistoryData: function (delayedDialogOpen, stateHistoryLoading) {
+ return !delayedDialogOpen || stateHistoryLoading;
},
- computeShowHistoryComponent: function (hasHistoryComponent, stateObj) {
- return this.hasHistoryComponent && stateObj &&
- window.hassUtil.DOMAINS_WITH_NO_HISTORY.indexOf(stateObj.domain) === -1;
+ computeHasHistoryComponent: function (hass) {
+ return window.hassUtil.isComponentLoaded(hass, 'history');
},
- fetchHistoryData: function () {
- if (this.stateObj && this.hasHistoryComponent &&
- this.shouldFetchHistory) {
- this.hass.entityHistoryActions.fetchRecent(this.stateObj.entityId);
- }
+ computeShowHistoryComponent: function (hasHistoryComponent, stateObj) {
+ return this.hasHistoryComponent && stateObj &&
+ window.hassUtil.DOMAINS_WITH_NO_HISTORY.indexOf(
+ window.hassUtil.computeDomain(stateObj)) === -1;
},
stateObjChanged: function (newVal) {
@@ -177,8 +172,6 @@
}
this.async(function () {
- // Firing action while other action is happening confuses nuclear
- this.fetchHistoryData();
// allow dialog to render content before showing it so it is
// positioned correctly.
this.dialogOpen = true;
@@ -189,7 +182,7 @@
if (newVal) {
this.async(function () { this.delayedDialogOpen = true; }.bind(this), 10);
} else if (!newVal && this.stateObj) {
- this.async(function () { this.hass.moreInfoActions.deselectEntity(); }.bind(this), 10);
+ this.fire('hass-more-info', { entityId: null });
this.delayedDialogOpen = false;
}
},
diff --git a/src/home-assistant.html b/src/home-assistant.html
index 47ceb3d78501..a999e2258f46 100644
--- a/src/home-assistant.html
+++ b/src/home-assistant.html
@@ -6,28 +6,47 @@
-
+
+
+
-
-
+
+
+
+
-
+
+ connection-promise='{{connectionPromise}}'
+ show-loading='[[computeShowLoading(connectionPromise, iconsLoaded)]]'>
diff --git a/src/layouts/home-assistant-main.html b/src/layouts/home-assistant-main.html
index a641983e50fb..b5ee7630de9c 100644
--- a/src/layouts/home-assistant-main.html
+++ b/src/layouts/home-assistant-main.html
@@ -5,22 +5,25 @@
-
+
-
-
+
+
@@ -29,21 +32,21 @@
main
attr-for-selected='id'
fallback-selection='panel-resolver'
- selected='[[activePanel]]'
+ selected='[[currentPanel]]'
selected-attribute='panel-visible'
>
@@ -56,56 +59,55 @@
Polymer({
is: 'home-assistant-main',
- behaviors: [window.hassBehavior],
-
properties: {
hass: {
type: Object,
+ value: null,
},
narrow: {
type: Boolean,
- value: true,
},
- activePanel: {
+ currentPanel: {
type: String,
- bindNuclear: function (hass) {
- return hass.navigationGetters.activePanelName;
- },
- observer: 'activePanelChanged',
+ computed: 'computeCurrentPanel(hass)',
+ observer: 'currentPanelChanged',
},
- showSidebar: {
+ dockedSidebar: {
type: Boolean,
- value: false,
- bindNuclear: function (hass) {
- return hass.navigationGetters.showSidebar;
- },
+ computed: 'computeDockedSidebar(hass)',
},
},
listeners: {
- 'open-menu': 'openMenu',
- 'close-menu': 'closeMenu',
+ 'hass-open-menu': 'handleOpenMenu',
+ 'hass-close-menu': 'handleCloseMenu',
+ 'hass-start-voice': 'handleStartVoice',
+ },
+
+ handleStartVoice: function (ev) {
+ ev.stopPropagation();
+ this.$.voiceDialog.startListening();
},
- openMenu: function () {
+ handleOpenMenu: function () {
if (this.narrow) {
this.$.drawer.openDrawer();
} else {
- this.hass.navigationActions.showSidebar(true);
+ this.fire('hass-dock-sidebar', { dock: true });
}
},
- closeMenu: function () {
+ handleCloseMenu: function () {
this.$.drawer.closeDrawer();
- if (this.showSidebar) {
- this.hass.navigationActions.showSidebar(false);
+ if (this.dockedSidebar) {
+ this.fire('hass-dock-sidebar', { dock: false });
}
},
- activePanelChanged: function () {
+ currentPanelChanged: function () {
if (this.narrow) {
this.$.drawer.closeDrawer();
}
@@ -113,15 +115,18 @@
attached: function () {
window.removeInitMsg();
- this.hass.startUrlSync();
},
- computeForceNarrow: function (narrow, showSidebar) {
- return narrow || !showSidebar;
+ computeForceNarrow: function (narrow, dockedSidebar) {
+ return narrow || !dockedSidebar;
+ },
+
+ computeCurrentPanel: function (hass) {
+ return hass.currentPanel;
},
- detached: function () {
- this.hass.stopUrlSync();
+ computeDockedSidebar: function (hass) {
+ return hass.dockedSidebar;
},
});
diff --git a/src/layouts/login-form.html b/src/layouts/login-form.html
index fe3b299fbd62..b6e90191b8b6 100644
--- a/src/layouts/login-form.html
+++ b/src/layouts/login-form.html
@@ -9,8 +9,6 @@
-
-
@@ -51,10 +49,18 @@