Add heating and cooling binary sensors to Plugwise (#66317)
parent
6c3b36a978
commit
11a13aa0b8
|
@ -43,6 +43,20 @@ BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = (
|
|||
icon_off="mdi:fire-off",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
PlugwiseBinarySensorEntityDescription(
|
||||
key="heating_state",
|
||||
name="Heating",
|
||||
icon="mdi:radiator",
|
||||
icon_off="mdi:radiator-off",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
PlugwiseBinarySensorEntityDescription(
|
||||
key="cooling_state",
|
||||
name="Cooling",
|
||||
icon="mdi:snowflake",
|
||||
icon_off="mdi:snowflake-off",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
PlugwiseBinarySensorEntityDescription(
|
||||
key="slave_boiler_state",
|
||||
name="Secondary Boiler State",
|
||||
|
@ -73,7 +87,7 @@ async def async_setup_entry(
|
|||
entities: list[PlugwiseBinarySensorEntity] = []
|
||||
for device_id, device in coordinator.data.devices.items():
|
||||
for description in BINARY_SENSORS:
|
||||
if (
|
||||
if description.key not in device and (
|
||||
"binary_sensors" not in device
|
||||
or description.key not in device["binary_sensors"]
|
||||
):
|
||||
|
@ -109,6 +123,8 @@ class PlugwiseBinarySensorEntity(PlugwiseEntity, BinarySensorEntity):
|
|||
@property
|
||||
def is_on(self) -> bool | None:
|
||||
"""Return true if the binary sensor is on."""
|
||||
if self.entity_description.key in self.device:
|
||||
return self.device[self.entity_description.key]
|
||||
return self.device["binary_sensors"].get(self.entity_description.key)
|
||||
|
||||
@property
|
||||
|
|
|
@ -21,6 +21,14 @@ async def test_anna_climate_binary_sensor_entities(
|
|||
assert state
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
state = hass.states.get("binary_sensor.opentherm_heating")
|
||||
assert state
|
||||
assert state.state == STATE_ON
|
||||
|
||||
state = hass.states.get("binary_sensor.opentherm_cooling")
|
||||
assert state
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
|
||||
async def test_anna_climate_binary_sensor_change(
|
||||
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
|
||||
|
|
Loading…
Reference in New Issue