From f2578a58b4debdfdb256aea9102bbc93b4900af6 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 21 Mar 2020 13:20:06 -0500 Subject: [PATCH] Add "gate" device class for DEVICE_CLASS_GATE (#5299) * Add "gate" device class for DEVICE_CLASS_GATE Gates are found outside of a structure and are typically part of a fence. When opening or closing a garage door, it was impossible to tell if you had hit the button or not even though the underlying state was reported as "opening". This lead to confusion and multiple clicks to open a garage door which can cause the door to stop opening and result in frustration. Add icons for gate and garage opening and closing states. * Add "gate" device class for DEVICE_CLASS_GATE Gates are found outside of a structure and are typically part of a fence. When opening or closing a garage door, it was impossible to tell if you had hit the button or not even though the underlying state was reported as "opening". This lead to confusion and multiple clicks to open a garage door which can cause the door to stop opening and result in frustration. Add icons for gate and garage opening and closing states. * de-bold --- src/common/entity/cover_icon.ts | 47 ++++++++++++++++++++++++++++++-- src/common/entity/domain_icon.ts | 11 +++++++- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/common/entity/cover_icon.ts b/src/common/entity/cover_icon.ts index 13eb5cd9de..faa7e29890 100644 --- a/src/common/entity/cover_icon.ts +++ b/src/common/entity/cover_icon.ts @@ -4,17 +4,58 @@ import { domainIcon } from "./domain_icon"; export const coverIcon = (state: HassEntity): string => { const open = state.state !== "closed"; + switch (state.attributes.device_class) { case "garage": - return open ? "hass:garage-open" : "hass:garage"; + switch (state.state) { + case "opening": + return "hass:arrow-up-box"; + case "closing": + return "hass:arrow-down-box"; + case "closed": + return "hass:garage"; + default: + return "hass:garage-open"; + } + case "gate": + switch (state.state) { + case "opening": + case "closing": + return "hass:gate-arrow-right"; + case "closed": + return "hass:gate"; + default: + return "hass:gate-open"; + } case "door": return open ? "hass:door-open" : "hass:door-closed"; + case "damper": + return open ? "hass:circle" : "hass:circle-slice-8"; case "shutter": return open ? "hass:window-shutter-open" : "hass:window-shutter"; case "blind": - return open ? "hass:blinds-open" : "hass:blinds"; + case "curtain": + switch (state.state) { + case "opening": + return "hass:arrow-up-box"; + case "closing": + return "hass:arrow-down-box"; + case "closed": + return "hass:blinds"; + default: + return "hass:blinds-open"; + } case "window": - return open ? "hass:window-open" : "hass:window-closed"; + switch (state.state) { + case "opening": + return "hass:arrow-up-box"; + case "closing": + return "hass:arrow-down-box"; + case "closed": + return "hass:window-closed"; + default: + return "hass:window-open"; + } default: return domainIcon("cover", state.state); } diff --git a/src/common/entity/domain_icon.ts b/src/common/entity/domain_icon.ts index baa698de4c..e735df808c 100644 --- a/src/common/entity/domain_icon.ts +++ b/src/common/entity/domain_icon.ts @@ -77,7 +77,16 @@ export const domainIcon = (domain: string, state?: string): string => { : "hass:checkbox-marked-circle"; case "cover": - return state === "closed" ? "hass:window-closed" : "hass:window-open"; + switch (state) { + case "opening": + return "hass:arrow-up-box"; + case "closing": + return "hass:arrow-down-box"; + case "closed": + return "hass:window-closed"; + default: + return "hass:window-open"; + } case "lock": return state && state === "unlocked" ? "hass:lock-open" : "hass:lock";