Split opentherm_gw entity base class (#125330)
Add OpenThermStatusEntity to allow entities that don't need status updatespull/125331/head
parent
70966c2b63
commit
65e16b4814
|
@ -22,7 +22,7 @@ from .const import (
|
|||
THERMOSTAT_DEVICE_DESCRIPTION,
|
||||
OpenThermDataSource,
|
||||
)
|
||||
from .entity import OpenThermEntity, OpenThermEntityDescription
|
||||
from .entity import OpenThermEntityDescription, OpenThermStatusEntity
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
|
@ -404,7 +404,7 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
|
||||
class OpenThermBinarySensor(OpenThermEntity, BinarySensorEntity):
|
||||
class OpenThermBinarySensor(OpenThermStatusEntity, BinarySensorEntity):
|
||||
"""Represent an OpenTherm Gateway binary sensor."""
|
||||
|
||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||
|
|
|
@ -12,16 +12,11 @@ from homeassistant.components.button import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ID, EntityCategory
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import OpenThermGatewayHub
|
||||
from .const import (
|
||||
DATA_GATEWAYS,
|
||||
DATA_OPENTHERM_GW,
|
||||
GATEWAY_DEVICE_DESCRIPTION,
|
||||
OpenThermDataSource,
|
||||
)
|
||||
from .const import DATA_GATEWAYS, DATA_OPENTHERM_GW, GATEWAY_DEVICE_DESCRIPTION
|
||||
from .entity import OpenThermEntity, OpenThermEntityDescription
|
||||
|
||||
|
||||
|
@ -63,11 +58,6 @@ class OpenThermButton(OpenThermEntity, ButtonEntity):
|
|||
_attr_entity_category = EntityCategory.CONFIG
|
||||
entity_description: OpenThermButtonEntityDescription
|
||||
|
||||
@callback
|
||||
def receive_report(self, status: dict[OpenThermDataSource, dict]) -> None:
|
||||
"""Handle status updates from the component."""
|
||||
# We don't need any information from the reports here
|
||||
|
||||
async def async_press(self) -> None:
|
||||
"""Perform button action."""
|
||||
await self.entity_description.action(self._gateway)
|
||||
|
|
|
@ -34,7 +34,7 @@ from .const import (
|
|||
THERMOSTAT_DEVICE_DESCRIPTION,
|
||||
OpenThermDataSource,
|
||||
)
|
||||
from .entity import OpenThermEntity, OpenThermEntityDescription
|
||||
from .entity import OpenThermEntityDescription, OpenThermStatusEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -69,7 +69,7 @@ async def async_setup_entry(
|
|||
async_add_entities(ents)
|
||||
|
||||
|
||||
class OpenThermClimate(OpenThermEntity, ClimateEntity):
|
||||
class OpenThermClimate(OpenThermStatusEntity, ClimateEntity):
|
||||
"""Representation of a climate device."""
|
||||
|
||||
_attr_supported_features = (
|
||||
|
|
|
@ -52,6 +52,15 @@ class OpenThermEntity(Entity):
|
|||
},
|
||||
)
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return connection status of the hub to indicate availability."""
|
||||
return self._gateway.connected
|
||||
|
||||
|
||||
class OpenThermStatusEntity(OpenThermEntity):
|
||||
"""Represent an OpenTherm entity that receives status updates."""
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Subscribe to updates from the component."""
|
||||
self.async_on_remove(
|
||||
|
@ -60,11 +69,6 @@ class OpenThermEntity(Entity):
|
|||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return connection status of the hub to indicate availability."""
|
||||
return self._gateway.connected
|
||||
|
||||
@callback
|
||||
def receive_report(self, status: dict[OpenThermDataSource, dict]) -> None:
|
||||
"""Handle status updates from the component."""
|
||||
|
|
|
@ -32,7 +32,7 @@ from .const import (
|
|||
THERMOSTAT_DEVICE_DESCRIPTION,
|
||||
OpenThermDataSource,
|
||||
)
|
||||
from .entity import OpenThermEntity, OpenThermEntityDescription
|
||||
from .entity import OpenThermEntityDescription, OpenThermStatusEntity
|
||||
|
||||
SENSOR_FLOAT_SUGGESTED_DISPLAY_PRECISION = 1
|
||||
|
||||
|
@ -889,7 +889,7 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
|
||||
class OpenThermSensor(OpenThermEntity, SensorEntity):
|
||||
class OpenThermSensor(OpenThermStatusEntity, SensorEntity):
|
||||
"""Representation of an OpenTherm sensor."""
|
||||
|
||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||
|
|
Loading…
Reference in New Issue