Skip to content

Commit

Permalink
Fix for covers
Browse files Browse the repository at this point in the history
  • Loading branch information
fastcolors committed Nov 9, 2019
1 parent 6f00f72 commit 08d7296
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,6 @@ class BannerCard extends LitElement {
const state = hass.states[config.entity];
const attributes = state.attributes;

const data = {
name: attributes.friendly_name,
state: state.state,
value: getAttributeOrState(state, config.attribute),
unit: attributes.unit_of_measurement,
attributes,
domain: config.entity.split(".")[0]
};

// Will either:
// set .value to be the key from entities.*.map_value.{key} that matches the current `state` if the value is a string
// or set all values as dynamicData if it is an object
Expand All @@ -108,6 +99,34 @@ class BannerCard extends LitElement {
}
}

if (
hass.states[config.entity].attributes.hasOwnProperty("current_position")
) {
const data = {
name: attributes.friendly_name,
state: attributes.current_position,
value: getAttributeOrState(state, config.attribute),
unit: attributes.unit_of_measurement,
attributes,
domain: config.entity.split(".")[0]
};

return {
...data,
...config,
...dynamicData
};
}

const data = {
name: attributes.friendly_name,
state: state.state,
value: getAttributeOrState(state, config.attribute),
unit: attributes.unit_of_measurement,
attributes,
domain: config.entity.split(".")[0]
};

return {
...data,
...config,
Expand Down Expand Up @@ -318,13 +337,14 @@ class BannerCard extends LitElement {
}

renderDomainCover({ onClick, size, name, state, entity }) {
const isclosed = state === "closed";
const isclosed = state === "closed" || state === 0.0;
const isopen = state === "open" || state === 100.0;
return html`
<div class="entity-state" style="${this.grid(size)}">
<span class="entity-name" @click=${onClick}>${name}</span>
<span class="entity-value">
<paper-icon-button
?disabled=${!isclosed}
?disabled=${isopen}
icon="hass:arrow-up"
role="button"
@click=${this._service("cover", "open_cover", entity)}
Expand Down

0 comments on commit 08d7296

Please sign in to comment.