mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Add binary sensors for Pure devices Boost Config (#73032)
This commit is contained in:
parent
6b2e5858b3
commit
7536586bed
@ -87,6 +87,48 @@ DEVICE_SENSOR_TYPES: tuple[SensiboDeviceBinarySensorEntityDescription, ...] = (
|
||||
),
|
||||
)
|
||||
|
||||
PURE_SENSOR_TYPES: tuple[SensiboDeviceBinarySensorEntityDescription, ...] = (
|
||||
SensiboDeviceBinarySensorEntityDescription(
|
||||
key="pure_boost_enabled",
|
||||
device_class=BinarySensorDeviceClass.RUNNING,
|
||||
name="Pure Boost Enabled",
|
||||
icon="mdi:wind-power-outline",
|
||||
value_fn=lambda data: data.pure_boost_enabled,
|
||||
),
|
||||
SensiboDeviceBinarySensorEntityDescription(
|
||||
key="pure_ac_integration",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
name="Pure Boost linked with AC",
|
||||
icon="mdi:connection",
|
||||
value_fn=lambda data: data.pure_ac_integration,
|
||||
),
|
||||
SensiboDeviceBinarySensorEntityDescription(
|
||||
key="pure_geo_integration",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
name="Pure Boost linked with Presence",
|
||||
icon="mdi:connection",
|
||||
value_fn=lambda data: data.pure_geo_integration,
|
||||
),
|
||||
SensiboDeviceBinarySensorEntityDescription(
|
||||
key="pure_measure_integration",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
name="Pure Boost linked with Indoor Air Quality",
|
||||
icon="mdi:connection",
|
||||
value_fn=lambda data: data.pure_measure_integration,
|
||||
),
|
||||
SensiboDeviceBinarySensorEntityDescription(
|
||||
key="pure_prime_integration",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
name="Pure Boost linked with Outdoor Air Quality",
|
||||
icon="mdi:connection",
|
||||
value_fn=lambda data: data.pure_prime_integration,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
@ -112,6 +154,12 @@ async def async_setup_entry(
|
||||
for device_id, device_data in coordinator.data.parsed.items()
|
||||
if getattr(device_data, description.key) is not None
|
||||
)
|
||||
entities.extend(
|
||||
SensiboDeviceSensor(coordinator, device_id, description)
|
||||
for description in PURE_SENSOR_TYPES
|
||||
for device_id, device_data in coordinator.data.parsed.items()
|
||||
if device_data.model == "pure"
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
|
||||
|
@ -116,7 +116,8 @@ PURE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = (
|
||||
key="pure_sensitivity",
|
||||
name="Pure Sensitivity",
|
||||
icon="mdi:air-filter",
|
||||
value_fn=lambda data: data.pure_sensitivity,
|
||||
value_fn=lambda data: str(data.pure_sensitivity).lower(),
|
||||
device_class="sensibo__sensitivity",
|
||||
),
|
||||
)
|
||||
|
||||
|
8
homeassistant/components/sensibo/strings.sensor.json
Normal file
8
homeassistant/components/sensibo/strings.sensor.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"state": {
|
||||
"sensibo__sensitivity": {
|
||||
"n": "Normal",
|
||||
"s": "Sensitive"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"state": {
|
||||
"sensibo__sensitivity": {
|
||||
"n": "Normal",
|
||||
"s": "Sensitive"
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from pysensibo.model import SensiboData
|
||||
from pytest import MonkeyPatch
|
||||
@ -16,6 +16,7 @@ from tests.common import async_fire_time_changed
|
||||
|
||||
async def test_binary_sensor(
|
||||
hass: HomeAssistant,
|
||||
entity_registry_enabled_by_default: AsyncMock,
|
||||
load_int: ConfigEntry,
|
||||
monkeypatch: MonkeyPatch,
|
||||
get_data: SensiboData,
|
||||
@ -26,10 +27,20 @@ async def test_binary_sensor(
|
||||
state2 = hass.states.get("binary_sensor.hallway_motion_sensor_main_sensor")
|
||||
state3 = hass.states.get("binary_sensor.hallway_motion_sensor_motion")
|
||||
state4 = hass.states.get("binary_sensor.hallway_room_occupied")
|
||||
state5 = hass.states.get("binary_sensor.kitchen_pure_boost_enabled")
|
||||
state6 = hass.states.get(
|
||||
"binary_sensor.kitchen_pure_boost_linked_with_indoor_air_quality"
|
||||
)
|
||||
state7 = hass.states.get(
|
||||
"binary_sensor.kitchen_pure_boost_linked_with_outdoor_air_quality"
|
||||
)
|
||||
assert state1.state == "on"
|
||||
assert state2.state == "on"
|
||||
assert state3.state == "on"
|
||||
assert state4.state == "on"
|
||||
assert state5.state == "off"
|
||||
assert state6.state == "on"
|
||||
assert state7.state == "off"
|
||||
|
||||
monkeypatch.setattr(
|
||||
get_data.parsed["ABC999111"].motion_sensors["AABBCC"], "alive", False
|
||||
|
@ -24,8 +24,10 @@ async def test_sensor(
|
||||
|
||||
state1 = hass.states.get("sensor.hallway_motion_sensor_battery_voltage")
|
||||
state2 = hass.states.get("sensor.kitchen_pm2_5")
|
||||
state3 = hass.states.get("sensor.kitchen_pure_sensitivity")
|
||||
assert state1.state == "3000"
|
||||
assert state2.state == "1"
|
||||
assert state3.state == "n"
|
||||
assert state2.attributes == {
|
||||
"state_class": "measurement",
|
||||
"unit_of_measurement": "µg/m³",
|
||||
|
Loading…
x
Reference in New Issue
Block a user