mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 08:46:35 +00:00
Add additional binary device classes to inversion list (#10152)
This commit is contained in:
parent
825ea93dba
commit
588f5bd6b7
@ -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!
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user