-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add button entities for bridge reboot and FW update
- Loading branch information
Showing
4 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from homeassistant.components.button import ButtonEntity | ||
|
||
import logging | ||
|
||
from . import NukiBridge | ||
from .constants import DOMAIN | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
async def async_setup_entry(hass, entry, async_add_entities): | ||
entities = [] | ||
data = entry.as_dict() | ||
coordinator = hass.data[DOMAIN][entry.entry_id] | ||
|
||
if coordinator.api.can_bridge(): | ||
entities.append(RebootBridge(coordinator)) | ||
entities.append(FWUpdateBridge(coordinator)) | ||
async_add_entities(entities) | ||
return True | ||
|
||
class RebootBridge(NukiBridge, ButtonEntity): | ||
|
||
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" | ||
|
||
async def async_press(self) -> None: | ||
await self.coordinator.do_reboot() | ||
|
||
class FWUpdateBridge(NukiBridge, ButtonEntity): | ||
|
||
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" | ||
|
||
async def async_press(self) -> None: | ||
await self.coordinator.do_fwupdate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
DOMAIN = "nuki_ng" | ||
PLATFORMS = ["binary_sensor", "sensor", "lock", "switch"] | ||
PLATFORMS = ["binary_sensor", "sensor", "lock", "switch", "button"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ | |
"requirements": [], | ||
"iot_class": "local_polling", | ||
"config_flow": true, | ||
"version": "0.1.0" | ||
"version": "0.2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "Nuki Lock", | ||
"domains": ["lock", "sensor"], | ||
"homeassistant": "2021.11.1", | ||
"homeassistant": "2021.12.1", | ||
"render_readme": true | ||
} |