Skip to content

Commit

Permalink
Merge branch 'main' of github.com:kvj/hass_nuki_ng into main
Browse files Browse the repository at this point in the history
  • Loading branch information
kvj committed Jan 12, 2022
2 parents 611fcab + 6074766 commit 3eabba4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
21 changes: 12 additions & 9 deletions custom_components/nuki_ng/button.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from homeassistant.components.button import ButtonEntity
from homeassistant.components.button import ButtonDeviceClass, ButtonEntity
from homeassistant.helpers.entity import EntityCategory

import logging

Expand All @@ -13,31 +14,33 @@ async def async_setup_entry(hass, entry, async_add_entities):
coordinator = hass.data[DOMAIN][entry.entry_id]

if coordinator.api.can_bridge():
entities.append(RebootBridge(coordinator))
entities.append(FWUpdateBridge(coordinator))
entities.append(NukiBridgeRestartButton(coordinator))
entities.append(NukiBridgeFWUpdateButton(coordinator))
async_add_entities(entities)
return True

class RebootBridge(NukiBridge, ButtonEntity):
class NukiBridgeRestartButton(NukiBridge, ButtonEntity):
"""Defines a Bridge restart button."""

def __init__(self, coordinator):
super().__init__(coordinator)
self.set_id("reboot")
self.set_name("Reboot")
self._attr_device_class = "restart"
self._attr_entity_category = "config"
self._attr_device_class = ButtonDeviceClass.RESTART
self._attr_entity_category = EntityCategory.CONFIG

async def async_press(self) -> None:
await self.coordinator.do_reboot()

class FWUpdateBridge(NukiBridge, ButtonEntity):
class NukiBridgeFWUpdateButton(NukiBridge, ButtonEntity):
"""Defines a Bridge update button."""

def __init__(self, coordinator):
super().__init__(coordinator)
self.set_id("fw_update")
self.set_name("Firmware Update")
self._attr_device_class = "update"
self._attr_entity_category = "config"
self._attr_device_class = ButtonDeviceClass.UPDATE
self._attr_entity_category = EntityCategory.CONFIG

async def async_press(self) -> None:
await self.coordinator.do_fwupdate()
3 changes: 2 additions & 1 deletion custom_components/nuki_ng/nuki.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ async def web_list_all_auths(self, dev_id: str):

async def web_list(self):
door_state_map = {1: "deactivated", 2: "door closed",
3: "door opened", 4: "door state unknown", 5: "calibrating"}
3: "door opened", 4: "door state unknown", 5: "calibrating",
16: "uncalibrated", 240: "removed", 255: "unknown"}
device_state_map = {
0: {0: "uncalibrated", 1: "locked", 2: "unlocking", 3: "unlocked", 4: "locking", 5: "unlatched", 6: "unlocked (lock 'n' go)", 7: "unlatching", 254: "motor blocked", 255: "undefined"},
2: {0: "untrained", 1: "online", 3: "ring to open active", 5: "open", 7: "opening", 253: "boot run", 255: "undefined"},
Expand Down
6 changes: 4 additions & 2 deletions custom_components/nuki_ng/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ class LockStates(BaseStates):


class DoorSensorStates(BaseStates):
UNAVAILABLE = 0
DEACTIVATED = 1
DOOR_CLOSED = 2
DOOR_OPENED = 3
UNKNOWN = 4
DOOR_UNKNOWN = 4
CALIBRATING = 5
UNCALIBRATED = 16
REMOVED = 240
UNKNOWN = 255


class DoorSecurityStates(BaseStates):
Expand Down

0 comments on commit 3eabba4

Please sign in to comment.