Add additional binary device classes to inversion list (#10152)

This commit is contained in:
Philip Allgaier 2021-10-16 14:49:57 +02:00 committed by GitHub
parent 825ea93dba
commit 588f5bd6b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,22 +12,19 @@ import { HomeAssistant } from "../../types";
import "./ha-chart-base"; import "./ha-chart-base";
import type { TimeLineData } from "./timeline-chart/const"; import type { TimeLineData } from "./timeline-chart/const";
/** Binary sensor device classes for which the static colors for on/off need to be inverted. /** Binary sensor device classes for which the static colors for on/off are NOT inverted.
* List the ones were "off" = good or normal state = should be rendered "green". * List the ones were "on" = good or normal state => should be rendered "green".
* Note: It is now a "not inverted" list (compared to the past) since we now have more inverted ones.
*/ */
const BINARY_SENSOR_DEVICE_CLASS_COLOR_INVERTED = new Set([ const BINARY_SENSOR_DEVICE_CLASS_COLOR_NOT_INVERTED = new Set([
"battery", "battery_charging",
"door", "connectivity",
"garage_door", "light",
"gas", "moving",
"lock", "plug",
"motion", "power",
"opening", "presence",
"problem", "update",
"safety",
"smoke",
"tamper",
"window",
]); ]);
const STATIC_STATE_COLORS = new Set([ const STATIC_STATE_COLORS = new Set([
@ -48,7 +45,7 @@ const invertOnOff = (entityState?: HassEntity) =>
entityState && entityState &&
computeDomain(entityState.entity_id) === "binary_sensor" && computeDomain(entityState.entity_id) === "binary_sensor" &&
"device_class" in entityState.attributes && "device_class" in entityState.attributes &&
BINARY_SENSOR_DEVICE_CLASS_COLOR_INVERTED.has( !BINARY_SENSOR_DEVICE_CLASS_COLOR_NOT_INVERTED.has(
entityState.attributes.device_class! entityState.attributes.device_class!
); );