Skip to content

Commit

Permalink
add unique entity_id to resolve #9
Browse files Browse the repository at this point in the history
  • Loading branch information
nberardi committed Jul 14, 2024
1 parent 9e691f8 commit 8a2239c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
3 changes: 3 additions & 0 deletions custom_components/kidde/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
class KiddeEntity(CoordinatorEntity[KiddeCoordinator]):
"""Entity base class."""

_attr_has_entity_name = True

def __init__(
self,
coordinator: KiddeCoordinator,
Expand Down Expand Up @@ -43,6 +45,7 @@ def device_info(self) -> DeviceInfo | None:
hw_version=device.get("hwrev"),
sw_version=str(device.get("fwrev")),
model=device.get("model"),
serial_number=device.get("serial_number"),
manufacturer=MANUFACTURER,
)

Expand Down
33 changes: 20 additions & 13 deletions custom_components/kidde/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@

_TIMESTAMP_DESCRIPTIONS = (
SensorEntityDescription(
"last_seen",
key="last_seen",
icon="mdi:home-clock",
name="Last Seen",
device_class=SensorDeviceClass.TIMESTAMP,
),
SensorEntityDescription(
"last_test_time",
key="last_test_time",
icon="mdi:home-clock",
name="Last Test Time",
device_class=SensorDeviceClass.TIMESTAMP,
Expand All @@ -47,29 +47,29 @@

_SENSOR_DESCRIPTIONS = (
SensorEntityDescription(
"smoke_level",
key="smoke_level",
icon="mdi:smoke",
name="Smoke Level",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.AQI,
),
SensorEntityDescription(
"co_level",
key="co_level",
icon="mdi:molecule-co",
name="CO Level",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.CO,
),
SensorEntityDescription(
"battery_state",
key="battery_state",
icon="mdi:battery-alert",
name="Battery State",
device_class=SensorDeviceClass.ENUM,
state_class=SensorStateClass.MEASUREMENT,
options=["ok", "failed"],
),
SensorEntityDescription(
"life",
key="life",
icon="mdi:calendar-clock",
name="Weeks to replace",
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -79,40 +79,47 @@

_MEASUREMENTSENSOR_DESCRIPTIONS = (
SensorEntityDescription(
"overall_iaq_status",
key="overall_iaq_status",
icon="mdi:air-filter",
name="Overall Air Quality",
device_class=SensorDeviceClass.AQI,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
"iaq_temperature",
key="iaq_temperature",
name="Indoor Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
"humidity",
key="humidity",
name="Humidity",
device_class=SensorDeviceClass.HUMIDITY,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
"hpa",
key="hpa",
name="Air Pressure",
device_class=SensorDeviceClass.ATMOSPHERIC_PRESSURE,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
"tvoc",
key="tvoc",
name="Total VOC",
device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
"iaq",
key="iaq",
name="Indoor Air Quality",
device_class=SensorDeviceClass.AQI,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
"co2",
key="co2",
name="CO₂ Level",
device_class=SensorDeviceClass.CO2,
state_class=SensorStateClass.MEASUREMENT,
),
)

Expand Down

0 comments on commit 8a2239c

Please sign in to comment.