mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add DeviceInfo to NINA (#103361)
This commit is contained in:
parent
37757f777f
commit
6036fda219
@ -9,6 +9,7 @@ from homeassistant.components.binary_sensor import (
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
@ -46,7 +47,9 @@ async def async_setup_entry(
|
||||
|
||||
for ent in coordinator.data:
|
||||
for i in range(0, message_slots):
|
||||
entities.append(NINAMessage(coordinator, ent, regions[ent], i + 1))
|
||||
entities.append(
|
||||
NINAMessage(coordinator, ent, regions[ent], i + 1, config_entry)
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
|
||||
@ -54,12 +57,15 @@ async def async_setup_entry(
|
||||
class NINAMessage(CoordinatorEntity[NINADataUpdateCoordinator], BinarySensorEntity):
|
||||
"""Representation of an NINA warning."""
|
||||
|
||||
_attr_device_class = BinarySensorDeviceClass.SAFETY
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: NINADataUpdateCoordinator,
|
||||
region: str,
|
||||
region_name: str,
|
||||
slot_id: int,
|
||||
config_entry: ConfigEntry,
|
||||
) -> None:
|
||||
"""Initialize."""
|
||||
super().__init__(coordinator)
|
||||
@ -69,7 +75,10 @@ class NINAMessage(CoordinatorEntity[NINADataUpdateCoordinator], BinarySensorEnti
|
||||
|
||||
self._attr_name = f"Warning: {region_name} {slot_id}"
|
||||
self._attr_unique_id = f"{region}-{slot_id}"
|
||||
self._attr_device_class = BinarySensorDeviceClass.SAFETY
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, config_entry.entry_id)},
|
||||
manufacturer="NINA",
|
||||
)
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
|
Loading…
x
Reference in New Issue
Block a user