Default more info will show recent states
This commit is contained in:
1 parent
807ceadf8b
commit
e2f51ef557
7 files changed
+126
-59
No files matched your search
@@ -1,2 +1,2 @@
|
||||
""" DO NOT MODIFY. Auto-generated by build_frontend script """
|
||||
VERSION = "83b735c326edc749f0066a79a7eedbd6"
|
||||
VERSION = "212470c7842a8715f81fba76a3bd985f"
|
||||
@@ -72,17 +72,23 @@ b.events&&Object.keys(a).length>0&&console.log("[%s] addHostListeners:",this.loc
|
||||
</div></template></div></template><script>Polymer("events-list",{cbEventClicked:null,events:[],domReady:function(){this.events=this.api.events;this.api.addEventListener("events-updated",this.eventsUpdated.bind(this))},eventsUpdated:function(){this.events=this.api.events},handleClick:function(ev){if(this.cbEventClicked){this.cbEventClicked(ev.path[0].innerHTML)}}});</script></polymer-element><polymer-element name="event-fire-dialog" attributes="api" assetpath="polymer/dialogs/"><template><ha-action-dialog id="dialog" heading="Fire Event" class="two-column" closeselector="[dismissive]"><div layout="" horizontal=""><div class="ha-form"><paper-input id="inputType" label="Event Type" floatinglabel="true" autofocus required></paper-input><paper-input-decorator label="Event Data (JSON, optional)" floatinglabel="true"><textarea id="inputData" rows="5"></textarea></paper-input-decorator></div><div class="sidebar"><b>Available events:</b><events-list api="{{api}}" cbeventclicked="{{eventSelected}}"></events-list></div></div><paper-button dismissive="">Cancel</paper-button><paper-button affirmative="" on-click="{{clickFireEvent}}">Fire Event</paper-button></ha-action-dialog></template><script>Polymer("event-fire-dialog",{ready:function(){this.eventSelected=this.eventSelected.bind(this)},show:function(eventType,eventData){this.setEventType(eventType);this.setEventData(eventData);this.job("showDialogAfterRender",function(){this.$.dialog.toggle()}.bind(this))},setEventType:function(eventType){this.$.inputType.value=eventType},setEventData:function(eventData){this.$.inputData.value=eventData},eventSelected:function(eventType){this.setEventType(eventType)},clickFireEvent:function(){try{this.api.fire_event(this.$.inputType.value,this.$.inputData.value?JSON.parse(this.$.inputData.value):{});this.$.dialog.close()}catch(err){alert("Error parsing JSON: "+err)}}});</script></polymer-element><polymer-element name="core-item" attributes="label icon src" horizontal="" center="" layout="" assetpath="polymer/bower_components/core-item/"><template><style>:host{display:block;position:relative;min-height:40px;white-space:nowrap}:host(.font-scalable){min-height:2.5em}:host(.core-selected){font-weight:700}#icon{margin:0 16px 0 4px}:host(.font-scalable) #icon{margin:0 1em 0 .25em;height:1.5em;width:1.5em}polyfill-next-selector{content:':host > a'}::content>a{position:absolute;top:0;right:0;bottom:0;left:0;background-color:rgba(0,0,0,.000001)}</style><template if="{{icon || src}}"><core-icon src="{{src}}" id="icon" icon="{{icon}}" hidden?="{{!src && !icon}}"></core-icon></template><div id="label">{{label}}</div><content></content></template><script>Polymer("core-item",{});</script></polymer-element><style shim-shadowdom="">html /deep/ core-collapse{display:block}html /deep/ .core-collapse-closed{display:none}</style><polymer-element name="core-collapse" attributes="target horizontal opened duration fixedSize allowOverflow" assetpath="polymer/bower_components/core-collapse/"><template><content></content></template><script>Polymer("core-collapse",{target:null,horizontal:false,opened:false,duration:.33,fixedSize:false,allowOverflow:false,created:function(){this.transitionEndListener=this.transitionEnd.bind(this)},ready:function(){this.target=this.target||this},domReady:function(){this.async(function(){this.afterInitialUpdate=true})},detached:function(){if(this.target){this.removeListeners(this.target)}},targetChanged:function(old){if(old){this.removeListeners(old)}if(!this.target){return}this.isTargetReady=!!this.target;this.classList.toggle("core-collapse-closed",this.target!==this);this.toggleOpenedStyle(false);this.horizontalChanged();this.addListeners(this.target);this.toggleClosedClass(true);this.update()},addListeners:function(node){node.addEventListener("transitionend",this.transitionEndListener)},removeListeners:function(node){node.removeEventListener("transitionend",this.transitionEndListener)},horizontalChanged:function(){this.dimension=this.horizontal?"width":"height"},openedChanged:function(){this.update();this.fire("core-collapse-open",this.opened)},toggle:function(){this.opened=!this.opened},setTransitionDuration:function(duration){var s=this.target.style;s.transition=duration?this.dimension+" "+duration+"s":null;if(duration===0){this.async("transitionEnd")}},transitionEnd:function(){if(this.opened&&!this.fixedSize){this.updateSize("auto",null)}this.setTransitionDuration(null);this.toggleOpenedStyle(this.opened);this.toggleClosedClass(!this.opened);this.asyncFire("core-resize",null,this.target)},toggleClosedClass:function(closed){this.hasClosedClass=closed;this.target.classList.toggle("core-collapse-closed",closed)},toggleOpenedStyle:function(opened){this.target.style.overflow=this.allowOverflow&&opened?"":"hidden"},updateSize:function(size,duration,forceEnd){this.setTransitionDuration(duration);this.calcSize();var s=this.target.style;var nochange=s[this.dimension]===size;s[this.dimension]=size;if(forceEnd&&nochange){thiLine truncated
|
||||
This dialog will update the representation of the device within Home Assistant.<br>
|
||||
This will not communicate with the actual device.
|
||||
</p><div layout="" horizontal=""><div class="ha-form"><paper-input id="inputEntityID" label="Entity ID" floatinglabel="true" autofocus required></paper-input><paper-input id="inputState" label="State" floatinglabel="true" required></paper-input><paper-input-decorator label="State attributes (JSON, optional)" floatinglabel="true"><textarea id="inputData" rows="5"></textarea></paper-input-decorator></div><div class="sidebar"><b>Current entities:</b><entity-list api="{{api}}" cbentityclicked="{{entitySelected}}"></entity-list></div></div><paper-button dismissive="">Cancel</paper-button><paper-button affirmative="" on-click="{{clickSetState}}">Set State</paper-button></ha-action-dialog></template><script>Polymer("state-set-dialog",{ready:function(){this.entitySelected=this.entitySelected.bind(this)},show:function(entityId,state,stateData){this.setEntityId(entityId);this.setState(state);this.setStateData(stateData);this.job("showDialogAfterRender",function(){this.$.dialog.toggle()}.bind(this))},setEntityId:function(entityId){this.$.inputEntityID.value=entityId},setState:function(state){this.$.inputState.value=state},setStateData:function(stateData){var value=stateData?JSON.stringify(stateData,null," "):"";this.$.inputData.value=value},entitySelected:function(entityId){this.setEntityId(entityId);var state=this.api.getState(entityId);this.setState(state.state);this.setStateData(state.attributes)},clickSetState:function(ev){try{this.api.set_state(this.$.inputEntityID.value,this.$.inputState.value,this.$.inputData.value?JSON.parse(this.$.inputData.value):{});this.$.dialog.close()}catch(err){alert("Error parsing JSON: "+err)}}});</script></polymer-element><polymer-element name="more-info-default" attributes="stateObj" assetpath="polymer/more-infos/"><template><style>.data-entry{margin-bottom:8px}.data-entry:last-child{margin-bottom:0}.data{padding-left:10px;text-align:right;word-break:break-all;max-width:200px}</style><div layout="" vertical=""><template repeat="{{key in stateObj.attributes | getKeys}}"><div layout="" justified="" horizontal="" class="data-entry"><div>
|
||||
</p><div layout="" horizontal=""><div class="ha-form"><paper-input id="inputEntityID" label="Entity ID" floatinglabel="true" autofocus required></paper-input><paper-input id="inputState" label="State" floatinglabel="true" required></paper-input><paper-input-decorator label="State attributes (JSON, optional)" floatinglabel="true"><textarea id="inputData" rows="5"></textarea></paper-input-decorator></div><div class="sidebar"><b>Current entities:</b><entity-list api="{{api}}" cbentityclicked="{{entitySelected}}"></entity-list></div></div><paper-button dismissive="">Cancel</paper-button><paper-button affirmative="" on-click="{{clickSetState}}">Set State</paper-button></ha-action-dialog></template><script>Polymer("state-set-dialog",{ready:function(){this.entitySelected=this.entitySelected.bind(this)},show:function(entityId,state,stateData){this.setEntityId(entityId);this.setState(state);this.setStateData(stateData);this.job("showDialogAfterRender",function(){this.$.dialog.toggle()}.bind(this))},setEntityId:function(entityId){this.$.inputEntityID.value=entityId},setState:function(state){this.$.inputState.value=state},setStateData:function(stateData){var value=stateData?JSON.stringify(stateData,null," "):"";this.$.inputData.value=value},entitySelected:function(entityId){this.setEntityId(entityId);var state=this.api.getState(entityId);this.setState(state.state);this.setStateData(state.attributes)},clickSetState:function(ev){try{this.api.set_state(this.$.inputEntityID.value,this.$.inputState.value,this.$.inputData.value?JSON.parse(this.$.inputData.value):{});this.$.dialog.close()}catch(err){alert("Error parsing JSON: "+err)}}});</script></polymer-element><polymer-element name="loading-box" attributes="text" assetpath="polymer/components/"><template><style>.text{display:inline-block;line-height:28px;vertical-align:top;margin-left:8px}</style><div layout="horizontal"><paper-spinner active="true"></paper-spinner><div class="text">{{text}}…</div></div></template><script>Polymer("loading-box",{text:"Loading"});</script></polymer-element><polymer-element name="recent-states" attributes="api stateObj" assetpath="polymer/components/"><template><core-style ref="ha-data-table"></core-style><template if="{{recentStates === null}}"><loading-box text="Loading recent states"></loading-box></template><template if="{{recentStates !== null}}"><div layout="" vertical=""><template repeat="{{recentStates as state}}"><div layout="" justified="" horizontal="" class="data-entry"><div>
|
||||
{{state.state}}
|
||||
</div><div class="data">
|
||||
{{state.last_changed | relativeHATime}}
|
||||
</div></div></template><template if="{{recentStates.length == 0}}">
|
||||
There are no recent states.
|
||||
</template></div></template></template><script>Polymer("recent-states",{recentStates:null,stateObjChanged:function(){this.recentStates=null;this.api.call_api("GET","history/"+this.stateObj.entity_id+"/recent_states",{},this.newStates.bind(this))},newStates:function(states){this.recentStates=states.slice(1)}});</script></polymer-element><polymer-element name="more-info-default" attributes="stateObj api" assetpath="polymer/more-infos/"><template><core-style ref="ha-key-value-table"></core-style><style>.data-entry .value{max-width:200px}</style><div layout="" vertical=""><template repeat="{{key in stateObj.attributes | getKeys}}"><div layout="" justified="" horizontal="" class="data-entry"><div class="key">
|
||||
{{key}}
|
||||
</div><div class="data">
|
||||
</div><div class="value">
|
||||
{{stateObj.attributes[key]}}
|
||||
</div></div></template></div></template><script>Polymer("more-info-default",{getKeys:function(obj){return Object.keys(obj||{})}});</script></polymer-element><polymer-element name="core-range" attributes="value min max step ratio" assetpath="polymer/bower_components/core-range/"><script>Polymer("core-range",{value:0,min:0,max:100,step:1,ratio:0,observe:{"value min max step":"update"},calcRatio:function(value){return(this.clampValue(value)-this.min)/(this.max-this.min)},clampValue:function(value){return Math.min(this.max,Math.max(this.min,this.calcStep(value)))},calcStep:function(value){return this.step?Math.round(value/this.step)/(1/this.step):value},validateValue:function(){var v=this.clampValue(this.value);this.value=this.oldValue=isNaN(v)?this.oldValue:v;return this.value!==v},update:function(){this.validateValue();this.ratio=this.calcRatio(this.value)*100}});</script></polymer-element><polymer-element name="paper-progress" extends="core-range" attributes="secondaryProgress indeterminate" assetpath="polymer/bower_components/paper-progress/"><template><style>:host{display:inline-block;width:200px;height:4px}#progressContainer{position:relative;height:100%;background-color:#c8c8c8;overflow:hidden}#activeProgress,#secondaryProgress{-webkit-transform-origin:left center;transform-origin:left center;-webkit-transform:scaleX(0);transform:scaleX(0)}#activeProgress{background-color:#0f9d58}#secondaryProgress{background-color:#87ceac}#activeProgress.indeterminate{-webkit-transform-origin:center center;transform-origin:center center;-webkit-animation:indeterminate-bar 1s linear infinite;animation:indeterminate-bar 1s linear infinite}@-webkit-keyframes indeterminate-bar{0%{-webkit-transform:translate(-50%) scaleX(0)}50%{-webkit-transform:translate(0%) scaleX(0.3)}100%{-webkit-transform:translate(50%) scaleX(0)}}@keyframes indeterminate-bar{0%{transform:translate(-50%) scaleX(0)}50%{transform:translate(0%) scaleX(0.3)}100%{transform:translate(50%) scaleX(0)}}</style><div id="progressContainer" role="progressbar" aria-valuenow="{{value}}" aria-valuemin="{{min}}" aria-valuemax="{{max}}"><div id="secondaryProgress" fit=""></div><div id="activeProgress" fit=""></div></div></template><script>Polymer("paper-progress",{secondaryProgress:0,indeterminate:false,step:0,observe:{"value secondaryProgress min max indeterminate":"update"},update:function(){this.super();this.secondaryProgress=this.clampValue(this.secondaryProgress);this.secondaryRatio=this.calcRatio(this.secondaryProgress)*100;this.$.activeProgress.classList.toggle("indeterminate",this.indeterminate)},transformProgress:function(progress,ratio){var transform="scaleX("+ratio/100+")";progress.style.transform=progress.style.webkitTransform=transform},ratioChanged:function(){this.transformProgress(this.$.activeProgress,this.ratio)},secondaryRatioChanged:function(){this.transformProgress(this.$.secondaryProgress,this.secondaryRatio)}});</script></polymer-element><polymer-element name="paper-slider" extends="core-range" attributes="snaps pin disabled secondaryProgress editable immediateValue" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100" assetpath="polymer/bower_components/paper-slider/"><template><style>:host{display:inline-block;width:200px;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}:host(:focus){outline:0}#sliderContainer{position:relative;width:calc(100% - 32px);height:32px}#sliderContainer.editable{float:left;width:calc(100% - 72px);margin:12px 0}.bar-container{position:absolute;top:0;left:16px;height:100%;width:100%;overflow:hidden}.ring>.bar-container{left:20px;width:calc(100% - 4px);transition:left .18s ease,width .18s ease}.ring.expand:not(.pin)>.bar-container{left:30px;width:calc(100% - 14px)}.ring.expand.dragging>.bar-container{transition:none}#sliderBar{position:absolute;top:15px;left:0;height:2px;width:100%;padding:8px 0;margin:-8px 0}.ring #sliderBar{left:-4px;width:calc(100% + 4px)}.ring.expand:not(.pin) #sliderBar{left:-14px;width:calc(100% + 14px)}.slider-markers{position:absolute;top:15px;left:15px;height:2px;width:calc(100% + 2px);box-sizing:border-box;pointer-events:none}.slider-markers::after,.slider-marker::after{content:"";display:block;width:2px;height:2px;border-radius:50%;background-color:#000}#sliderBar::shadow #activeProgress{background-color:#3f51b5}.transiting #sliderBar::shadow #activeProgress{transition:-webkit-transform .08s ease;transition:transform .08s ease}#sliderKnob{position:absolute;left:0;top:0;width:32px;height:32px}.transiting>#sliderKnob{transition:left .08s ease}#sliderKnob:focus{outline:0}#sliderKnob.dragging{transition:none}.snaps>#sliderKnob.dragging{transition:-webkit-transform .08s ease;transition:transform .08s ease}#sliderKnobInner{width:12px;height:12px;box-sizing:border-box;-moz-box-sizing:border-box;border-radius:50%;background-color:#3f51b5;transition:height .18s ease,width .18s ease}.expand:not(Line truncated
|
||||
</div></div></template><template if="{{hasHistoryComponent}}"><h4>Recent states</h4><recent-states api="{{api}}" stateobj="{{stateObj}}"></recent-states></template></div></template><script>Polymer("more-info-default",{hasHistoryComponent:false,getKeys:function(obj){return Object.keys(obj||{})},apiChanged:function(oldVal,newVal){this.hasHistoryComponent=this.api&&this.api.hasComponent("history")}});</script></polymer-element><polymer-element name="core-range" attributes="value min max step ratio" assetpath="polymer/bower_components/core-range/"><script>Polymer("core-range",{value:0,min:0,max:100,step:1,ratio:0,observe:{"value min max step":"update"},calcRatio:function(value){return(this.clampValue(value)-this.min)/(this.max-this.min)},clampValue:function(value){return Math.min(this.max,Math.max(this.min,this.calcStep(value)))},calcStep:function(value){return this.step?Math.round(value/this.step)/(1/this.step):value},validateValue:function(){var v=this.clampValue(this.value);this.value=this.oldValue=isNaN(v)?this.oldValue:v;return this.value!==v},update:function(){this.validateValue();this.ratio=this.calcRatio(this.value)*100}});</script></polymer-element><polymer-element name="paper-progress" extends="core-range" attributes="secondaryProgress indeterminate" assetpath="polymer/bower_components/paper-progress/"><template><style>:host{display:inline-block;width:200px;height:4px}#progressContainer{position:relative;height:100%;background-color:#c8c8c8;overflow:hidden}#activeProgress,#secondaryProgress{-webkit-transform-origin:left center;transform-origin:left center;-webkit-transform:scaleX(0);transform:scaleX(0)}#activeProgress{background-color:#0f9d58}#secondaryProgress{background-color:#87ceac}#activeProgress.indeterminate{-webkit-transform-origin:center center;transform-origin:center center;-webkit-animation:indeterminate-bar 1s linear infinite;animation:indeterminate-bar 1s linear infinite}@-webkit-keyframes indeterminate-bar{0%{-webkit-transform:translate(-50%) scaleX(0)}50%{-webkit-transform:translate(0%) scaleX(0.3)}100%{-webkit-transform:translate(50%) scaleX(0)}}@keyframes indeterminate-bar{0%{transform:translate(-50%) scaleX(0)}50%{transform:translate(0%) scaleX(0.3)}100%{transform:translate(50%) scaleX(0)}}</style><div id="progressContainer" role="progressbar" aria-valuenow="{{value}}" aria-valuemin="{{min}}" aria-valuemax="{{max}}"><div id="secondaryProgress" fit=""></div><div id="activeProgress" fit=""></div></div></template><script>Polymer("paper-progress",{secondaryProgress:0,indeterminate:false,step:0,observe:{"value secondaryProgress min max indeterminate":"update"},update:function(){this.super();this.secondaryProgress=this.clampValue(this.secondaryProgress);this.secondaryRatio=this.calcRatio(this.secondaryProgress)*100;this.$.activeProgress.classList.toggle("indeterminate",this.indeterminate)},transformProgress:function(progress,ratio){var transform="scaleX("+ratio/100+")";progress.style.transform=progress.style.webkitTransform=transform},ratioChanged:function(){this.transformProgress(this.$.activeProgress,this.ratio)},secondaryRatioChanged:function(){this.transformProgress(this.$.secondaryProgress,this.secondaryRatio)}});</script></polymer-element><polymer-element name="paper-slider" extends="core-range" attributes="snaps pin disabled secondaryProgress editable immediateValue" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100" assetpath="polymer/bower_components/paper-slider/"><template><style>:host{display:inline-block;width:200px;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}:host(:focus){outline:0}#sliderContainer{position:relative;width:calc(100% - 32px);height:32px}#sliderContainer.editable{float:left;width:calc(100% - 72px);margin:12px 0}.bar-container{position:absolute;top:0;left:16px;height:100%;width:100%;overflow:hidden}.ring>.bar-container{left:20px;width:calc(100% - 4px);transition:left .18s ease,width .18s ease}.ring.expand:not(.pin)>.bar-container{left:30px;width:calc(100% - 14px)}.ring.expand.dragging>.bar-container{transition:none}#sliderBar{position:absolute;top:15px;left:0;height:2px;width:100%;padding:8px 0;margin:-8px 0}.ring #sliderBar{left:-4px;width:calc(100% + 4px)}.ring.expand:not(.pin) #sliderBar{left:-14px;width:calc(100% + 14px)}.slider-markers{position:absolute;top:15px;left:15px;height:2px;width:calc(100% + 2px);box-sizing:border-box;pointer-events:none}.slider-markers::after,.slider-marker::after{content:"";display:block;width:2px;height:2px;border-radius:50%;background-color:#000}#sliderBar::shadow #activeProgress{background-color:#3f51b5}.transiting #sliderBar::shadow #activeProgress{transition:-webkit-transform .08s ease;transition:transform .08s ease}#sliderKnob{position:absolute;left:0;top:0;width:32px;height:32px}.transiting>#sliderKnob{transition:left .08s ease}#sliderKnob:focus{outline:0}#sliderKnob.dragging{transition:none}.snaps>#sliderKLine truncated
|
||||
Rising {{stateObj.attributes.next_rising | relativeHATime}}
|
||||
</div><div class="data">
|
||||
</div><div class="value">
|
||||
{{stateObj.attributes.next_rising | HATimeStripDate}}
|
||||
</div></div><div layout="" justified="" horizontal="" class="data-entry" id="setting"><div>
|
||||
</div></div><div layout="" justified="" horizontal="" class="data-entry" id="setting"><div class="key">
|
||||
Setting {{stateObj.attributes.next_setting | relativeHATime}}
|
||||
</div><div class="data">
|
||||
</div><div class="value">
|
||||
{{stateObj.attributes.next_setting | HATimeStripDate}}
|
||||
</div></div></div></template><script>Polymer("more-info-sun",{stateObjChanged:function(){var rising=ha.util.parseTime(this.stateObj.attributes.next_rising);var setting=ha.util.parseTime(this.stateObj.attributes.next_setting);if(rising>setting){this.$.sunData.appendChild(this.$.rising)}else{this.$.sunData.appendChild(this.$.setting)}}});</script></polymer-element><polymer-element name="more-info-configurator" attributes="stateObj api" assetpath="polymer/more-infos/"><template><style>p{margin:8px 0}p>img{max-width:100%}p.center{text-align:center}p.error{color:#C62828}p.submit{text-align:center;height:41px}p.submit paper-spinner{margin-right:16px}p.submit span{display:inline-block;vertical-align:top;margin-top:6px}</style><div layout="" vertical=""><template if="{{stateObj.state == 'configure'}}"><p hidden?="{{!stateObj.attributes.description}}">
|
||||
{{stateObj.attributes.description}}
|
||||
@@ -90,7 +96,7 @@ b.events&&Object.keys(a).length>0&&console.log("[%s] addHostListeners:",this.loc
|
||||
{{stateObj.attributes.errors}}
|
||||
</p><p class="center" hidden?="{{!stateObj.attributes.description_image}}"><img src="{{stateObj.attributes.description_image}}"></p><p class="submit"><paper-button raised="" on-click="{{submitClicked}}" hidden?="{{action !== 'display'}}">
|
||||
{{stateObj.attributes.submit_caption || "Set configuration"}}
|
||||
</paper-button><span hidden?="{{action !== 'configuring'}}"><paper-spinner active="true"></paper-spinner><span>Configuring…</span></span></p></template></div></template><script>Polymer("more-info-configurator",{action:"display",submitClicked:function(){this.action="configuring";var data={configure_id:this.stateObj.attributes.configure_id};this.api.call_service("configurator","configure",data,{success:function(){this.action="display";this.api.fetchAll()}.bind(this),error:function(){this.action="display"}.bind(this)})}});</script></polymer-element><polymer-element name="more-info-content" attributes="api stateObj" assetpath="polymer/more-infos/"><template><style>:host{display:block}</style><div id="moreInfo" class="{{classNames}}"></div></template><script>Polymer("more-info-content",{classNames:"",observe:{"stateObj.attributes":"stateAttributesChanged"},stateObjChanged:function(){while(this.$.moreInfo.lastChild){this.$.moreInfo.removeChild(this.$.moreInfo.lastChild)}var moreInfo=document.createElement("more-info-"+this.stateObj.moreInfoType);moreInfo.api=this.api;moreInfo.stateObj=this.stateObj;this.$.moreInfo.appendChild(moreInfo)},stateAttributesChanged:function(oldVal,newVal){this.classNames=Object.keys(newVal).map(function(key){return"has-"+key}).join(" ")}});</script></polymer-element><polymer-element name="more-info-dialog" attributes="api" assetpath="polymer/dialogs/"><template><ha-action-dialog id="dialog"><style>.title-card{margin-bottom:24px}</style><div><state-card-content stateobj="{{stateObj}}" api="{{api}}" class="title-card"></state-card-content><more-info-content stateobj="{{stateObj}}" api="{{api}}"></more-info-content></div><paper-button dismissive="" on-click="{{editClicked}}">Debug</paper-button><paper-button affirmative="">Dismiss</paper-button></ha-action-dialog></template><script>Polymer("more-info-dialog",{stateObj:{},observe:{"stateObj.attributes":"reposition"},reposition:function(oldVal,newVal){if(this.$.dialog.opened){this.job("resizeAfterLayoutChange",function(){this.$.dialog.resizeHandler()}.bind(this),1e3)}},show:function(stateObj){this.stateObj=stateObj;this.job("showDialogAfterRender",function(){this.$.dialog.toggle()}.bind(this))},editClicked:function(ev){this.api.showEditStateDialog(this.stateObj.entity_id)}});</script></polymer-element><script>var ha={};ha.util={};ha.util.parseTime=function(timeString){return moment(timeString,"HH:mm:ss DD-MM-YYYY")};ha.util.relativeTime=function(timeString){return ha.util.parseTime(timeString).fromNow()};PolymerExpressions.prototype.relativeHATime=function(timeString){return ha.util.relativeTime(timeString)};PolymerExpressions.prototype.HATimeStripDate=function(timeString){return(timeString||"").split(" ")[0]};</script><polymer-element name="home-assistant-api" attributes="auth" assetpath="polymer/"><template><paper-toast id="toast" role="alert" text=""></paper-toast><event-fire-dialog id="eventDialog" api="{{api}}"></event-fire-dialog><service-call-dialog id="serviceDialog" api="{{api}}"></service-call-dialog><state-set-dialog id="stateSetDialog" api="{{api}}"></state-set-dialog><more-info-dialog id="moreInfoDialog" api="{{api}}"></more-info-dialog></template><script>var domainsWithCard=["thermostat","configurator"];var domainsWithMoreInfo=["light","group","sun","configurator"];State=function(json,api){this.api=api;this.attributes=json.attributes;this.entity_id=json.entity_id;var parts=json.entity_id.split(".");this.domain=parts[0];this.object_id=parts[1];if(this.attributes.friendly_name){this.entityDisplay=this.attributes.friendly_name}else{this.entityDisplay=this.object_id.replace(/_/g," ")}this.state=json.state;this.last_changed=json.last_changed};Object.defineProperties(State.prototype,{stateDisplay:{get:function(){var state=this.state.replace(/_/g," ");if(this.attributes.unit_of_measurement){return state+" "+this.attributes.unit_of_measurement}else{return state}}},isCustomGroup:{get:function(){return this.domain=="group"&&!this.attributes.auto}},canToggle:{get:function(){return this.domain=="group"&&(this.state=="on"||this.state=="off")||this.api.hasService(this.domain,"turn_on")}},cardType:{get:function(){if(domainsWithCard.indexOf(this.domain)!==-1){return this.domain}else if(this.canToggle){return"toggle"}else{return"display"}}},moreInfoType:{get:function(){if(domainsWithMoreInfo.indexOf(this.domain)!==-1){return this.domain}else{return"default"}}},relativeLastChanged:{get:function(){return ha.util.relativeTime(this.last_changed)}}});Polymer("home-assistant-api",{auth:"not-set",states:[],services:[],events:[],stateUpdateTimeout:null,created:function(){this.api=this;this.turn_on=this.turn_on.bind(this);this.turn_off=this.turn_off.bind(this)},removeState:function(entityId){var state=this.getState(entityId);if(state!==null){this.states.splice(this.states.indexOf(state),1)}},getState:function(entityId){var found=this.states.filter(function(state){return state.entity_id==entityId},this);return found.length>0?found[0]:null},geLine truncated
|
||||
</paper-button><span hidden?="{{action !== 'configuring'}}"><paper-spinner active="true"></paper-spinner><span>Configuring…</span></span></p></template></div></template><script>Polymer("more-info-configurator",{action:"display",submitClicked:function(){this.action="configuring";var data={configure_id:this.stateObj.attributes.configure_id};this.api.call_service("configurator","configure",data,{success:function(){this.action="display";this.api.fetchAll()}.bind(this),error:function(){this.action="display"}.bind(this)})}});</script></polymer-element><polymer-element name="more-info-content" attributes="api stateObj" assetpath="polymer/more-infos/"><template><style>:host{display:block}</style><div id="moreInfo" class="{{classNames}}"></div></template><script>Polymer("more-info-content",{classNames:"",observe:{"stateObj.attributes":"stateAttributesChanged"},stateObjChanged:function(){while(this.$.moreInfo.lastChild){this.$.moreInfo.removeChild(this.$.moreInfo.lastChild)}var moreInfo=document.createElement("more-info-"+this.stateObj.moreInfoType);moreInfo.api=this.api;moreInfo.stateObj=this.stateObj;this.$.moreInfo.appendChild(moreInfo)},stateAttributesChanged:function(oldVal,newVal){this.classNames=Object.keys(newVal).map(function(key){return"has-"+key}).join(" ")}});</script></polymer-element><polymer-element name="more-info-dialog" attributes="api" assetpath="polymer/dialogs/"><template><ha-action-dialog id="dialog"><style>.title-card{margin-bottom:24px}</style><div><state-card-content stateobj="{{stateObj}}" api="{{api}}" class="title-card"></state-card-content><more-info-content stateobj="{{stateObj}}" api="{{api}}"></more-info-content></div><paper-button dismissive="" on-click="{{editClicked}}">Debug</paper-button><paper-button affirmative="">Dismiss</paper-button></ha-action-dialog></template><script>Polymer("more-info-dialog",{stateObj:{},observe:{"stateObj.attributes":"reposition"},reposition:function(oldVal,newVal){if(this.$.dialog.opened){this.job("resizeAfterLayoutChange",function(){this.$.dialog.resizeHandler()}.bind(this),1e3)}},show:function(stateObj){this.stateObj=stateObj;this.job("showDialogAfterRender",function(){this.$.dialog.toggle()}.bind(this))},editClicked:function(ev){this.api.showEditStateDialog(this.stateObj.entity_id)}});</script></polymer-element><script>var ha={};ha.util={};ha.util.parseTime=function(timeString){return moment(timeString,"HH:mm:ss DD-MM-YYYY")};ha.util.relativeTime=function(timeString){return ha.util.parseTime(timeString).fromNow()};PolymerExpressions.prototype.relativeHATime=function(timeString){return ha.util.relativeTime(timeString)};PolymerExpressions.prototype.HATimeStripDate=function(timeString){return(timeString||"").split(" ")[0]};</script><polymer-element name="home-assistant-api" attributes="auth" assetpath="polymer/"><template><paper-toast id="toast" role="alert" text=""></paper-toast><event-fire-dialog id="eventDialog" api="{{api}}"></event-fire-dialog><service-call-dialog id="serviceDialog" api="{{api}}"></service-call-dialog><state-set-dialog id="stateSetDialog" api="{{api}}"></state-set-dialog><more-info-dialog id="moreInfoDialog" api="{{api}}"></more-info-dialog></template><script>var domainsWithCard=["thermostat","configurator"];var domainsWithMoreInfo=["light","group","sun","configurator"];State=function(json,api){this.api=api;this.attributes=json.attributes;this.entity_id=json.entity_id;var parts=json.entity_id.split(".");this.domain=parts[0];this.object_id=parts[1];if(this.attributes.friendly_name){this.entityDisplay=this.attributes.friendly_name}else{this.entityDisplay=this.object_id.replace(/_/g," ")}this.state=json.state;this.last_changed=json.last_changed};Object.defineProperties(State.prototype,{stateDisplay:{get:function(){var state=this.state.replace(/_/g," ");if(this.attributes.unit_of_measurement){return state+" "+this.attributes.unit_of_measurement}else{return state}}},isCustomGroup:{get:function(){return this.domain=="group"&&!this.attributes.auto}},canToggle:{get:function(){return this.domain=="group"&&(this.state=="on"||this.state=="off")||this.api.hasService(this.domain,"turn_on")}},cardType:{get:function(){if(domainsWithCard.indexOf(this.domain)!==-1){return this.domain}else if(this.canToggle){return"toggle"}else{return"display"}}},moreInfoType:{get:function(){if(domainsWithMoreInfo.indexOf(this.domain)!==-1){return this.domain}else{return"default"}}},relativeLastChanged:{get:function(){return ha.util.relativeTime(this.last_changed)}}});Polymer("home-assistant-api",{auth:"not-set",states:[],services:[],events:[],stateUpdateTimeout:null,created:function(){this.api=this;this.turn_on=this.turn_on.bind(this);this.turn_off=this.turn_off.bind(this)},removeState:function(entityId){var state=this.getState(entityId);if(state!==null){this.states.splice(this.states.indexOf(state),1)}},getState:function(entityId){var found=this.states.filter(function(state){return state.entity_id==entityId},this);return found.length>0?found[0]:null},geLine truncated
|
||||
<div hidden><polymer-element name="home-assistant-style" assetpath="polymer/resources/"><template><core-style id="ha-dialog">
|
||||
:host {
|
||||
font-family: RobotoDraft, 'Helvetica Neue', Helvetica, Arial;
|
||||
@@ -143,6 +149,23 @@ b.events&&Object.keys(a).length>0&&console.log("[%s] addHostListeners:",this.loc
|
||||
html /deep/ .ha-form paper-input:first-child {
|
||||
padding-top: 0;
|
||||
}
|
||||
</core-style><core-style id="ha-key-value-table">
|
||||
.data-entry {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.data-entry:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.data-entry .key {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.data-entry .value {
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
}
|
||||
</core-style></template><script>Polymer("home-assistant-style");</script></polymer-element></div>
|
||||
|
||||
<polymer-element name="splash-login" attributes="auth" assetpath="polymer/"><template><style>:host{font-family:RobotoDraft,'Helvetica Neue',Helvetica,Arial}paper-input{display:block}.login paper-button{margin-left:242px}.login .interact{height:125px}#validatebox{text-align:center}#validatemessage{margin-top:10px}</style><home-assistant-style></home-assistant-style><home-assistant-api auth="{{auth}}" id="api"></home-assistant-api><div layout="" horizontal="" center="" fit="" class="login" id="splash"><div layout="" vertical="" center="" flex=""><img src="/static/favicon-192x192.png"><h1>Home Assistant</h1><a href="polymer/#" id="hideKeyboardOnFocus"></a><div class="interact" layout="" vertical=""><div id="loginform"><paper-input-decorator label="Password" id="passwordDecorator"><input is="core-input" type="password" id="passwordInput" value="{{auth}}" on-keyup="{{passwordKeyup}}" autofocus></paper-input-decorator><paper-button on-click="{{validatePassword}}">Log In</paper-button></div><div id="validatebox" hidden><paper-spinner active="true"></paper-spinner><br><div id="validatemessage">Validating password...</div></div></div></div></div><home-assistant-main api="{{api}}" hidden id="main"></home-assistant-main></template><script>Polymer("splash-login",{state:"no_auth",auth:"",ready:function(){this.api=this.$.api},domReady:function(){document.getElementById("init").remove();if(this.auth){this.validatePassword()}},authChanged:function(oldVal,newVal){if(newVal===""&&this.state==="valid_auth"){this.state="no_auth"}},stateChanged:function(oldVal,newVal){if(newVal==="no_auth"){this.$.loginform.removeAttribute("hidden");this.$.validatebox.setAttribute("hidden",null);this.$.validatemessage.innerHTML="Validating password...";this.$.splash.removeAttribute("hidden");this.$.main.setAttribute("hidden",null)}else{this.$.splash.setAttribute("hidden",null);this.$.main.removeAttribute("hidden")}},passwordKeyup:function(ev){if(ev.keyCode===13){this.validatePassword()}else if(this.$.passwordDecorator.isInvalid){this.$.passwordDecorator.isInvalid=false}},validatePassword:function(){this.$.loginform.setAttribute("hidden",null);this.$.validatebox.removeAttribute("hidden");this.$.hideKeyboardOnFocus.focus();var passwordValid=function(result){this.$.validatemessage.innerHTML="Loading data...";this.api.fetchEvents();this.api.fetchStates(function(){this.state="valid_auth"}.bind(this))};var passwordInvalid=function(result){if(result&&result.message){this.$.passwordDecorator.error=result.message}else{this.$.passwordDecorator.error="Unexpected result from API"}this.auth=null;this.$.passwordDecorator.isInvalid=true;this.$.loginform.removeAttribute("hidden");this.$.validatebox.setAttribute("hidden",null);this.$.passwordInput.focus()};this.api.fetchServices(passwordValid.bind(this),passwordInvalid.bind(this))}});</script></polymer-element>
|
||||
<polymer-element name="splash-login" attributes="auth" assetpath="polymer/"><template><style>:host{font-family:RobotoDraft,'Helvetica Neue',Helvetica,Arial}paper-input{display:block}.login paper-button{margin-left:242px}.login .interact{height:125px}#validatebox{text-align:center}#validatemessage{margin-top:10px}</style><home-assistant-style></home-assistant-style><home-assistant-api auth="{{auth}}" id="api"></home-assistant-api><div layout="" horizontal="" center="" fit="" class="login" id="splash"><div layout="" vertical="" center="" flex=""><img src="/static/favicon-192x192.png"><h1>Home Assistant</h1><a href="polymer/#" id="hideKeyboardOnFocus"></a><div class="interact" layout="" vertical=""><div id="loginform"><paper-input-decorator label="Password" id="passwordDecorator"><input is="core-input" type="password" id="passwordInput" value="{{auth}}" on-keyup="{{passwordKeyup}}" autofocus></paper-input-decorator><paper-button on-click="{{validatePassword}}">Log In</paper-button></div><div id="validatebox" hidden><paper-spinner active="true"></paper-spinner><br><div id="validatemessage">Validating password...</div></div></div></div></div><home-assistant-main api="{{api}}" hidden id="main"></home-assistant-main></template><script>Polymer("splash-login",{state:"no_auth",auth:"",ready:function(){this.api=this.$.api},domReady:function(){document.getElementById("init").remove();if(this.auth){this.validatePassword()}},authChanged:function(oldVal,newVal){if(newVal===""&&this.state==="valid_auth"){this.state="no_auth"}},stateChanged:function(oldVal,newVal){if(newVal==="no_auth"){this.$.loginform.removeAttribute("hidden");this.$.validatebox.setAttribute("hidden",null);this.$.validatemessage.innerHTML="Validating password...";this.$.splash.removeAttribute("hidden");this.$.main.setAttribute("hidden",null)}else{this.$.splash.setAttribute("hidden",null);this.$.main.removeAttribute("hidden")}},passwordKeyup:function(ev){if(ev.keyCode===13){this.validatePassword()}else if(this.$.passwordDecorator.isInvalid){this.$.passwordDecorator.isInvalid=false}},validatePassword:function(){this.$.loginform.setAttribute("hidden",null);this.$.validatebox.removeAttribute("hidden");this.$.hideKeyboardOnFocus.focus();var passwordValid=function(result){this.$.validatemessage.innerHTML="Loading data…";this.api.fetchEvents();this.api.fetchComponents();this.api.fetchStates(function(){this.state="valid_auth"}.bind(this))};var passwordInvalid=function(result){if(result&&result.message){this.$.passwordDecorator.error=result.message}else{this.$.passwordDecorator.error="Unexpected result from API"}this.auth=null;this.$.passwordDecorator.isInvalid=true;this.$.loginform.removeAttribute("hidden");this.$.validatebox.setAttribute("hidden",null);this.$.passwordInput.focus()};this.api.fetchServices(passwordValid.bind(this),passwordInvalid.bind(this))}});</script></polymer-element>
|
||||
@@ -0,0 +1,25 @@
|
||||
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../bower_components/paper-spinner/paper-spinner.html">
|
||||
|
||||
<polymer-element name="loading-box" attributes="text">
|
||||
<template>
|
||||
<style>
|
||||
.text {
|
||||
display: inline-block;
|
||||
line-height: 28px;
|
||||
vertical-align: top;
|
||||
margin-left: 8px;
|
||||
}
|
||||
</style>
|
||||
<div layout='horizontal'>
|
||||
<paper-spinner active="true"></paper-spinner>
|
||||
<div class='text'>{{text}}…</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
Polymer({
|
||||
text: "Loading"
|
||||
});
|
||||
</script>
|
||||
</polymer-element>
|
||||
+27
-10
@@ -1,29 +1,46 @@
|
||||
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../bower_components/core-style/core-style.html">
|
||||
<link rel="import" href="./loading-box.html">
|
||||
|
||||
<polymer-element name="recent-states" attributes="api stateObj">
|
||||
<template>
|
||||
<style>
|
||||
<core-style ref='ha-data-table'></core-style>
|
||||
|
||||
</style>
|
||||
|
||||
<h3>State history</h3>
|
||||
|
||||
<template repeat="{{recentStates as state}}">
|
||||
<p>{{state.state}} - {{state.last_changed | relativeHATime}}</p>
|
||||
<template if="{{recentStates === null}}">
|
||||
<loading-box text="Loading recent states"></loading-box>
|
||||
</template>
|
||||
|
||||
<template if="{{recentStates !== null}}">
|
||||
<div layout vertical>
|
||||
<template repeat="{{recentStates as state}}">
|
||||
<div layout justified horizontal class='data-entry'>
|
||||
<div>
|
||||
{{state.state}}
|
||||
</div>
|
||||
<div class='data'>
|
||||
{{state.last_changed | relativeHATime}}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template if="{{recentStates.length == 0}}">
|
||||
There are no recent states.
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
<script>
|
||||
Polymer({
|
||||
recentStates: [],
|
||||
recentStates: null,
|
||||
|
||||
stateObjChanged: function() {
|
||||
this.recentStates = [];
|
||||
this.recentStates = null;
|
||||
|
||||
this.api.call_api('GET', 'component/recorder/' + this.stateObj.entity_id + '/last_5_states', {}, this.newStates.bind(this));
|
||||
this.api.call_api('GET', 'history/' + this.stateObj.entity_id + '/recent_states', {}, this.newStates.bind(this));
|
||||
},
|
||||
|
||||
newStates: function(states) {
|
||||
// cut off the first one (which is the current)
|
||||
this.recentStates = states.slice(1);
|
||||
}
|
||||
});
|
||||
|
||||
+16
-17
@@ -1,22 +1,13 @@
|
||||
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../bower_components/core-style/core-style.html">
|
||||
|
||||
<link rel="import" href="../components/recent-states.html">
|
||||
|
||||
<polymer-element name="more-info-default" attributes="stateObj">
|
||||
<polymer-element name="more-info-default" attributes="stateObj api">
|
||||
<template>
|
||||
<core-style ref='ha-key-value-table'></core-style>
|
||||
<style>
|
||||
.data-entry {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.data-entry:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.data {
|
||||
padding-left: 10px;
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
.data-entry .value {
|
||||
max-width: 200px;
|
||||
}
|
||||
</style>
|
||||
@@ -25,24 +16,32 @@
|
||||
|
||||
<template repeat="{{key in stateObj.attributes | getKeys}}">
|
||||
<div layout justified horizontal class='data-entry'>
|
||||
<div>
|
||||
<div class='key'>
|
||||
{{key}}
|
||||
</div>
|
||||
<div class='data'>
|
||||
<div class='value'>
|
||||
{{stateObj.attributes[key]}}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<recent-states api="{{api}}" stateObj="{{stateObj}}"></recent-states>
|
||||
|
||||
<template if="{{hasHistoryComponent}}">
|
||||
<h4>Recent states</h4>
|
||||
<recent-states api="{{api}}" stateObj="{{stateObj}}"></recent-states>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
Polymer({
|
||||
hasHistoryComponent: false,
|
||||
|
||||
getKeys: function(obj) {
|
||||
return Object.keys(obj || {});
|
||||
},
|
||||
|
||||
apiChanged: function(oldVal, newVal) {
|
||||
this.hasHistoryComponent = this.api && this.api.hasComponent('history');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</polymer-element>
|
||||
@@ -1,42 +1,26 @@
|
||||
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../bower_components/core-style/core-style.html">
|
||||
|
||||
<polymer-element name="more-info-sun" attributes="stateObj api">
|
||||
<template>
|
||||
<style>
|
||||
.data-entry {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.data-entry:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.data {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.time-ago {
|
||||
color: darkgrey;
|
||||
margin-top: -2px;
|
||||
}
|
||||
</style>
|
||||
<core-style ref='ha-key-value-table'></core-style>
|
||||
|
||||
<div layout vertical id='sunData'>
|
||||
|
||||
<div layout justified horizontal class='data-entry' id='rising'>
|
||||
<div>
|
||||
<div class='key'>
|
||||
Rising {{stateObj.attributes.next_rising | relativeHATime}}
|
||||
</div>
|
||||
<div class='data'>
|
||||
<div class='value'>
|
||||
{{stateObj.attributes.next_rising | HATimeStripDate}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div layout justified horizontal class='data-entry' id='setting'>
|
||||
<div>
|
||||
<div class='key'>
|
||||
Setting {{stateObj.attributes.next_setting | relativeHATime}}
|
||||
</div>
|
||||
<div class='data'>
|
||||
<div class='value'>
|
||||
{{stateObj.attributes.next_setting | HATimeStripDate}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+20
-1
@@ -55,6 +55,25 @@
|
||||
html /deep/ .ha-form paper-input:first-child {
|
||||
padding-top: 0;
|
||||
}
|
||||
</core-style>
|
||||
</core-style>
|
||||
|
||||
<core-style id='ha-key-value-table'>
|
||||
.data-entry {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.data-entry:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.data-entry .key {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.data-entry .value {
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
}
|
||||
</core-style>
|
||||
</template>
|
||||
</polymer-element>
|
||||
Reference in new issue
Block a user