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
This commit is contained in:
J. Nick Koston 2020-03-21 13:20:06 -05:00 committed by GitHub
parent 1950656bd5
commit f2578a58b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 4 deletions

View File

@ -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);
}

View File

@ -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";