Implement battery state binary sensor in Plugwise (#126020)

This commit is contained in:
Bouwe Westerdijk 2024-09-16 11:06:25 +02:00 committed by GitHub
parent 156a88a3a3
commit 29fb83e98b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 3 deletions

View File

@ -9,6 +9,7 @@ from typing import Any
from plugwise.constants import BinarySensorType from plugwise.constants import BinarySensorType
from homeassistant.components.binary_sensor import ( from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity, BinarySensorEntity,
BinarySensorEntityDescription, BinarySensorEntityDescription,
) )
@ -31,6 +32,12 @@ class PlugwiseBinarySensorEntityDescription(BinarySensorEntityDescription):
BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = ( BINARY_SENSORS: tuple[PlugwiseBinarySensorEntityDescription, ...] = (
PlugwiseBinarySensorEntityDescription(
key="low_battery",
translation_key="low_battery",
device_class=BinarySensorDeviceClass.BATTERY,
entity_category=EntityCategory.DIAGNOSTIC,
),
PlugwiseBinarySensorEntityDescription( PlugwiseBinarySensorEntityDescription(
key="compressor_state", key="compressor_state",
translation_key="compressor_state", translation_key="compressor_state",

View File

@ -30,6 +30,9 @@
}, },
"entity": { "entity": {
"binary_sensor": { "binary_sensor": {
"low_battery": {
"name": "Battery state"
},
"compressor_state": { "compressor_state": {
"name": "Compressor state" "name": "Compressor state"
}, },

View File

@ -40,6 +40,9 @@ TOM = {
"location": "f871b8c4d63549319221e294e4f88074", "location": "f871b8c4d63549319221e294e4f88074",
"model": "Tom/Floor", "model": "Tom/Floor",
"name": "Tom Zolder", "name": "Tom Zolder",
"binary_sensors": {
"low_battery": False,
},
"sensors": { "sensors": {
"battery": 99, "battery": 99,
"temperature": 18.6, "temperature": 18.6,
@ -221,7 +224,7 @@ async def test_update_device(
entity_registry, mock_config_entry.entry_id entity_registry, mock_config_entry.entry_id
) )
) )
== 29 == 31
) )
assert ( assert (
len( len(
@ -244,7 +247,7 @@ async def test_update_device(
entity_registry, mock_config_entry.entry_id entity_registry, mock_config_entry.entry_id
) )
) )
== 34 == 37
) )
assert ( assert (
len( len(
@ -271,7 +274,7 @@ async def test_update_device(
entity_registry, mock_config_entry.entry_id entity_registry, mock_config_entry.entry_id
) )
) )
== 29 == 31
) )
assert ( assert (
len( len(