From 37098f805d5a3416580ae22d7466bedf726072aa Mon Sep 17 00:00:00 2001 From: cribbstechnologies Date: Sat, 17 Jun 2017 21:09:45 -0400 Subject: [PATCH] Control modification for cover (#298) * modifying cover to optionally have up/down and tilt controls in regular state card * missed these * linting * making only one set of controls show up with preference to up/down * DRYing things up * appeasing Travis * DRYer still * reusing utility functions * appeasing the build master --- src/components/ha-cover-tilt-controls.html | 74 ++++++++++++++++++++++ src/more-infos/more-info-cover.html | 32 ++-------- src/state-summary/state-card-cover.html | 18 +++++- src/util/cover-model.html | 6 ++ 4 files changed, 101 insertions(+), 29 deletions(-) create mode 100644 src/components/ha-cover-tilt-controls.html mode change 100755 => 100644 src/more-infos/more-info-cover.html diff --git a/src/components/ha-cover-tilt-controls.html b/src/components/ha-cover-tilt-controls.html new file mode 100644 index 0000000000..22781f90a2 --- /dev/null +++ b/src/components/ha-cover-tilt-controls.html @@ -0,0 +1,74 @@ + + + + + + + + + + + + + diff --git a/src/more-infos/more-info-cover.html b/src/more-infos/more-info-cover.html old mode 100755 new mode 100644 index c4a3eff2ae..5f8ac86777 --- a/src/more-infos/more-info-cover.html +++ b/src/more-infos/more-info-cover.html @@ -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 { @@ -42,17 +39,10 @@
Tilt position
- - - +
+ + +
diff --git a/src/state-summary/state-card-cover.html b/src/state-summary/state-card-cover.html index 07f691acf5..552496d471 100644 --- a/src/state-summary/state-card-cover.html +++ b/src/state-summary/state-card-cover.html @@ -5,6 +5,7 @@ + @@ -39,6 +43,18 @@ Polymer({ stateObj: { type: Object, }, + + entityObj: { + type: Object, + computed: 'computeEntityObj(hass, stateObj)', + }, + }, + + computeEntityObj: function (hass, stateObj) { + var entity = new window.CoverEntity(hass, stateObj); + return entity; + }, + }); diff --git a/src/util/cover-model.html b/src/util/cover-model.html index 7c039c9403..4880fc03cf 100644 --- a/src/util/cover-model.html +++ b/src/util/cover-model.html @@ -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, {