From 61e22831465f9c8f51a324829abbd16c5800dbab Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker <joostlek@outlook.com> Date: Fri, 25 Oct 2024 12:46:46 +0200 Subject: [PATCH] Add base class to Smarty (#129112) --- homeassistant/components/smarty/binary_sensor.py | 4 ++-- homeassistant/components/smarty/entity.py | 9 +++++++++ homeassistant/components/smarty/fan.py | 4 ++-- homeassistant/components/smarty/sensor.py | 4 ++-- 4 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 homeassistant/components/smarty/entity.py diff --git a/homeassistant/components/smarty/binary_sensor.py b/homeassistant/components/smarty/binary_sensor.py index cb0cdef7dbc..a0282d5b31d 100644 --- a/homeassistant/components/smarty/binary_sensor.py +++ b/homeassistant/components/smarty/binary_sensor.py @@ -15,9 +15,9 @@ from homeassistant.components.binary_sensor import ( ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.update_coordinator import CoordinatorEntity from .coordinator import SmartyConfigEntry, SmartyCoordinator +from .entity import SmartyEntity _LOGGER = logging.getLogger(__name__) @@ -64,7 +64,7 @@ async def async_setup_entry( ) -class SmartyBinarySensor(CoordinatorEntity[SmartyCoordinator], BinarySensorEntity): +class SmartyBinarySensor(SmartyEntity, BinarySensorEntity): """Representation of a Smarty Binary Sensor.""" entity_description: SmartyBinarySensorEntityDescription diff --git a/homeassistant/components/smarty/entity.py b/homeassistant/components/smarty/entity.py new file mode 100644 index 00000000000..c9ac1139b87 --- /dev/null +++ b/homeassistant/components/smarty/entity.py @@ -0,0 +1,9 @@ +"""Smarty Entity class.""" + +from homeassistant.helpers.update_coordinator import CoordinatorEntity + +from .coordinator import SmartyCoordinator + + +class SmartyEntity(CoordinatorEntity[SmartyCoordinator]): + """Representation of a Smarty Entity.""" diff --git a/homeassistant/components/smarty/fan.py b/homeassistant/components/smarty/fan.py index 898d53ebf89..e9d6b1df37a 100644 --- a/homeassistant/components/smarty/fan.py +++ b/homeassistant/components/smarty/fan.py @@ -10,7 +10,6 @@ from homeassistant.components.fan import FanEntity, FanEntityFeature from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.util.percentage import ( percentage_to_ranged_value, ranged_value_to_percentage, @@ -19,6 +18,7 @@ from homeassistant.util.scaling import int_states_in_range from . import SmartyConfigEntry from .coordinator import SmartyCoordinator +from .entity import SmartyEntity _LOGGER = logging.getLogger(__name__) @@ -38,7 +38,7 @@ async def async_setup_entry( async_add_entities([SmartyFan(coordinator)]) -class SmartyFan(CoordinatorEntity[SmartyCoordinator], FanEntity): +class SmartyFan(SmartyEntity, FanEntity): """Representation of a Smarty Fan.""" _attr_icon = "mdi:air-conditioner" diff --git a/homeassistant/components/smarty/sensor.py b/homeassistant/components/smarty/sensor.py index c1ae27c8ecc..f720abfbbf6 100644 --- a/homeassistant/components/smarty/sensor.py +++ b/homeassistant/components/smarty/sensor.py @@ -17,10 +17,10 @@ from homeassistant.components.sensor import ( from homeassistant.const import UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.update_coordinator import CoordinatorEntity import homeassistant.util.dt as dt_util from .coordinator import SmartyConfigEntry, SmartyCoordinator +from .entity import SmartyEntity _LOGGER = logging.getLogger(__name__) @@ -94,7 +94,7 @@ async def async_setup_entry( ) -class SmartySensor(CoordinatorEntity[SmartyCoordinator], SensorEntity): +class SmartySensor(SmartyEntity, SensorEntity): """Representation of a Smarty Sensor.""" entity_description: SmartySensorDescription -- GitLab