Update dynalite library and minor changes (#34618)
This commit is contained in:
parent
71617e8e8b
commit
4afa2a2651
8 changed files with 15 additions and 22 deletions
|
@ -117,7 +117,7 @@ AREA_DATA_SCHEMA = vol.Schema(
|
|||
vol.All(
|
||||
{
|
||||
vol.Required(CONF_NAME): cv.string,
|
||||
vol.Optional(CONF_TEMPLATE): cv.string,
|
||||
vol.Optional(CONF_TEMPLATE): vol.In(DEFAULT_TEMPLATES),
|
||||
vol.Optional(CONF_FADE): vol.Coerce(float),
|
||||
vol.Optional(CONF_NO_DEFAULT): cv.boolean,
|
||||
vol.Optional(CONF_CHANNEL): CHANNEL_SCHEMA,
|
||||
|
|
|
@ -1,21 +1,16 @@
|
|||
"""Code to handle a Dynalite bridge."""
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Callable, Dict, List
|
||||
from typing import Any, Callable, Dict, List, Optional
|
||||
|
||||
from dynalite_devices_lib.dynalite_devices import DynaliteDevices
|
||||
from dynalite_devices_lib.dynalite_devices import DynaliteBaseDevice, DynaliteDevices
|
||||
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
|
||||
from .const import CONF_ALL, ENTITY_PLATFORMS, LOGGER
|
||||
from .const import ENTITY_PLATFORMS, LOGGER
|
||||
from .convert_config import convert_config
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from dynalite_devices_lib.dynalite_devices import ( # pylint: disable=ungrouped-imports
|
||||
DynaliteBaseDevice,
|
||||
)
|
||||
|
||||
|
||||
class DynaliteBridge:
|
||||
"""Manages a single Dynalite bridge."""
|
||||
|
@ -45,7 +40,7 @@ class DynaliteBridge:
|
|||
LOGGER.debug("Reloading bridge - host %s, config %s", self.host, config)
|
||||
self.dynalite_devices.configure(convert_config(config))
|
||||
|
||||
def update_signal(self, device: "DynaliteBaseDevice" = None) -> str:
|
||||
def update_signal(self, device: Optional[DynaliteBaseDevice] = None) -> str:
|
||||
"""Create signal to use to trigger entity update."""
|
||||
if device:
|
||||
signal = f"dynalite-update-{self.host}-{device.unique_id}"
|
||||
|
@ -54,9 +49,9 @@ class DynaliteBridge:
|
|||
return signal
|
||||
|
||||
@callback
|
||||
def update_device(self, device: "DynaliteBaseDevice") -> None:
|
||||
def update_device(self, device: Optional[DynaliteBaseDevice] = None) -> None:
|
||||
"""Call when a device or all devices should be updated."""
|
||||
if device == CONF_ALL:
|
||||
if not device:
|
||||
# This is used to signal connection or disconnection, so all devices may become available or not.
|
||||
log_string = (
|
||||
"Connected" if self.dynalite_devices.connected else "Disconnected"
|
||||
|
@ -73,7 +68,7 @@ class DynaliteBridge:
|
|||
if platform in self.waiting_devices:
|
||||
self.async_add_devices[platform](self.waiting_devices[platform])
|
||||
|
||||
def add_devices_when_registered(self, devices: List["DynaliteBaseDevice"]) -> None:
|
||||
def add_devices_when_registered(self, devices: List[DynaliteBaseDevice]) -> None:
|
||||
"""Add the devices to HA if the add devices callback was registered, otherwise queue until it is."""
|
||||
for platform in ENTITY_PLATFORMS:
|
||||
platform_devices = [
|
||||
|
|
|
@ -14,7 +14,6 @@ CONF_ACTIVE = "active"
|
|||
ACTIVE_INIT = "init"
|
||||
ACTIVE_OFF = "off"
|
||||
ACTIVE_ON = "on"
|
||||
CONF_ALL = "ALL"
|
||||
CONF_AREA = "area"
|
||||
CONF_AUTO_DISCOVER = "autodiscover"
|
||||
CONF_BRIDGES = "bridges"
|
||||
|
|
|
@ -34,9 +34,9 @@ from .const import (
|
|||
|
||||
CONF_MAP = {
|
||||
CONF_ACTIVE: dyn_const.CONF_ACTIVE,
|
||||
ACTIVE_INIT: dyn_const.CONF_ACTIVE_INIT,
|
||||
ACTIVE_OFF: dyn_const.CONF_ACTIVE_OFF,
|
||||
ACTIVE_ON: dyn_const.CONF_ACTIVE_ON,
|
||||
ACTIVE_INIT: dyn_const.ACTIVE_INIT,
|
||||
ACTIVE_OFF: dyn_const.ACTIVE_OFF,
|
||||
ACTIVE_ON: dyn_const.ACTIVE_ON,
|
||||
CONF_AREA: dyn_const.CONF_AREA,
|
||||
CONF_AUTO_DISCOVER: dyn_const.CONF_AUTO_DISCOVER,
|
||||
CONF_CHANNEL: dyn_const.CONF_CHANNEL,
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/dynalite",
|
||||
"codeowners": ["@ziv1234"],
|
||||
"requirements": ["dynalite_devices==0.1.39"]
|
||||
"requirements": ["dynalite_devices==0.1.40"]
|
||||
}
|
||||
|
|
|
@ -481,7 +481,7 @@ dsmr_parser==0.18
|
|||
dweepy==0.3.0
|
||||
|
||||
# homeassistant.components.dynalite
|
||||
dynalite_devices==0.1.39
|
||||
dynalite_devices==0.1.40
|
||||
|
||||
# homeassistant.components.rainforest_eagle
|
||||
eagle200_reader==0.2.4
|
||||
|
|
|
@ -197,7 +197,7 @@ doorbirdpy==2.0.8
|
|||
dsmr_parser==0.18
|
||||
|
||||
# homeassistant.components.dynalite
|
||||
dynalite_devices==0.1.39
|
||||
dynalite_devices==0.1.40
|
||||
|
||||
# homeassistant.components.ee_brightbox
|
||||
eebrightbox==0.0.4
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
"""Test Dynalite bridge."""
|
||||
|
||||
from asynctest import CoroutineMock, Mock, patch
|
||||
from dynalite_devices_lib.const import CONF_ALL
|
||||
|
||||
from homeassistant.components import dynalite
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
@ -29,7 +28,7 @@ async def test_update_device(hass):
|
|||
async_dispatcher_connect(
|
||||
hass, f"dynalite-update-{host}-{device.unique_id}", specific_func
|
||||
)
|
||||
update_device_func(CONF_ALL)
|
||||
update_device_func()
|
||||
await hass.async_block_till_done()
|
||||
wide_func.assert_called_once()
|
||||
specific_func.assert_not_called()
|
||||
|
|
Loading…
Add table
Reference in a new issue