From 29fb83e98bfe23f7c3e3ffcc208fa21b28f39db1 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk <11290930+bouwew@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:06:25 +0200 Subject: [PATCH] Implement battery state binary sensor in Plugwise (#126020) --- homeassistant/components/plugwise/binary_sensor.py | 7 +++++++ homeassistant/components/plugwise/strings.json | 3 +++ tests/components/plugwise/test_init.py | 9 ++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/plugwise/binary_sensor.py b/homeassistant/components/plugwise/binary_sensor.py index 4b251d20a02..fb271ea7264 100644 --- a/homeassistant/components/plugwise/binary_sensor.py +++ b/homeassistant/components/plugwise/binary_sensor.py @@ -9,6 +9,7 @@ from typing import Any from plugwise.constants import BinarySensorType from homeassistant.components.binary_sensor import ( + BinarySensorDeviceClass, BinarySensorEntity, BinarySensorEntityDescription, ) @@ -31,6 +32,12 @@ class PlugwiseBinarySensorEntityDescription(BinarySensorEntityDescription): BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = ( + PlugwiseBinarySensorEntityDescription( + key="low_battery", + translation_key="low_battery", + device_class=BinarySensorDeviceClass.BATTERY, + entity_category=EntityCategory.DIAGNOSTIC, + ), PlugwiseBinarySensorEntityDescription( key="compressor_state", translation_key="compressor_state", diff --git a/homeassistant/components/plugwise/strings.json b/homeassistant/components/plugwise/strings.json index f74fc036e2a..c09323f458b 100644 --- a/homeassistant/components/plugwise/strings.json +++ b/homeassistant/components/plugwise/strings.json @@ -30,6 +30,9 @@ }, "entity": { "binary_sensor": { + "low_battery": { + "name": "Battery state" + }, "compressor_state": { "name": "Compressor state" }, diff --git a/tests/components/plugwise/test_init.py b/tests/components/plugwise/test_init.py index 26aedf864dc..46ef7b89d09 100644 --- a/tests/components/plugwise/test_init.py +++ b/tests/components/plugwise/test_init.py @@ -40,6 +40,9 @@ TOM = { "location": "f871b8c4d63549319221e294e4f88074", "model": "Tom/Floor", "name": "Tom Zolder", + "binary_sensors": { + "low_battery": False, + }, "sensors": { "battery": 99, "temperature": 18.6, @@ -221,7 +224,7 @@ async def test_update_device( entity_registry, mock_config_entry.entry_id ) ) - == 29 + == 31 ) assert ( len( @@ -244,7 +247,7 @@ async def test_update_device( entity_registry, mock_config_entry.entry_id ) ) - == 34 + == 37 ) assert ( len( @@ -271,7 +274,7 @@ async def test_update_device( entity_registry, mock_config_entry.entry_id ) ) - == 29 + == 31 ) assert ( len(