hass-core/homeassistant/components/iskra/entity.py
Iskra kranj b557e9e826
Add Iskra integration (#121488)
* Add iskra integration

* iskra non resettable counters naming fix

* added iskra config_flow test

* fixed iskra integration according to code review

* changed iskra config flow test

* iskra integration, fixed codeowners

* Removed counters code & minor fixes

* added comment

* Update homeassistant/components/iskra/__init__.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Updated Iskra integration according to review

* Update homeassistant/components/iskra/strings.json

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Updated iskra integration according to review

* minor iskra integration change

* iskra integration changes according to review

* iskra integration changes according to review

* Changed iskra integration according to review

* added iskra config_flow range validation

* Fixed tests for iskra integration

* Update homeassistant/components/iskra/coordinator.py

* Update homeassistant/components/iskra/config_flow.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Fixed iskra integration according to review

* Changed voluptuous schema for iskra integration and added data_descriptions

* Iskra integration tests lint error fix

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-09-04 15:33:23 +02:00

38 lines
1.4 KiB
Python

"""Base entity for Iskra devices."""
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN, MANUFACTURER
from .coordinator import IskraDataUpdateCoordinator
class IskraEntity(CoordinatorEntity[IskraDataUpdateCoordinator]):
"""Representation a base Iskra device."""
_attr_has_entity_name = True
def __init__(self, coordinator: IskraDataUpdateCoordinator) -> None:
"""Initialize the Iskra device."""
super().__init__(coordinator)
self.device = coordinator.device
gateway = self.device.parent_device
if gateway is not None:
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self.device.serial)},
manufacturer=MANUFACTURER,
model=self.device.model,
name=self.device.model,
sw_version=self.device.fw_version,
serial_number=self.device.serial,
via_device=(DOMAIN, gateway.serial),
)
else:
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self.device.serial)},
manufacturer=MANUFACTURER,
model=self.device.model,
sw_version=self.device.fw_version,
serial_number=self.device.serial,
)