From 523b52748681d8ad139faf8e0993e14e1b19c942 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 17 Feb 2026 16:19:35 +0100 Subject: [PATCH] Use shorthand attributes in omnilogic (#163283) --- homeassistant/components/omnilogic/entity.py | 42 ++++---------------- homeassistant/components/omnilogic/sensor.py | 8 ++-- 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/homeassistant/components/omnilogic/entity.py b/homeassistant/components/omnilogic/entity.py index 6f7b769fc8f..99aac699589 100644 --- a/homeassistant/components/omnilogic/entity.py +++ b/homeassistant/components/omnilogic/entity.py @@ -1,7 +1,5 @@ """Common classes and elements for Omnilogic Integration.""" -from typing import Any - from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -54,40 +52,14 @@ class OmniLogicEntity(CoordinatorEntity[OmniLogicUpdateCoordinator]): unique_id = unique_id.replace(" ", "_") self._kind = kind - self._name = entity_friendly_name - self._unique_id = unique_id + self._attr_name = entity_friendly_name + self._attr_unique_id = unique_id self._item_id = item_id - self._icon = icon - self._attrs: dict[str, Any] = {} - self._msp_system_id = msp_system_id - self._backyard_name = coordinator.data[backyard_id]["BackyardName"] - - @property - def unique_id(self) -> str: - """Return a unique, Home Assistant friendly identifier for this entity.""" - return self._unique_id - - @property - def name(self) -> str: - """Return the name of the entity.""" - return self._name - - @property - def icon(self): - """Return the icon for the entity.""" - return self._icon - - @property - def extra_state_attributes(self): - """Return the attributes.""" - return self._attrs - - @property - def device_info(self) -> DeviceInfo: - """Define the device as back yard/MSP System.""" - return DeviceInfo( - identifiers={(DOMAIN, self._msp_system_id)}, + self._attr_icon = icon + self._attr_extra_state_attributes = {} + self._attr_device_info = DeviceInfo( + identifiers={(DOMAIN, msp_system_id)}, manufacturer="Hayward", model="OmniLogic", - name=self._backyard_name, + name=coordinator.data[backyard_id]["BackyardName"], ) diff --git a/homeassistant/components/omnilogic/sensor.py b/homeassistant/components/omnilogic/sensor.py index d941eb3ae4d..522dcc4f3cd 100644 --- a/homeassistant/components/omnilogic/sensor.py +++ b/homeassistant/components/omnilogic/sensor.py @@ -115,8 +115,10 @@ class OmniLogicTemperatureSensor(OmnilogicSensor): hayward_state = None state = None - self._attrs["hayward_temperature"] = hayward_state - self._attrs["hayward_unit_of_measure"] = hayward_unit_of_measure + self._attr_extra_state_attributes["hayward_temperature"] = hayward_state + self._attr_extra_state_attributes["hayward_unit_of_measure"] = ( + hayward_unit_of_measure + ) self._attr_native_unit_of_measurement = UnitOfTemperature.FAHRENHEIT @@ -153,7 +155,7 @@ class OmniLogicPumpSpeedSensor(OmnilogicSensor): ): state = "high" - self._attrs["pump_type"] = pump_type + self._attr_extra_state_attributes["pump_type"] = pump_type return state