Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unique entity_id to resolve #9 #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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