Add heating and cooling binary sensors to Plugwise (#66317)
This commit is contained in:
parent
6c3b36a978
commit
11a13aa0b8
2 changed files with 25 additions and 1 deletions
|
@ -43,6 +43,20 @@ BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = (
|
||||||
icon_off="mdi:fire-off",
|
icon_off="mdi:fire-off",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
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(
|
PlugwiseBinarySensorEntityDescription(
|
||||||
key="slave_boiler_state",
|
key="slave_boiler_state",
|
||||||
name="Secondary Boiler State",
|
name="Secondary Boiler State",
|
||||||
|
@ -73,7 +87,7 @@ async def async_setup_entry(
|
||||||
entities: list[PlugwiseBinarySensorEntity] = []
|
entities: list[PlugwiseBinarySensorEntity] = []
|
||||||
for device_id, device in coordinator.data.devices.items():
|
for device_id, device in coordinator.data.devices.items():
|
||||||
for description in BINARY_SENSORS:
|
for description in BINARY_SENSORS:
|
||||||
if (
|
if description.key not in device and (
|
||||||
"binary_sensors" not in device
|
"binary_sensors" not in device
|
||||||
or description.key not in device["binary_sensors"]
|
or description.key not in device["binary_sensors"]
|
||||||
):
|
):
|
||||||
|
@ -109,6 +123,8 @@ class PlugwiseBinarySensorEntity(PlugwiseEntity, BinarySensorEntity):
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool | None:
|
def is_on(self) -> bool | None:
|
||||||
"""Return true if the binary sensor is on."""
|
"""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)
|
return self.device["binary_sensors"].get(self.entity_description.key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -21,6 +21,14 @@ async def test_anna_climate_binary_sensor_entities(
|
||||||
assert state
|
assert state
|
||||||
assert state.state == STATE_OFF
|
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(
|
async def test_anna_climate_binary_sensor_change(
|
||||||
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
|
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
|
||||||
|
|
Loading…
Add table
Reference in a new issue