Nuki add binary sensor for battery charging (#111320)

* Nuki binary sensors

* disable by default
This commit is contained in:
steffenrapp 2024-02-25 13:37:13 +01:00 committed by GitHub
parent 7d37aeac59
commit 13621532fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 8 deletions

View File

@ -29,6 +29,7 @@ async def async_setup_entry(
if lock.is_door_sensor_activated:
entities.append(NukiDoorsensorEntity(entry_data.coordinator, lock))
entities.append(NukiBatteryCriticalEntity(entry_data.coordinator, lock))
entities.append(NukiBatteryChargingEntity(entry_data.coordinator, lock))
for opener in entry_data.openers:
entities.append(NukiRingactionEntity(entry_data.coordinator, opener))
@ -107,7 +108,6 @@ class NukiBatteryCriticalEntity(NukiEntity[NukiDevice], BinarySensorEntity):
"""Representation of Nuki Battery Critical."""
_attr_has_entity_name = True
_attr_translation_key = "battery_critical"
_attr_device_class = BinarySensorDeviceClass.BATTERY
_attr_entity_category = EntityCategory.DIAGNOSTIC
@ -118,5 +118,24 @@ class NukiBatteryCriticalEntity(NukiEntity[NukiDevice], BinarySensorEntity):
@property
def is_on(self) -> bool:
"""Return the value of the ring action state."""
"""Return the value of the battery critical."""
return self._nuki_device.battery_critical
class NukiBatteryChargingEntity(NukiEntity[NukiDevice], BinarySensorEntity):
"""Representation of a Nuki Battery charging."""
_attr_has_entity_name = True
_attr_device_class = BinarySensorDeviceClass.BATTERY_CHARGING
_attr_entity_category = EntityCategory.DIAGNOSTIC
_attr_entity_registry_enabled_default = False
@property
def unique_id(self) -> str:
"""Return a unique ID."""
return f"{self._nuki_device.nuki_id}_battery_charging"
@property
def is_on(self) -> bool:
"""Return the value of the battery charging."""
return self._nuki_device.battery_charging

View File

@ -12,5 +12,5 @@
"documentation": "https://www.home-assistant.io/integrations/nuki",
"iot_class": "local_polling",
"loggers": ["pynuki"],
"requirements": ["pynuki==1.6.2"]
"requirements": ["pynuki==1.6.3"]
}

View File

@ -41,9 +41,6 @@
"binary_sensor": {
"ring_action": {
"name": "Ring Action"
},
"battery_critical": {
"name": "Battery critical"
}
},
"lock": {

View File

@ -1992,7 +1992,7 @@ pynetio==0.1.9.1
pynobo==1.6.0
# homeassistant.components.nuki
pynuki==1.6.2
pynuki==1.6.3
# homeassistant.components.nut
pynut2==2.1.2

View File

@ -1537,7 +1537,7 @@ pynetgear==0.10.10
pynobo==1.6.0
# homeassistant.components.nuki
pynuki==1.6.2
pynuki==1.6.3
# homeassistant.components.nut
pynut2==2.1.2