Add Airzone Cloud Zone running binary sensor (#95606)

This commit is contained in:
Álvaro Fernández Rojas 2023-07-04 21:29:14 +02:00 committed by GitHub
parent ea160c2bad
commit 60e2ee86b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

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

View File

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

View File

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