Skip to content

Commit

Permalink
Designate 0.2.1 release; Add config attribute state_confidence
Browse files Browse the repository at this point in the history
  • Loading branch information
berrywhite96 committed Oct 2, 2022
1 parent 6ced623 commit 6170fee
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ preset_buttons:
| `name` | `string` | Optional | Overwrites friendly name from entity |
| `invert_position` | `boolean` | false | Inverts position value (0% => 100%, 30% => 70%), forces also `invert_position_label` to `true` |
| `invert_position_label` | `boolean` | false | Inverts position label (if `false` => 0% = closed, 100% = open; if `true` => 0% = open, 100% = closed) |
| `state_confidence` | `boolean` | true | Trust full state support (if `false` ignore state and e.g. always enables move buttons ) |
| `state_color` | `boolean` | false | Enables icon coloring if entity is active |
| `move_down_button` | [`action`](https://www.home-assistant.io/dashboards/actions/) | Optional | Custom action for the move down button (overwrites default functions) |
| `move_stop_button` | [`action`](https://www.home-assistant.io/dashboards/actions/) | Optional | Custom action for the move stop button (overwrites default functions) |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@berrywhite/lovelace-shutter-row",
"private": true,
"version": "0.2.0",
"version": "0.2.1",
"description": "Home Assistant Lovelace Shutter Row Card",
"main": "shutter-row.js",
"module": "shutter-row.js",
Expand Down
24 changes: 14 additions & 10 deletions shutter-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ styleInject(css_248z);

let HASSIO_CARD_ID = "shutter-row";
let HASSIO_CARD_NAME = "Shutter row";
let VERSION = "0.2.0";
let VERSION = "0.2.1";


class ShutterRow extends s {
Expand Down Expand Up @@ -283,6 +283,7 @@ class ShutterRow extends s {
name: getConfigAttribute("name", false),
invert_position: getConfigAttribute("invert_position", false),
invert_position_label: getConfigAttribute("invert_position_label", false) || getConfigAttribute("invert_position", false),
state_confidence: getConfigAttribute("state_confidence", true),
state_color: getConfigAttribute("state_color", false),
move_down_button: {
tap_action: getConfigAttribute("tap_action", false, getConfigAttribute("move_down_button", false)),
Expand Down Expand Up @@ -392,9 +393,9 @@ class ShutterRow extends s {
<span class="entity-name" @click="${this.moreInfo}">${this.getName()}</span>
<div class="controls" state="${this.stateDisplay}">
<ha-icon icon="mdi:chevron-up" class="${this.upReached() || this.stateDisplay == "opening" ? "disabled" : ''}" @dblclick="${this.onMoveUpDoubleClick}" @pointerdown="${onHoldPointerDown}" @pointerup="${this.onMoveUpPointerUp}"></ha-icon>
<ha-icon icon="mdi:stop" class="${(this.stateDisplay == "open" || this.stateDisplay == "closed") ? "disabled" : ''}" @dblclick="${this.onMoveStopDoubleClick}" @pointerdown="${onHoldPointerDown}" @pointerup="${this.onMoveStopPointerUp}"></ha-icon>
<ha-icon icon="mdi:chevron-down" class="${this.downReached() || this.stateDisplay == "closing" ? "disabled" : ''}" @dblclick="${this.onMoveDownDoubleClick}" @pointerdown="${onHoldPointerDown}" @pointerup="${this.onMoveDownPointerUp}"></ha-icon>
<ha-icon icon="mdi:chevron-up" class="${this.config.state_confidence && (this.upReached() || this.stateDisplay == "opening") ? "disabled" : ''}" @dblclick="${this.onMoveUpDoubleClick}" @pointerdown="${onHoldPointerDown}" @pointerup="${this.onMoveUpPointerUp}"></ha-icon>
<ha-icon icon="mdi:stop" class="${this.config.state_confidence && (this.stateDisplay == "open" || this.stateDisplay == "closed") ? "disabled" : ''}" @dblclick="${this.onMoveStopDoubleClick}" @pointerdown="${onHoldPointerDown}" @pointerup="${this.onMoveStopPointerUp}"></ha-icon>
<ha-icon icon="mdi:chevron-down" class="${this.config.state_confidence && (this.downReached() || this.stateDisplay == "closing") ? "disabled" : ''}" @dblclick="${this.onMoveDownDoubleClick}" @pointerdown="${onHoldPointerDown}" @pointerup="${this.onMoveDownPointerUp}"></ha-icon>
</div>
</div>
`;
Expand Down Expand Up @@ -483,8 +484,9 @@ class ShutterRow extends s {
return;
}
// Run default action
if(this.stateDisplay == "opening" || this._getElements().controls.hasAttribute("up-reached"))
return;
if(this.config.state_confidence)
if(this.upReached())
return;
this.hass.callService("cover", "open_cover", {
entity_id: this.entityId,
});
Expand All @@ -506,8 +508,9 @@ class ShutterRow extends s {
return;
}
// Run default action
if(this.stateDisplay == "open" || this.stateDisplay == "closed")
return;
if(this.config.state_confidence)
if(this.stateDisplay == "open" || this.stateDisplay == "closed")
return;
this.hass.callService("cover", "stop_cover", {
entity_id: this.entityId,
});
Expand All @@ -529,8 +532,9 @@ class ShutterRow extends s {
return;
}
// Run default action
if(this.stateDisplay == "closing" || this._getElements().controls.hasAttribute("down-reached"))
return;
if(this.config.state_confidence)
if(this.downReached())
return;
this.hass.callService("cover", "close_cover", {
entity_id: this.entityId,
});
Expand Down
26 changes: 15 additions & 11 deletions src/shutter-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import style from "./style.css";

let HASSIO_CARD_ID = "shutter-row";
let HASSIO_CARD_NAME = "Shutter row";
let VERSION = "0.2.0"
let VERSION = "0.2.1";


class ShutterRow extends LitElement {
Expand Down Expand Up @@ -51,6 +51,7 @@ class ShutterRow extends LitElement {
name: getConfigAttribute("name", false),
invert_position: getConfigAttribute("invert_position", false),
invert_position_label: getConfigAttribute("invert_position_label", false) || getConfigAttribute("invert_position", false),
state_confidence: getConfigAttribute("state_confidence", true),
state_color: getConfigAttribute("state_color", false),
move_down_button: {
tap_action: getConfigAttribute("tap_action", false, getConfigAttribute("move_down_button", false)),
Expand Down Expand Up @@ -160,9 +161,9 @@ class ShutterRow extends LitElement {
<span class="entity-name" @click="${this.moreInfo}">${this.getName()}</span>
<div class="controls" state="${this.stateDisplay}">
<ha-icon icon="mdi:chevron-up" class="${this.upReached() || this.stateDisplay == "opening" ? "disabled" : ''}" @dblclick="${this.onMoveUpDoubleClick}" @pointerdown="${onHoldPointerDown}" @pointerup="${this.onMoveUpPointerUp}"></ha-icon>
<ha-icon icon="mdi:stop" class="${(this.stateDisplay == "open" || this.stateDisplay == "closed") ? "disabled" : ''}" @dblclick="${this.onMoveStopDoubleClick}" @pointerdown="${onHoldPointerDown}" @pointerup="${this.onMoveStopPointerUp}"></ha-icon>
<ha-icon icon="mdi:chevron-down" class="${this.downReached() || this.stateDisplay == "closing" ? "disabled" : ''}" @dblclick="${this.onMoveDownDoubleClick}" @pointerdown="${onHoldPointerDown}" @pointerup="${this.onMoveDownPointerUp}"></ha-icon>
<ha-icon icon="mdi:chevron-up" class="${this.config.state_confidence && (this.upReached() || this.stateDisplay == "opening") ? "disabled" : ''}" @dblclick="${this.onMoveUpDoubleClick}" @pointerdown="${onHoldPointerDown}" @pointerup="${this.onMoveUpPointerUp}"></ha-icon>
<ha-icon icon="mdi:stop" class="${this.config.state_confidence && (this.stateDisplay == "open" || this.stateDisplay == "closed") ? "disabled" : ''}" @dblclick="${this.onMoveStopDoubleClick}" @pointerdown="${onHoldPointerDown}" @pointerup="${this.onMoveStopPointerUp}"></ha-icon>
<ha-icon icon="mdi:chevron-down" class="${this.config.state_confidence && (this.downReached() || this.stateDisplay == "closing") ? "disabled" : ''}" @dblclick="${this.onMoveDownDoubleClick}" @pointerdown="${onHoldPointerDown}" @pointerup="${this.onMoveDownPointerUp}"></ha-icon>
</div>
</div>
`;
Expand Down Expand Up @@ -251,8 +252,9 @@ class ShutterRow extends LitElement {
return;
}
// Run default action
if(this.stateDisplay == "opening" || this._getElements().controls.hasAttribute("up-reached"))
return;
if(this.config.state_confidence)
if(this.upReached())
return;
this.hass.callService("cover", "open_cover", {
entity_id: this.entityId,
});
Expand All @@ -274,8 +276,9 @@ class ShutterRow extends LitElement {
return;
}
// Run default action
if(this.stateDisplay == "open" || this.stateDisplay == "closed")
return;
if(this.config.state_confidence)
if(this.stateDisplay == "open" || this.stateDisplay == "closed")
return;
this.hass.callService("cover", "stop_cover", {
entity_id: this.entityId,
});
Expand All @@ -297,8 +300,9 @@ class ShutterRow extends LitElement {
return;
}
// Run default action
if(this.stateDisplay == "closing" || this._getElements().controls.hasAttribute("down-reached"))
return;
if(this.config.state_confidence)
if(this.downReached())
return;
this.hass.callService("cover", "close_cover", {
entity_id: this.entityId,
});
Expand Down Expand Up @@ -337,4 +341,4 @@ class ShutterRow extends LitElement {
}

customElements.define(HASSIO_CARD_ID, ShutterRow);
console.info("%c" + HASSIO_CARD_NAME.toLocaleUpperCase() + " " + VERSION, "color: #ffa500");
console.info("%c" + HASSIO_CARD_NAME.toLocaleUpperCase() + " " + VERSION, "color: #ffa500");

0 comments on commit 6170fee

Please sign in to comment.