mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add thermostat battery and signal sensors for Airzone integration (#142390)
* airzone: add thermostat battery/signal sensors Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> * tests: airzone: use snapshot_platform for sensors Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> * airzone: rename sensor strength Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> --------- Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
parent
bea389eed7
commit
7c488f1e54
@ -9,6 +9,8 @@ from aioairzone.const import (
|
|||||||
AZD_HUMIDITY,
|
AZD_HUMIDITY,
|
||||||
AZD_TEMP,
|
AZD_TEMP,
|
||||||
AZD_TEMP_UNIT,
|
AZD_TEMP_UNIT,
|
||||||
|
AZD_THERMOSTAT_BATTERY,
|
||||||
|
AZD_THERMOSTAT_SIGNAL,
|
||||||
AZD_WEBSERVER,
|
AZD_WEBSERVER,
|
||||||
AZD_WIFI_RSSI,
|
AZD_WIFI_RSSI,
|
||||||
AZD_ZONES,
|
AZD_ZONES,
|
||||||
@ -73,6 +75,20 @@ ZONE_SENSOR_TYPES: Final[tuple[SensorEntityDescription, ...]] = (
|
|||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
device_class=SensorDeviceClass.BATTERY,
|
||||||
|
key=AZD_THERMOSTAT_BATTERY,
|
||||||
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
SensorEntityDescription(
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
key=AZD_THERMOSTAT_SIGNAL,
|
||||||
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
translation_key="thermostat_signal",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,6 +76,9 @@
|
|||||||
"sensor": {
|
"sensor": {
|
||||||
"rssi": {
|
"rssi": {
|
||||||
"name": "RSSI"
|
"name": "RSSI"
|
||||||
|
},
|
||||||
|
"thermostat_signal": {
|
||||||
|
"name": "Signal strength"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1245
tests/components/airzone/snapshots/test_sensor.ambr
Normal file
1245
tests/components/airzone/snapshots/test_sensor.ambr
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,17 @@
|
|||||||
"""The sensor tests for the Airzone platform."""
|
"""The sensor tests for the Airzone platform."""
|
||||||
|
|
||||||
|
from collections.abc import Generator
|
||||||
import copy
|
import copy
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from aioairzone.const import API_DATA, API_SYSTEMS
|
from aioairzone.const import API_DATA, API_SYSTEMS
|
||||||
import pytest
|
import pytest
|
||||||
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.airzone.coordinator import SCAN_INTERVAL
|
from homeassistant.components.airzone.coordinator import SCAN_INTERVAL
|
||||||
from homeassistant.const import STATE_UNAVAILABLE
|
from homeassistant.const import STATE_UNAVAILABLE, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
from .util import (
|
from .util import (
|
||||||
@ -20,62 +23,27 @@ from .util import (
|
|||||||
async_init_integration,
|
async_init_integration,
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import async_fire_time_changed
|
from tests.common import async_fire_time_changed, snapshot_platform
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def override_platforms() -> Generator[None]:
|
||||||
|
"""Override PLATFORMS."""
|
||||||
|
with patch("homeassistant.components.airzone.PLATFORMS", [Platform.SENSOR]):
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||||
async def test_airzone_create_sensors(hass: HomeAssistant) -> None:
|
async def test_airzone_create_sensors(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
|
) -> None:
|
||||||
"""Test creation of sensors."""
|
"""Test creation of sensors."""
|
||||||
|
|
||||||
await async_init_integration(hass)
|
config_entry = await async_init_integration(hass)
|
||||||
|
|
||||||
# Hot Water
|
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
|
||||||
state = hass.states.get("sensor.airzone_dhw_temperature")
|
|
||||||
assert state.state == "43"
|
|
||||||
|
|
||||||
# WebServer
|
|
||||||
state = hass.states.get("sensor.airzone_webserver_rssi")
|
|
||||||
assert state.state == "-42"
|
|
||||||
|
|
||||||
# Zones
|
|
||||||
state = hass.states.get("sensor.despacho_temperature")
|
|
||||||
assert state.state == "21.20"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.despacho_humidity")
|
|
||||||
assert state.state == "36"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.dorm_1_temperature")
|
|
||||||
assert state.state == "20.8"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.dorm_1_humidity")
|
|
||||||
assert state.state == "35"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.dorm_2_temperature")
|
|
||||||
assert state.state == "20.5"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.dorm_2_humidity")
|
|
||||||
assert state.state == "40"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.dorm_ppal_temperature")
|
|
||||||
assert state.state == "21.1"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.dorm_ppal_humidity")
|
|
||||||
assert state.state == "39"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.salon_temperature")
|
|
||||||
assert state.state == "19.6"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.salon_humidity")
|
|
||||||
assert state.state == "34"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.airzone_2_1_temperature")
|
|
||||||
assert state.state == "22.3"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.airzone_2_1_humidity")
|
|
||||||
assert state.state == "62"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.dkn_plus_temperature")
|
|
||||||
assert state.state == "21.7"
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.dkn_plus_humidity")
|
state = hass.states.get("sensor.dkn_plus_humidity")
|
||||||
assert state is None
|
assert state is None
|
||||||
|
@ -371,7 +371,7 @@ HVAC_WEBSERVER_MOCK = {
|
|||||||
|
|
||||||
async def async_init_integration(
|
async def async_init_integration(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
) -> None:
|
) -> MockConfigEntry:
|
||||||
"""Set up the Airzone integration in Home Assistant."""
|
"""Set up the Airzone integration in Home Assistant."""
|
||||||
|
|
||||||
config_entry = MockConfigEntry(
|
config_entry = MockConfigEntry(
|
||||||
@ -407,3 +407,5 @@ async def async_init_integration(
|
|||||||
):
|
):
|
||||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
return config_entry
|
||||||
|
Loading…
x
Reference in New Issue
Block a user