Skip to content

Commit

Permalink
Nuki add binary sensor for battery charging (home-assistant#111320)
Browse files Browse the repository at this point in the history
* Nuki binary sensors

* disable by default
  • Loading branch information
steffenrapp authored Feb 25, 2024
1 parent 7d37aea commit 1362153
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
23 changes: 21 additions & 2 deletions homeassistant/components/nuki/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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

Expand All @@ -118,5 +118,24 @@ def unique_id(self) -> str:

@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
2 changes: 1 addition & 1 deletion homeassistant/components/nuki/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
3 changes: 0 additions & 3 deletions homeassistant/components/nuki/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
"binary_sensor": {
"ring_action": {
"name": "Ring Action"
},
"battery_critical": {
"name": "Battery critical"
}
},
"lock": {
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1362153

Please sign in to comment.