Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions src/components/ha-cover-tilt-controls.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<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='../../bower_components/paper-slider/paper-slider.html'>

<link rel='import' href='../util/cover-model.html'>

<dom-module id='ha-cover-tilt-controls'>
<template>
<style is="custom-style" include="iron-flex"></style>
<style>
:host {
white-space: nowrap;
}

[invisible] {
visibility: hidden !important;
}
</style>
<paper-icon-button icon="mdi:arrow-top-right"
on-tap='onOpenTiltTap' title='Open tilt'
invisible$='[[!entityObj.supportsOpenTilt]]'
disabled='[[entityObj.isFullyOpenTilt]]'></paper-icon-button>
<paper-icon-button icon="mdi:stop" on-tap='onStopTiltTap'
invisible$='[[!entityObj.supportsStopTilt]]'
title='Stop tilt'></paper-icon-button>
<paper-icon-button icon="mdi:arrow-bottom-left"
on-tap='onCloseTiltTap' title='Close tilt'
invisible$='[[!entityObj.supportsCloseTilt]]'
disabled='[[entityObj.isFullyClosedTilt]]'></paper-icon-button>
</template>
</dom-module>

<script>
Polymer({
is: 'ha-cover-tilt-controls',

properties: {
hass: {
type: Object,
},

stateObj: {
type: Object,
},

entityObj: {
type: Object,
computed: 'computeEntityObj(hass, stateObj)',
},
},

computeEntityObj: function (hass, stateObj) {
var entity = new window.CoverEntity(hass, stateObj);
return entity;
},

onOpenTiltTap: function (ev) {
ev.stopPropagation();
this.entityObj.openCoverTilt();
},

onCloseTiltTap: function (ev) {
ev.stopPropagation();
this.entityObj.closeCoverTilt();
},

onStopTiltTap: function (ev) {
ev.stopPropagation();
this.entityObj.stopCoverTilt();
},
});
</script>
32 changes: 4 additions & 28 deletions src/more-infos/more-info-cover.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
overflow: hidden;
}
.has-current_position .current_position,
.has-open_tilt .tilt,
.has-close_tilt .tilt,
.has-stop_tilt .tilt,
.has-set_tilt_position .tilt,
.has-current_tilt_position .tilt
{
Expand All @@ -42,17 +39,10 @@

<div class='tilt'>
<div>Tilt position</div>
<paper-icon-button icon="mdi:arrow-top-right"
on-tap='onOpenTiltTap' title='Open tilt'
invisible$='[[!entityObj.supportsOpenTilt]]'
disabled='[[entityObj.isFullyOpenTilt]]'></paper-icon-button>
<paper-icon-button icon="mdi:stop" on-tap='onStopTiltTap'
invisible$='[[!entityObj.supportsStopTilt]]'
title='Stop tilt'></paper-icon-button>
<paper-icon-button icon="mdi:arrow-bottom-left"
on-tap='onCloseTiltTap' title='Close tilt'
invisible$='[[!entityObj.supportsCloseTilt]]'
disabled='[[entityObj.isFullyClosedTilt]]'></paper-icon-button>
<div>
<ha-cover-tilt-controls hidden$="[[entityObj.isTiltOnly]]" hass="[[hass]]" state-obj="[[stateObj]]">
</ha-cover-tilt-controls>
</div>
<paper-slider
min='0' max='100'
value='{{coverTiltPositionSliderValue}}'
Expand Down Expand Up @@ -104,9 +94,6 @@
},

featureClassNames: {
16: 'has-open_tilt',
32: 'has-close_tilt',
64: 'has-stop_tilt',
128: 'has-set_tilt_position',
},

Expand All @@ -126,16 +113,5 @@
this.entityObj.setCoverTiltPosition(ev.target.value);
},

onOpenTiltTap: function () {
this.entityObj.openCoverTilt();
},

onCloseTiltTap: function () {
this.entityObj.closeCoverTilt();
},

onStopTiltTap: function () {
this.entityObj.stopCoverTilt();
},
});
</script>
18 changes: 17 additions & 1 deletion src/state-summary/state-card-cover.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<link rel="import" href="../components/entity/state-info.html">

<link rel="import" href="../components/ha-cover-controls.html">
<link rel="import" href="../components/ha-cover-tilt-controls.html">

<dom-module id="state-card-cover">
<template>
Expand All @@ -17,7 +18,10 @@

<div class='horizontal justified layout'>
<state-info state-obj="[[stateObj]]" in-dialog='[[inDialog]]'></state-info>
<ha-cover-controls hass="[[hass]]" state-obj="[[stateObj]]"></ha-cover-controls>
<div class='horizontal layout'>
<ha-cover-controls hidden$="[[entityObj.isTiltOnly]]" hass="[[hass]]" state-obj="[[stateObj]]"></ha-cover-controls>
<ha-cover-tilt-controls hidden$="[[!entityObj.isTiltOnly]]" hass="[[hass]]" state-obj="[[stateObj]]"></ha-cover-tilt-controls>
</div>
</div>
</template>
</dom-module>
Expand All @@ -39,6 +43,18 @@
stateObj: {
type: Object,
},

entityObj: {
type: Object,
computed: 'computeEntityObj(hass, stateObj)',
},

},

computeEntityObj: function (hass, stateObj) {
var entity = new window.CoverEntity(hass, stateObj);
return entity;
},

});
</script>
6 changes: 6 additions & 0 deletions src/util/cover-model.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
return (this.stateObj.attributes.supported_features & 128) !== 0;
});

addGetter('isTiltOnly', function () {
var supportsCover = this.supportsOpen || this.supportsClose || this.supportsStop;
var supportsTilt = this.supportsOpenTilt || this.supportsCloseTilt || this.supportsStopTilt;
return supportsTilt && !supportsCover;
});

/* eslint-enable no-bitwise */

Object.assign(window.CoverEntity.prototype, {
Expand Down