Add heating and cooling binary sensors to Plugwise (#66317)

pull/66321/head
Franck Nijhof 2022-02-11 13:36:27 +01:00 committed by GitHub
parent 6c3b36a978
commit 11a13aa0b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -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

View File

@ -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