- [[stateObj.entityDisplay]]
+ [[computeStateName(stateObj)]]
(Error loading image)
@@ -99,9 +99,7 @@ Polymer({
},
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 @@ Polymer({
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 8f87acb268..8d1355fb0d 100644
--- a/src/cards/ha-entities-card.html
+++ b/src/cards/ha-entities-card.html
@@ -75,14 +75,16 @@ Polymer({
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 @@ Polymer({
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 a23e06f25d..0b3f972b1a 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 @@ Polymer({
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)',
- },
-
- isSingleDevice: {
- type: Boolean,
- computed: 'computeIsSingleDevice(stateHistory)',
+ computed: '_computeIsLoading(isLoadingData, _apiLoaded)',
},
},
- computeIsSingleDevice: function (stateHistory) {
- return stateHistory && stateHistory.size === 1;
+ _computeIsSingleLineChart: function (historyData) {
+ return historyData && historyData.line.length === 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 };
- },
-
- 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 0000000000..8cc770435b
--- /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 ef42bd7537..9d096a1253 100644
--- a/src/dialogs/ha-voice-command-dialog.html
+++ b/src/dialogs/ha-voice-command-dialog.html
@@ -5,8 +5,6 @@
-
-
-
+
-
+
+
+
+
-
+
+
+
-
-
+
+
+
+
-
+
+ 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 a641983e50..b5ee7630de 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',
},
- openMenu: function () {
+ handleStartVoice: function (ev) {
+ ev.stopPropagation();
+ this.$.voiceDialog.startListening();
+ },
+
+ 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 @@ Polymer({
attached: function () {
window.removeInitMsg();
- this.hass.startUrlSync();
},
- computeForceNarrow: function (narrow, showSidebar) {
- return narrow || !showSidebar;
+ computeForceNarrow: function (narrow, dockedSidebar) {
+ return narrow || !dockedSidebar;
},
- detached: function () {
- this.hass.stopUrlSync();
+ computeCurrentPanel: function (hass) {
+ return hass.currentPanel;
+ },
+
+ computeDockedSidebar: function (hass) {
+ return hass.dockedSidebar;
},
});
diff --git a/src/layouts/login-form.html b/src/layouts/login-form.html
index fe3b299fbd..b6e90191b8 100644
--- a/src/layouts/login-form.html
+++ b/src/layouts/login-form.html
@@ -9,8 +9,6 @@
-
-
@@ -51,10 +49,18 @@