mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 18:48:22 +00:00
Use Color enum for status options
This commit is contained in:
parent
aee85a80b4
commit
73226ba138
@ -5,7 +5,7 @@ from __future__ import annotations
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aranet4.client import Aranet4Advertisement
|
from aranet4.client import Aranet4Advertisement, Color
|
||||||
from bleak.backends.device import BLEDevice
|
from bleak.backends.device import BLEDevice
|
||||||
|
|
||||||
from homeassistant.components.bluetooth.passive_update_processor import (
|
from homeassistant.components.bluetooth.passive_update_processor import (
|
||||||
@ -78,7 +78,7 @@ SENSOR_DESCRIPTIONS = {
|
|||||||
key="status",
|
key="status",
|
||||||
name="Threshold Level",
|
name="Threshold Level",
|
||||||
device_class=SensorDeviceClass.ENUM,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
options=["green", "yellow", "red"],
|
options=[status.name for status in Color],
|
||||||
),
|
),
|
||||||
"co2": AranetSensorEntityDescription(
|
"co2": AranetSensorEntityDescription(
|
||||||
key="co2",
|
key="co2",
|
||||||
@ -167,7 +167,10 @@ def sensor_update_to_bluetooth_data_update(
|
|||||||
val = getattr(adv.readings, key)
|
val = getattr(adv.readings, key)
|
||||||
if val == -1:
|
if val == -1:
|
||||||
continue
|
continue
|
||||||
val *= desc.scale
|
if key == "status":
|
||||||
|
val = val.name # Use the name of the status
|
||||||
|
else:
|
||||||
|
val *= desc.scale
|
||||||
data[tag] = val
|
data[tag] = val
|
||||||
names[tag] = desc.name
|
names[tag] = desc.name
|
||||||
descs[tag] = desc
|
descs[tag] = desc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user