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 typing import Any
|
||||
|
||||
from aranet4.client import Aranet4Advertisement
|
||||
from aranet4.client import Aranet4Advertisement, Color
|
||||
from bleak.backends.device import BLEDevice
|
||||
|
||||
from homeassistant.components.bluetooth.passive_update_processor import (
|
||||
@ -78,7 +78,7 @@ SENSOR_DESCRIPTIONS = {
|
||||
key="status",
|
||||
name="Threshold Level",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=["green", "yellow", "red"],
|
||||
options=[status.name for status in Color],
|
||||
),
|
||||
"co2": AranetSensorEntityDescription(
|
||||
key="co2",
|
||||
@ -167,6 +167,9 @@ def sensor_update_to_bluetooth_data_update(
|
||||
val = getattr(adv.readings, key)
|
||||
if val == -1:
|
||||
continue
|
||||
if key == "status":
|
||||
val = val.name # Use the name of the status
|
||||
else:
|
||||
val *= desc.scale
|
||||
data[tag] = val
|
||||
names[tag] = desc.name
|
||||
|
Loading…
x
Reference in New Issue
Block a user