ha-frontend/src/state-summary/state-card-cover.html

86 lines
2.3 KiB
HTML

<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../components/entity/state-info.html">
<dom-module id="state-card-cover">
<template>
<style is="custom-style" include="iron-flex iron-flex-alignment"></style>
<style>
:host {
line-height: 1.5;
}
.state {
text-align: right;
white-space: nowrap;
width: 127px;
}
</style>
<div class='horizontal justified layout'>
<state-info state-obj="[[stateObj]]" in-dialog='[[inDialog]]'></state-info>
<div class='state'>
<paper-icon-button icon="mdi:arrow-up" on-tap='onOpenTap'
disabled='[[computeIsFullyOpen(stateObj)]]'></paper-icon-button>
<paper-icon-button icon="mdi:stop" on-tap='onStopTap'></paper-icon-button>
<paper-icon-button icon="mdi:arrow-down" on-tap='onCloseTap'
disabled='[[computeIsFullyClosed(stateObj)]]'></paper-icon-button>
</div>
</div>
</template>
</dom-module>
<script>
Polymer({
is: 'state-card-cover',
properties: {
hass: {
type: Object,
},
inDialog: {
type: Boolean,
value: false,
},
stateObj: {
type: Object,
},
},
computeIsFullyOpen: function (stateObj) {
if (stateObj.attributes.current_position !== undefined) {
return stateObj.attributes.current_position === 100;
}
return stateObj.state === 'open';
},
computeIsFullyClosed: function (stateObj) {
if (stateObj.attributes.current_position !== undefined) {
return stateObj.attributes.current_position === 0;
}
return stateObj.state === 'closed';
},
onOpenTap: function () {
this.hass.callService('cover', 'open_cover',
{ entity_id: this.stateObj.entity_id });
},
onCloseTap: function () {
this.hass.callService('cover', 'close_cover',
{ entity_id: this.stateObj.entity_id });
},
onStopTap: function () {
this.hass.callService('cover', 'stop_cover',
{ entity_id: this.stateObj.entity_id });
},
});
</script>