diff --git a/src/more-infos/more-info-camera.html b/src/more-infos/more-info-camera.html index b33d0ef760..8648720b88 100644 --- a/src/more-infos/more-info-camera.html +++ b/src/more-infos/more-info-camera.html @@ -12,7 +12,7 @@ } - [[stateObj.entityDisplay]] @@ -29,21 +29,26 @@ Polymer({ stateObj: { type: Object, }, + + isVisible: { + type: Boolean, + value: true, + }, }, imageLoaded: function () { this.fire('iron-resize'); }, - computeCameraImageUrl: function (hass, stateObj) { + computeCameraImageUrl: function (hass, stateObj, isVisible) { if (hass.demo) { return '/demo/webcam.jpg'; - } else if (stateObj) { + } else if (stateObj && isVisible) { return '/api/camera_proxy_stream/' + stateObj.entityId + '?token=' + stateObj.attributes.access_token; } - // Return an empty image if no stateObj (= dialog not open) + // Return an empty image if no stateObj (= dialog not open) or in cleanup mode. return 'data:image/gif;base64,R0lGODlhAQABAAAAACw='; }, }); - \ No newline at end of file + diff --git a/src/more-infos/more-info-content.html b/src/more-infos/more-info-content.html index 6525290df0..793563978c 100644 --- a/src/more-infos/more-info-content.html +++ b/src/more-infos/more-info-content.html @@ -35,11 +35,18 @@ Polymer({ }, stateObjChanged: function (stateObj) { - if (!stateObj) return; - - window.hassUtil.dynamicContentUpdater( - this, 'MORE-INFO-' + window.hassUtil.stateMoreInfoType(stateObj).toUpperCase(), - { hass: this.hass, stateObj: stateObj }); + var rootEl; + if (!stateObj) { + // If root has lastChild, set 'isVisible' attribute of that child to false. + rootEl = Polymer.dom(this); + if (rootEl.lastChild) { + rootEl.lastChild.isVisible = false; + } + } else { + window.hassUtil.dynamicContentUpdater( + this, 'MORE-INFO-' + window.hassUtil.stateMoreInfoType(stateObj).toUpperCase(), + { hass: this.hass, stateObj: stateObj, isVisible: true }); + } }, }); diff --git a/src/util/hass-util.html b/src/util/hass-util.html index bae710051e..3bd524f22a 100644 --- a/src/util/hass-util.html +++ b/src/util/hass-util.html @@ -50,6 +50,8 @@ window.hassUtil.canToggle = function (hass, entityId) { return hass.reactor.evaluate(hass.serviceGetters.canToggleEntity(entityId)); }; +// Update root's child element to be newElementTag replacing another existing child if any. +// Copy attributes into the child element. window.hassUtil.dynamicContentUpdater = function (root, newElementTag, attributes) { var rootEl = Polymer.dom(root); var customEl;