mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 10:48:01 +02:00
Universal Powerline Bus -- Link Events (#35526)
* Universal Powerline Bus - Link Event * Bump lib version. * Update homeassistant/components/upb/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
@ -8,7 +8,14 @@ from homeassistant.core import HomeAssistant, callback
|
|||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import (
|
||||||
|
ATTR_ADDRESS,
|
||||||
|
ATTR_BRIGHTNESS_PCT,
|
||||||
|
ATTR_COMMAND,
|
||||||
|
ATTR_RATE,
|
||||||
|
DOMAIN,
|
||||||
|
EVENT_UPB_LINK_CHANGED,
|
||||||
|
)
|
||||||
|
|
||||||
UPB_PLATFORMS = ["light", "scene"]
|
UPB_PLATFORMS = ["light", "scene"]
|
||||||
|
|
||||||
@ -34,6 +41,27 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
hass.config_entries.async_forward_entry_setup(config_entry, component)
|
hass.config_entries.async_forward_entry_setup(config_entry, component)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _element_changed(element, changeset):
|
||||||
|
change = changeset.get("last_change")
|
||||||
|
if change is None:
|
||||||
|
return
|
||||||
|
if change.get("command") is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
hass.bus.async_fire(
|
||||||
|
EVENT_UPB_LINK_CHANGED,
|
||||||
|
{
|
||||||
|
ATTR_COMMAND: change["command"],
|
||||||
|
ATTR_ADDRESS: element.addr.index,
|
||||||
|
ATTR_BRIGHTNESS_PCT: change.get("level", -1),
|
||||||
|
ATTR_RATE: change.get("rate", -1),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
for link in upb.links:
|
||||||
|
element = upb.links[link]
|
||||||
|
element.add_callback(_element_changed)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,13 +4,17 @@ import voluptuous as vol
|
|||||||
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
CONF_NETWORK = "network"
|
|
||||||
DOMAIN = "upb"
|
DOMAIN = "upb"
|
||||||
|
|
||||||
|
ATTR_ADDRESS = "address"
|
||||||
ATTR_BLINK_RATE = "blink_rate"
|
ATTR_BLINK_RATE = "blink_rate"
|
||||||
ATTR_BRIGHTNESS = "brightness"
|
ATTR_BRIGHTNESS = "brightness"
|
||||||
ATTR_BRIGHTNESS_PCT = "brightness_pct"
|
ATTR_BRIGHTNESS_PCT = "brightness_pct"
|
||||||
|
ATTR_COMMAND = "command"
|
||||||
ATTR_RATE = "rate"
|
ATTR_RATE = "rate"
|
||||||
|
CONF_NETWORK = "network"
|
||||||
|
EVENT_UPB_LINK_CHANGED = "upb.link_changed"
|
||||||
|
|
||||||
VALID_BRIGHTNESS = vol.All(vol.Coerce(int), vol.Clamp(min=0, max=255))
|
VALID_BRIGHTNESS = vol.All(vol.Coerce(int), vol.Clamp(min=0, max=255))
|
||||||
VALID_BRIGHTNESS_PCT = vol.All(vol.Coerce(float), vol.Range(min=0, max=100))
|
VALID_BRIGHTNESS_PCT = vol.All(vol.Coerce(float), vol.Range(min=0, max=100))
|
||||||
VALID_RATE = vol.All(vol.Coerce(float), vol.Clamp(min=-1, max=3600))
|
VALID_RATE = vol.All(vol.Coerce(float), vol.Clamp(min=-1, max=3600))
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"domain": "upb",
|
"domain": "upb",
|
||||||
"name": "Universal Powerline Bus (UPB)",
|
"name": "Universal Powerline Bus (UPB)",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/upb",
|
"documentation": "https://www.home-assistant.io/integrations/upb",
|
||||||
"requirements": ["upb_lib==0.4.10"],
|
"requirements": ["upb_lib==0.4.11"],
|
||||||
"codeowners": ["@gwww"],
|
"codeowners": ["@gwww"],
|
||||||
"config_flow": true
|
"config_flow": true
|
||||||
}
|
}
|
||||||
|
@ -2114,7 +2114,7 @@ uEagle==0.0.1
|
|||||||
unifiled==0.11
|
unifiled==0.11
|
||||||
|
|
||||||
# homeassistant.components.upb
|
# homeassistant.components.upb
|
||||||
upb_lib==0.4.10
|
upb_lib==0.4.11
|
||||||
|
|
||||||
# homeassistant.components.upcloud
|
# homeassistant.components.upcloud
|
||||||
upcloud-api==0.4.5
|
upcloud-api==0.4.5
|
||||||
|
@ -844,7 +844,7 @@ twentemilieu==0.3.0
|
|||||||
twilio==6.32.0
|
twilio==6.32.0
|
||||||
|
|
||||||
# homeassistant.components.upb
|
# homeassistant.components.upb
|
||||||
upb_lib==0.4.10
|
upb_lib==0.4.11
|
||||||
|
|
||||||
# homeassistant.components.huawei_lte
|
# homeassistant.components.huawei_lte
|
||||||
url-normalize==1.4.1
|
url-normalize==1.4.1
|
||||||
|
Reference in New Issue
Block a user