diff --git a/homeassistant/components/sensibo/binary_sensor.py b/homeassistant/components/sensibo/binary_sensor.py index e8d83f04593..3a7deadc405 100644 --- a/homeassistant/components/sensibo/binary_sensor.py +++ b/homeassistant/components/sensibo/binary_sensor.py @@ -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) diff --git a/homeassistant/components/sensibo/sensor.py b/homeassistant/components/sensibo/sensor.py index 7254948bdad..f37a054b606 100644 --- a/homeassistant/components/sensibo/sensor.py +++ b/homeassistant/components/sensibo/sensor.py @@ -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", ), ) diff --git a/homeassistant/components/sensibo/strings.sensor.json b/homeassistant/components/sensibo/strings.sensor.json new file mode 100644 index 00000000000..2e4e05fba5b --- /dev/null +++ b/homeassistant/components/sensibo/strings.sensor.json @@ -0,0 +1,8 @@ +{ + "state": { + "sensibo__sensitivity": { + "n": "Normal", + "s": "Sensitive" + } + } +} diff --git a/homeassistant/components/sensibo/translations/sensor.en.json b/homeassistant/components/sensibo/translations/sensor.en.json new file mode 100644 index 00000000000..9ea1818b37c --- /dev/null +++ b/homeassistant/components/sensibo/translations/sensor.en.json @@ -0,0 +1,8 @@ +{ + "state": { + "sensibo__sensitivity": { + "n": "Normal", + "s": "Sensitive" + } + } +} \ No newline at end of file diff --git a/tests/components/sensibo/test_binary_sensor.py b/tests/components/sensibo/test_binary_sensor.py index 3a84dc99ca5..efa6c5bdb2a 100644 --- a/tests/components/sensibo/test_binary_sensor.py +++ b/tests/components/sensibo/test_binary_sensor.py @@ -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 diff --git a/tests/components/sensibo/test_sensor.py b/tests/components/sensibo/test_sensor.py index 413b62f6b9f..426416ae2b9 100644 --- a/tests/components/sensibo/test_sensor.py +++ b/tests/components/sensibo/test_sensor.py @@ -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³",