mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Move available property to base entity in Sensibo (#134410)
* Move available property to base entity in Sensibo * Fix test
This commit is contained in:
parent
088b097a03
commit
97dc72a6e2
@ -295,11 +295,6 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
|
||||
"""Return the maximum temperature."""
|
||||
return self.device_data.temp_list[-1]
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return True if entity is available."""
|
||||
return self.device_data.available and super().available
|
||||
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
if "targetTemperature" not in self.device_data.active_features:
|
||||
|
@ -75,6 +75,11 @@ class SensiboBaseEntity(CoordinatorEntity[SensiboDataUpdateCoordinator]):
|
||||
"""Return data for device."""
|
||||
return self.coordinator.data.parsed[self._device_id]
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return True if entity is available."""
|
||||
return self.device_data.available and super().available
|
||||
|
||||
|
||||
class SensiboDeviceBaseEntity(SensiboBaseEntity):
|
||||
"""Representation of a Sensibo Device."""
|
||||
@ -125,8 +130,13 @@ class SensiboMotionBaseEntity(SensiboBaseEntity):
|
||||
)
|
||||
|
||||
@property
|
||||
def sensor_data(self) -> MotionSensor | None:
|
||||
def sensor_data(self) -> MotionSensor:
|
||||
"""Return data for Motion Sensor."""
|
||||
if TYPE_CHECKING:
|
||||
assert self.device_data.motion_sensors
|
||||
return self.device_data.motion_sensors[self._sensor_id]
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return True if entity is available."""
|
||||
return bool(self.sensor_data.alive) and super().available
|
||||
|
@ -10,7 +10,7 @@ import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.util import dt as dt_util
|
||||
@ -35,9 +35,6 @@ async def test_binary_sensor(
|
||||
|
||||
await snapshot_platform(hass, entity_registry, snapshot, load_int.entry_id)
|
||||
|
||||
monkeypatch.setattr(
|
||||
get_data.parsed["ABC999111"].motion_sensors["AABBCC"], "alive", False
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
get_data.parsed["ABC999111"].motion_sensors["AABBCC"], "motion", False
|
||||
)
|
||||
@ -54,5 +51,5 @@ async def test_binary_sensor(
|
||||
|
||||
state1 = hass.states.get("binary_sensor.hallway_motion_sensor_connectivity")
|
||||
state3 = hass.states.get("binary_sensor.hallway_motion_sensor_motion")
|
||||
assert state1.state == "off"
|
||||
assert state3.state == "off"
|
||||
assert state1.state == STATE_ON
|
||||
assert state3.state == STATE_OFF
|
||||
|
Loading…
x
Reference in New Issue
Block a user