From 60e2ee86b2237ad62bdd662751f6f2b83dd8daa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 4 Jul 2023 21:29:14 +0200 Subject: [PATCH] Add Airzone Cloud Zone running binary sensor (#95606) --- homeassistant/components/airzone_cloud/binary_sensor.py | 6 +++++- tests/components/airzone_cloud/test_binary_sensor.py | 8 +++++++- tests/components/airzone_cloud/util.py | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/airzone_cloud/binary_sensor.py b/homeassistant/components/airzone_cloud/binary_sensor.py index 052318b6b10..29b550463d0 100644 --- a/homeassistant/components/airzone_cloud/binary_sensor.py +++ b/homeassistant/components/airzone_cloud/binary_sensor.py @@ -4,7 +4,7 @@ from __future__ import annotations from dataclasses import dataclass from typing import Any, Final -from aioairzone_cloud.const import AZD_PROBLEMS, AZD_WARNINGS, AZD_ZONES +from aioairzone_cloud.const import AZD_ACTIVE, AZD_PROBLEMS, AZD_WARNINGS, AZD_ZONES from homeassistant.components.binary_sensor import ( BinarySensorDeviceClass, @@ -29,6 +29,10 @@ class AirzoneBinarySensorEntityDescription(BinarySensorEntityDescription): ZONE_BINARY_SENSOR_TYPES: Final[tuple[AirzoneBinarySensorEntityDescription, ...]] = ( + AirzoneBinarySensorEntityDescription( + device_class=BinarySensorDeviceClass.RUNNING, + key=AZD_ACTIVE, + ), AirzoneBinarySensorEntityDescription( attributes={ "warnings": AZD_WARNINGS, diff --git a/tests/components/airzone_cloud/test_binary_sensor.py b/tests/components/airzone_cloud/test_binary_sensor.py index b2c9ee173b7..37357bf59da 100644 --- a/tests/components/airzone_cloud/test_binary_sensor.py +++ b/tests/components/airzone_cloud/test_binary_sensor.py @@ -1,6 +1,6 @@ """The binary sensor tests for the Airzone Cloud platform.""" -from homeassistant.const import STATE_OFF +from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant from .util import async_init_integration @@ -16,6 +16,12 @@ async def test_airzone_create_binary_sensors(hass: HomeAssistant) -> None: assert state.state == STATE_OFF assert state.attributes.get("warnings") is None + state = hass.states.get("binary_sensor.dormitorio_running") + assert state.state == STATE_OFF + state = hass.states.get("binary_sensor.salon_problem") assert state.state == STATE_OFF assert state.attributes.get("warnings") is None + + state = hass.states.get("binary_sensor.salon_running") + assert state.state == STATE_ON diff --git a/tests/components/airzone_cloud/util.py b/tests/components/airzone_cloud/util.py index 4eab870297b..80c0b4ae027 100644 --- a/tests/components/airzone_cloud/util.py +++ b/tests/components/airzone_cloud/util.py @@ -4,6 +4,7 @@ from typing import Any from unittest.mock import patch from aioairzone_cloud.const import ( + API_ACTIVE, API_AZ_AIDOO, API_AZ_SYSTEM, API_AZ_ZONE, @@ -177,6 +178,7 @@ def mock_get_device_status(device: Device) -> dict[str, Any]: } if device.get_id() == "zone2": return { + API_ACTIVE: False, API_HUMIDITY: 24, API_IS_CONNECTED: True, API_WS_CONNECTED: True, @@ -187,6 +189,7 @@ def mock_get_device_status(device: Device) -> dict[str, Any]: API_WARNINGS: [], } return { + API_ACTIVE: True, API_HUMIDITY: 30, API_IS_CONNECTED: True, API_WS_CONNECTED: True,