mirror of
https://github.com/home-assistant/core.git
synced 2025-10-28 13:09:26 +00:00
Compare commits
148 Commits
media-sour
...
2025.10.0b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cd1283b00 | ||
|
|
dde60cdecb | ||
|
|
f03b16bdf8 | ||
|
|
f616e5a4e3 | ||
|
|
c0317f60cc | ||
|
|
8abfe424e1 | ||
|
|
8de200de0b | ||
|
|
f242e294be | ||
|
|
58cc7c8f84 | ||
|
|
bd10f6ec08 | ||
|
|
ed9cfb4c4b | ||
|
|
a6b6e4c4b8 | ||
|
|
36ff5c0d45 | ||
|
|
de6d34fec5 | ||
|
|
38f9067970 | ||
|
|
53a8a250d0 | ||
|
|
00f6d26ede | ||
|
|
6d09411c07 | ||
|
|
037e2bfd31 | ||
|
|
c893552d4a | ||
|
|
4fd10162c9 | ||
|
|
392ee5ae7e | ||
|
|
bf190609a0 | ||
|
|
e982ac1e53 | ||
|
|
b4747ea87b | ||
|
|
df69bcecb7 | ||
|
|
c75dca743a | ||
|
|
00d667ed51 | ||
|
|
51e098e807 | ||
|
|
5e2b27699e | ||
|
|
be942c2888 | ||
|
|
584c1fbd97 | ||
|
|
abc5c6e2b4 | ||
|
|
d9de964035 | ||
|
|
bb02158d1a | ||
|
|
be10f097c7 | ||
|
|
7084bca783 | ||
|
|
cd6f3a0fe5 | ||
|
|
af2888331d | ||
|
|
b92e5d7131 | ||
|
|
f7265c85d0 | ||
|
|
8466dbf69f | ||
|
|
2dd0d69bcd | ||
|
|
6783c4ad83 | ||
|
|
07d7f4e18d | ||
|
|
54b1749986 | ||
|
|
eaf264361f | ||
|
|
d8f6f17a4f | ||
|
|
9a969cea63 | ||
|
|
ef16327b2b | ||
|
|
a6a6261168 | ||
|
|
a01eb48db8 | ||
|
|
eb103a8d9a | ||
|
|
2b5f989855 | ||
|
|
4e247a6ebe | ||
|
|
77f897a768 | ||
|
|
4f0a6ef9a1 | ||
|
|
66c6b0f5fc | ||
|
|
dd01243391 | ||
|
|
66c17e250a | ||
|
|
723902e233 | ||
|
|
59fdb9f3b5 | ||
|
|
d83502514a | ||
|
|
08e81b2ba6 | ||
|
|
1e808c965d | ||
|
|
563b58c9aa | ||
|
|
cf223880e8 | ||
|
|
4058ca59ed | ||
|
|
1386c01733 | ||
|
|
46504947f7 | ||
|
|
0a44682014 | ||
|
|
06a57473a9 | ||
|
|
fbed66ef1f | ||
|
|
99a0380ec5 | ||
|
|
68c51dc7aa | ||
|
|
3d945b0fc5 | ||
|
|
7b26a93d38 | ||
|
|
1b2eab00be | ||
|
|
750e849f09 | ||
|
|
6aaddad56b | ||
|
|
a5af974209 | ||
|
|
09e45f6f54 | ||
|
|
d857d8850c | ||
|
|
ccc50f2412 | ||
|
|
3905723900 | ||
|
|
cee88473a2 | ||
|
|
cdf613d3f8 | ||
|
|
156a0f1a3d | ||
|
|
cc2a5b43dd | ||
|
|
731064f7e9 | ||
|
|
2f75661c20 | ||
|
|
be6f056f30 | ||
|
|
79599e1284 | ||
|
|
a255585ab6 | ||
|
|
e9bde225fe | ||
|
|
d9521ac2a0 | ||
|
|
d8b24ccccd | ||
|
|
b4417a76d5 | ||
|
|
274f6eb54a | ||
|
|
21a5aaf35c | ||
|
|
05820a49d0 | ||
|
|
17b12d29af | ||
|
|
9cc78680d6 | ||
|
|
14d42e43bf | ||
|
|
ed5f5d4b33 | ||
|
|
c3ba086fad | ||
|
|
7b5314605c | ||
|
|
3a806d6603 | ||
|
|
6dd33f900d | ||
|
|
2844bd474a | ||
|
|
d865fcf999 | ||
|
|
79a2fc5a01 | ||
|
|
19d87abb8a | ||
|
|
c4de46a85b | ||
|
|
e79a434d9b | ||
|
|
9a801424c7 | ||
|
|
5cb186980a | ||
|
|
1629ade97f | ||
|
|
ccf0011ac2 | ||
|
|
70077511a3 | ||
|
|
dfbaf66021 | ||
|
|
62cea48a58 | ||
|
|
c493c7dd67 | ||
|
|
fdaceaddfd | ||
|
|
a2f4073d54 | ||
|
|
2d01a99ec2 | ||
|
|
311d4c4262 | ||
|
|
e14f5ba44d | ||
|
|
9babc85517 | ||
|
|
332a3fad3c | ||
|
|
8782aa4f60 | ||
|
|
475b84cc5f | ||
|
|
0f904d418b | ||
|
|
4ea4eec2d8 | ||
|
|
afefa16615 | ||
|
|
1dccbee45c | ||
|
|
711a56db2f | ||
|
|
9d1c7dadff | ||
|
|
7d1953e387 | ||
|
|
023ecf2a64 | ||
|
|
934db458a3 | ||
|
|
0a6ae3b52a | ||
|
|
bdd0b74d51 | ||
|
|
8837f2aca7 | ||
|
|
403cd2d8ef | ||
|
|
ddfc528d63 | ||
|
|
ddea2206c3 | ||
|
|
32aacac550 |
@@ -58,6 +58,7 @@ base_platforms: &base_platforms
|
|||||||
# Extra components that trigger the full suite
|
# Extra components that trigger the full suite
|
||||||
components: &components
|
components: &components
|
||||||
- homeassistant/components/alexa/**
|
- homeassistant/components/alexa/**
|
||||||
|
- homeassistant/components/analytics/**
|
||||||
- homeassistant/components/application_credentials/**
|
- homeassistant/components/application_credentials/**
|
||||||
- homeassistant/components/assist_pipeline/**
|
- homeassistant/components/assist_pipeline/**
|
||||||
- homeassistant/components/auth/**
|
- homeassistant/components/auth/**
|
||||||
|
|||||||
4
.github/workflows/wheels.yml
vendored
4
.github/workflows/wheels.yml
vendored
@@ -160,7 +160,7 @@ jobs:
|
|||||||
|
|
||||||
# home-assistant/wheels doesn't support sha pinning
|
# home-assistant/wheels doesn't support sha pinning
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
uses: home-assistant/wheels@2025.07.0
|
uses: home-assistant/wheels@2025.09.1
|
||||||
with:
|
with:
|
||||||
abi: ${{ matrix.abi }}
|
abi: ${{ matrix.abi }}
|
||||||
tag: musllinux_1_2
|
tag: musllinux_1_2
|
||||||
@@ -221,7 +221,7 @@ jobs:
|
|||||||
|
|
||||||
# home-assistant/wheels doesn't support sha pinning
|
# home-assistant/wheels doesn't support sha pinning
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
uses: home-assistant/wheels@2025.07.0
|
uses: home-assistant/wheels@2025.09.1
|
||||||
with:
|
with:
|
||||||
abi: ${{ matrix.abi }}
|
abi: ${{ matrix.abi }}
|
||||||
tag: musllinux_1_2
|
tag: musllinux_1_2
|
||||||
|
|||||||
@@ -443,6 +443,7 @@ homeassistant.components.rituals_perfume_genie.*
|
|||||||
homeassistant.components.roborock.*
|
homeassistant.components.roborock.*
|
||||||
homeassistant.components.roku.*
|
homeassistant.components.roku.*
|
||||||
homeassistant.components.romy.*
|
homeassistant.components.romy.*
|
||||||
|
homeassistant.components.route_b_smart_meter.*
|
||||||
homeassistant.components.rpi_power.*
|
homeassistant.components.rpi_power.*
|
||||||
homeassistant.components.rss_feed_template.*
|
homeassistant.components.rss_feed_template.*
|
||||||
homeassistant.components.russound_rio.*
|
homeassistant.components.russound_rio.*
|
||||||
|
|||||||
8
CODEOWNERS
generated
8
CODEOWNERS
generated
@@ -316,6 +316,8 @@ build.json @home-assistant/supervisor
|
|||||||
/tests/components/crownstone/ @Crownstone @RicArch97
|
/tests/components/crownstone/ @Crownstone @RicArch97
|
||||||
/homeassistant/components/cups/ @fabaff
|
/homeassistant/components/cups/ @fabaff
|
||||||
/tests/components/cups/ @fabaff
|
/tests/components/cups/ @fabaff
|
||||||
|
/homeassistant/components/cync/ @Kinachi249
|
||||||
|
/tests/components/cync/ @Kinachi249
|
||||||
/homeassistant/components/daikin/ @fredrike
|
/homeassistant/components/daikin/ @fredrike
|
||||||
/tests/components/daikin/ @fredrike
|
/tests/components/daikin/ @fredrike
|
||||||
/homeassistant/components/date/ @home-assistant/core
|
/homeassistant/components/date/ @home-assistant/core
|
||||||
@@ -410,6 +412,8 @@ build.json @home-assistant/supervisor
|
|||||||
/homeassistant/components/egardia/ @jeroenterheerdt
|
/homeassistant/components/egardia/ @jeroenterheerdt
|
||||||
/homeassistant/components/eheimdigital/ @autinerd
|
/homeassistant/components/eheimdigital/ @autinerd
|
||||||
/tests/components/eheimdigital/ @autinerd
|
/tests/components/eheimdigital/ @autinerd
|
||||||
|
/homeassistant/components/ekeybionyx/ @richardpolzer
|
||||||
|
/tests/components/ekeybionyx/ @richardpolzer
|
||||||
/homeassistant/components/electrasmart/ @jafar-atili
|
/homeassistant/components/electrasmart/ @jafar-atili
|
||||||
/tests/components/electrasmart/ @jafar-atili
|
/tests/components/electrasmart/ @jafar-atili
|
||||||
/homeassistant/components/electric_kiwi/ @mikey0000
|
/homeassistant/components/electric_kiwi/ @mikey0000
|
||||||
@@ -972,8 +976,6 @@ build.json @home-assistant/supervisor
|
|||||||
/tests/components/moat/ @bdraco
|
/tests/components/moat/ @bdraco
|
||||||
/homeassistant/components/mobile_app/ @home-assistant/core
|
/homeassistant/components/mobile_app/ @home-assistant/core
|
||||||
/tests/components/mobile_app/ @home-assistant/core
|
/tests/components/mobile_app/ @home-assistant/core
|
||||||
/homeassistant/components/modbus/ @janiversen
|
|
||||||
/tests/components/modbus/ @janiversen
|
|
||||||
/homeassistant/components/modem_callerid/ @tkdrob
|
/homeassistant/components/modem_callerid/ @tkdrob
|
||||||
/tests/components/modem_callerid/ @tkdrob
|
/tests/components/modem_callerid/ @tkdrob
|
||||||
/homeassistant/components/modern_forms/ @wonderslug
|
/homeassistant/components/modern_forms/ @wonderslug
|
||||||
@@ -1332,6 +1334,8 @@ build.json @home-assistant/supervisor
|
|||||||
/tests/components/roomba/ @pschmitt @cyr-ius @shenxn @Orhideous
|
/tests/components/roomba/ @pschmitt @cyr-ius @shenxn @Orhideous
|
||||||
/homeassistant/components/roon/ @pavoni
|
/homeassistant/components/roon/ @pavoni
|
||||||
/tests/components/roon/ @pavoni
|
/tests/components/roon/ @pavoni
|
||||||
|
/homeassistant/components/route_b_smart_meter/ @SeraphicRav
|
||||||
|
/tests/components/route_b_smart_meter/ @SeraphicRav
|
||||||
/homeassistant/components/rpi_power/ @shenxn @swetoast
|
/homeassistant/components/rpi_power/ @shenxn @swetoast
|
||||||
/tests/components/rpi_power/ @shenxn @swetoast
|
/tests/components/rpi_power/ @shenxn @swetoast
|
||||||
/homeassistant/components/rss_feed_template/ @home-assistant/core
|
/homeassistant/components/rss_feed_template/ @home-assistant/core
|
||||||
|
|||||||
10
build.yaml
10
build.yaml
@@ -1,10 +1,10 @@
|
|||||||
image: ghcr.io/home-assistant/{arch}-homeassistant
|
image: ghcr.io/home-assistant/{arch}-homeassistant
|
||||||
build_from:
|
build_from:
|
||||||
aarch64: ghcr.io/home-assistant/aarch64-homeassistant-base:2025.09.1
|
aarch64: ghcr.io/home-assistant/aarch64-homeassistant-base:2025.09.3
|
||||||
armhf: ghcr.io/home-assistant/armhf-homeassistant-base:2025.09.1
|
armhf: ghcr.io/home-assistant/armhf-homeassistant-base:2025.09.3
|
||||||
armv7: ghcr.io/home-assistant/armv7-homeassistant-base:2025.09.1
|
armv7: ghcr.io/home-assistant/armv7-homeassistant-base:2025.09.3
|
||||||
amd64: ghcr.io/home-assistant/amd64-homeassistant-base:2025.09.1
|
amd64: ghcr.io/home-assistant/amd64-homeassistant-base:2025.09.3
|
||||||
i386: ghcr.io/home-assistant/i386-homeassistant-base:2025.09.1
|
i386: ghcr.io/home-assistant/i386-homeassistant-base:2025.09.3
|
||||||
codenotary:
|
codenotary:
|
||||||
signer: notary@home-assistant.io
|
signer: notary@home-assistant.io
|
||||||
base_image: notary@home-assistant.io
|
base_image: notary@home-assistant.io
|
||||||
|
|||||||
5
homeassistant/brands/eltako.json
Normal file
5
homeassistant/brands/eltako.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"domain": "eltako",
|
||||||
|
"name": "Eltako",
|
||||||
|
"iot_standards": ["matter"]
|
||||||
|
}
|
||||||
5
homeassistant/brands/konnected.json
Normal file
5
homeassistant/brands/konnected.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"domain": "konnected",
|
||||||
|
"name": "Konnected",
|
||||||
|
"integrations": ["konnected", "konnected_esphome"]
|
||||||
|
}
|
||||||
5
homeassistant/brands/level.json
Normal file
5
homeassistant/brands/level.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"domain": "level",
|
||||||
|
"name": "Level",
|
||||||
|
"iot_standards": ["matter"]
|
||||||
|
}
|
||||||
@@ -4,11 +4,9 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import cast
|
|
||||||
|
|
||||||
from aioacaia.acaiascale import AcaiaScale
|
from aioacaia.acaiascale import AcaiaScale
|
||||||
from aioacaia.exceptions import AcaiaDeviceNotFound, AcaiaError
|
from aioacaia.exceptions import AcaiaDeviceNotFound, AcaiaError
|
||||||
from bleak import BleakScanner
|
|
||||||
|
|
||||||
from homeassistant.components.bluetooth import async_get_scanner
|
from homeassistant.components.bluetooth import async_get_scanner
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@@ -45,7 +43,7 @@ class AcaiaCoordinator(DataUpdateCoordinator[None]):
|
|||||||
name=entry.title,
|
name=entry.title,
|
||||||
is_new_style_scale=entry.data[CONF_IS_NEW_STYLE_SCALE],
|
is_new_style_scale=entry.data[CONF_IS_NEW_STYLE_SCALE],
|
||||||
notify_callback=self.async_update_listeners,
|
notify_callback=self.async_update_listeners,
|
||||||
scanner=cast(BleakScanner, async_get_scanner(hass)),
|
scanner=async_get_scanner(hass),
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -7,5 +7,5 @@
|
|||||||
"integration_type": "service",
|
"integration_type": "service",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["accuweather"],
|
"loggers": ["accuweather"],
|
||||||
"requirements": ["accuweather==4.2.1"]
|
"requirements": ["accuweather==4.2.2"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,18 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from airos.airos8 import AirOS8
|
from airos.airos8 import AirOS8
|
||||||
|
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platform
|
from homeassistant.const import (
|
||||||
|
CONF_HOST,
|
||||||
|
CONF_PASSWORD,
|
||||||
|
CONF_SSL,
|
||||||
|
CONF_USERNAME,
|
||||||
|
CONF_VERIFY_SSL,
|
||||||
|
Platform,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
|
from .const import DEFAULT_SSL, DEFAULT_VERIFY_SSL, SECTION_ADVANCED_SETTINGS
|
||||||
from .coordinator import AirOSConfigEntry, AirOSDataUpdateCoordinator
|
from .coordinator import AirOSConfigEntry, AirOSDataUpdateCoordinator
|
||||||
|
|
||||||
_PLATFORMS: list[Platform] = [
|
_PLATFORMS: list[Platform] = [
|
||||||
@@ -21,13 +29,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: AirOSConfigEntry) -> boo
|
|||||||
|
|
||||||
# By default airOS 8 comes with self-signed SSL certificates,
|
# By default airOS 8 comes with self-signed SSL certificates,
|
||||||
# with no option in the web UI to change or upload a custom certificate.
|
# with no option in the web UI to change or upload a custom certificate.
|
||||||
session = async_get_clientsession(hass, verify_ssl=False)
|
session = async_get_clientsession(
|
||||||
|
hass, verify_ssl=entry.data[SECTION_ADVANCED_SETTINGS][CONF_VERIFY_SSL]
|
||||||
|
)
|
||||||
|
|
||||||
airos_device = AirOS8(
|
airos_device = AirOS8(
|
||||||
host=entry.data[CONF_HOST],
|
host=entry.data[CONF_HOST],
|
||||||
username=entry.data[CONF_USERNAME],
|
username=entry.data[CONF_USERNAME],
|
||||||
password=entry.data[CONF_PASSWORD],
|
password=entry.data[CONF_PASSWORD],
|
||||||
session=session,
|
session=session,
|
||||||
|
use_ssl=entry.data[SECTION_ADVANCED_SETTINGS][CONF_SSL],
|
||||||
)
|
)
|
||||||
|
|
||||||
coordinator = AirOSDataUpdateCoordinator(hass, entry, airos_device)
|
coordinator = AirOSDataUpdateCoordinator(hass, entry, airos_device)
|
||||||
@@ -40,6 +51,30 @@ async def async_setup_entry(hass: HomeAssistant, entry: AirOSConfigEntry) -> boo
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
async def async_migrate_entry(hass: HomeAssistant, entry: AirOSConfigEntry) -> bool:
|
||||||
|
"""Migrate old config entry."""
|
||||||
|
|
||||||
|
if entry.version > 1:
|
||||||
|
# This means the user has downgraded from a future version
|
||||||
|
return False
|
||||||
|
|
||||||
|
if entry.version == 1 and entry.minor_version == 1:
|
||||||
|
new_data = {**entry.data}
|
||||||
|
advanced_data = {
|
||||||
|
CONF_SSL: DEFAULT_SSL,
|
||||||
|
CONF_VERIFY_SSL: DEFAULT_VERIFY_SSL,
|
||||||
|
}
|
||||||
|
new_data[SECTION_ADVANCED_SETTINGS] = advanced_data
|
||||||
|
|
||||||
|
hass.config_entries.async_update_entry(
|
||||||
|
entry,
|
||||||
|
data=new_data,
|
||||||
|
minor_version=2,
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: AirOSConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: AirOSConfigEntry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
return await hass.config_entries.async_unload_platforms(entry, _PLATFORMS)
|
return await hass.config_entries.async_unload_platforms(entry, _PLATFORMS)
|
||||||
|
|||||||
@@ -15,10 +15,17 @@ from airos.exceptions import (
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import (
|
||||||
|
CONF_HOST,
|
||||||
|
CONF_PASSWORD,
|
||||||
|
CONF_SSL,
|
||||||
|
CONF_USERNAME,
|
||||||
|
CONF_VERIFY_SSL,
|
||||||
|
)
|
||||||
|
from homeassistant.data_entry_flow import section
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DEFAULT_SSL, DEFAULT_VERIFY_SSL, DOMAIN, SECTION_ADVANCED_SETTINGS
|
||||||
from .coordinator import AirOS8
|
from .coordinator import AirOS8
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@@ -28,6 +35,15 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
|
|||||||
vol.Required(CONF_HOST): str,
|
vol.Required(CONF_HOST): str,
|
||||||
vol.Required(CONF_USERNAME, default="ubnt"): str,
|
vol.Required(CONF_USERNAME, default="ubnt"): str,
|
||||||
vol.Required(CONF_PASSWORD): str,
|
vol.Required(CONF_PASSWORD): str,
|
||||||
|
vol.Required(SECTION_ADVANCED_SETTINGS): section(
|
||||||
|
vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Required(CONF_SSL, default=DEFAULT_SSL): bool,
|
||||||
|
vol.Required(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL): bool,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
{"collapsed": True},
|
||||||
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -36,6 +52,7 @@ class AirOSConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle a config flow for Ubiquiti airOS."""
|
"""Handle a config flow for Ubiquiti airOS."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
MINOR_VERSION = 2
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self,
|
self,
|
||||||
@@ -46,13 +63,17 @@ class AirOSConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
# By default airOS 8 comes with self-signed SSL certificates,
|
# By default airOS 8 comes with self-signed SSL certificates,
|
||||||
# with no option in the web UI to change or upload a custom certificate.
|
# with no option in the web UI to change or upload a custom certificate.
|
||||||
session = async_get_clientsession(self.hass, verify_ssl=False)
|
session = async_get_clientsession(
|
||||||
|
self.hass,
|
||||||
|
verify_ssl=user_input[SECTION_ADVANCED_SETTINGS][CONF_VERIFY_SSL],
|
||||||
|
)
|
||||||
|
|
||||||
airos_device = AirOS8(
|
airos_device = AirOS8(
|
||||||
host=user_input[CONF_HOST],
|
host=user_input[CONF_HOST],
|
||||||
username=user_input[CONF_USERNAME],
|
username=user_input[CONF_USERNAME],
|
||||||
password=user_input[CONF_PASSWORD],
|
password=user_input[CONF_PASSWORD],
|
||||||
session=session,
|
session=session,
|
||||||
|
use_ssl=user_input[SECTION_ADVANCED_SETTINGS][CONF_SSL],
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
await airos_device.login()
|
await airos_device.login()
|
||||||
|
|||||||
@@ -7,3 +7,8 @@ DOMAIN = "airos"
|
|||||||
SCAN_INTERVAL = timedelta(minutes=1)
|
SCAN_INTERVAL = timedelta(minutes=1)
|
||||||
|
|
||||||
MANUFACTURER = "Ubiquiti"
|
MANUFACTURER = "Ubiquiti"
|
||||||
|
|
||||||
|
DEFAULT_VERIFY_SSL = False
|
||||||
|
DEFAULT_SSL = True
|
||||||
|
|
||||||
|
SECTION_ADVANCED_SETTINGS = "advanced_settings"
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST, CONF_SSL
|
||||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
|
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from .const import DOMAIN, MANUFACTURER
|
from .const import DOMAIN, MANUFACTURER, SECTION_ADVANCED_SETTINGS
|
||||||
from .coordinator import AirOSDataUpdateCoordinator
|
from .coordinator import AirOSDataUpdateCoordinator
|
||||||
|
|
||||||
|
|
||||||
@@ -20,9 +20,14 @@ class AirOSEntity(CoordinatorEntity[AirOSDataUpdateCoordinator]):
|
|||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
|
|
||||||
airos_data = self.coordinator.data
|
airos_data = self.coordinator.data
|
||||||
|
url_schema = (
|
||||||
|
"https"
|
||||||
|
if coordinator.config_entry.data[SECTION_ADVANCED_SETTINGS][CONF_SSL]
|
||||||
|
else "http"
|
||||||
|
)
|
||||||
|
|
||||||
configuration_url: str | None = (
|
configuration_url: str | None = (
|
||||||
f"https://{coordinator.config_entry.data[CONF_HOST]}"
|
f"{url_schema}://{coordinator.config_entry.data[CONF_HOST]}"
|
||||||
)
|
)
|
||||||
|
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
|
|||||||
@@ -12,6 +12,18 @@
|
|||||||
"host": "IP address or hostname of the airOS device",
|
"host": "IP address or hostname of the airOS device",
|
||||||
"username": "Administrator username for the airOS device, normally 'ubnt'",
|
"username": "Administrator username for the airOS device, normally 'ubnt'",
|
||||||
"password": "Password configured through the UISP app or web interface"
|
"password": "Password configured through the UISP app or web interface"
|
||||||
|
},
|
||||||
|
"sections": {
|
||||||
|
"advanced_settings": {
|
||||||
|
"data": {
|
||||||
|
"ssl": "Use HTTPS",
|
||||||
|
"verify_ssl": "[%key:common::config_flow::data::verify_ssl%]"
|
||||||
|
},
|
||||||
|
"data_description": {
|
||||||
|
"ssl": "Whether the connection should be encrypted (required for most devices)",
|
||||||
|
"verify_ssl": "Whether the certificate should be verified when using HTTPS. This should be off for self-signed certificates"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,17 +6,19 @@ from collections.abc import Callable
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, Final
|
from typing import Any, Final
|
||||||
|
|
||||||
from aioairzone.common import GrilleAngle, OperationMode, SleepTimeout
|
from aioairzone.common import GrilleAngle, OperationMode, QAdapt, SleepTimeout
|
||||||
from aioairzone.const import (
|
from aioairzone.const import (
|
||||||
API_COLD_ANGLE,
|
API_COLD_ANGLE,
|
||||||
API_HEAT_ANGLE,
|
API_HEAT_ANGLE,
|
||||||
API_MODE,
|
API_MODE,
|
||||||
|
API_Q_ADAPT,
|
||||||
API_SLEEP,
|
API_SLEEP,
|
||||||
AZD_COLD_ANGLE,
|
AZD_COLD_ANGLE,
|
||||||
AZD_HEAT_ANGLE,
|
AZD_HEAT_ANGLE,
|
||||||
AZD_MASTER,
|
AZD_MASTER,
|
||||||
AZD_MODE,
|
AZD_MODE,
|
||||||
AZD_MODES,
|
AZD_MODES,
|
||||||
|
AZD_Q_ADAPT,
|
||||||
AZD_SLEEP,
|
AZD_SLEEP,
|
||||||
AZD_ZONES,
|
AZD_ZONES,
|
||||||
)
|
)
|
||||||
@@ -65,6 +67,14 @@ SLEEP_DICT: Final[dict[str, int]] = {
|
|||||||
"90m": SleepTimeout.SLEEP_90,
|
"90m": SleepTimeout.SLEEP_90,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_ADAPT_DICT: Final[dict[str, int]] = {
|
||||||
|
"standard": QAdapt.STANDARD,
|
||||||
|
"power": QAdapt.POWER,
|
||||||
|
"silence": QAdapt.SILENCE,
|
||||||
|
"minimum": QAdapt.MINIMUM,
|
||||||
|
"maximum": QAdapt.MAXIMUM,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def main_zone_options(
|
def main_zone_options(
|
||||||
zone_data: dict[str, Any],
|
zone_data: dict[str, Any],
|
||||||
@@ -83,6 +93,14 @@ MAIN_ZONE_SELECT_TYPES: Final[tuple[AirzoneSelectDescription, ...]] = (
|
|||||||
options_fn=main_zone_options,
|
options_fn=main_zone_options,
|
||||||
translation_key="modes",
|
translation_key="modes",
|
||||||
),
|
),
|
||||||
|
AirzoneSelectDescription(
|
||||||
|
api_param=API_Q_ADAPT,
|
||||||
|
entity_category=EntityCategory.CONFIG,
|
||||||
|
key=AZD_Q_ADAPT,
|
||||||
|
options=list(Q_ADAPT_DICT),
|
||||||
|
options_dict=Q_ADAPT_DICT,
|
||||||
|
translation_key="q_adapt",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,16 @@
|
|||||||
"stop": "Stop"
|
"stop": "Stop"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"q_adapt": {
|
||||||
|
"name": "Q-Adapt",
|
||||||
|
"state": {
|
||||||
|
"standard": "Standard",
|
||||||
|
"power": "Power",
|
||||||
|
"silence": "Silence",
|
||||||
|
"minimum": "Minimum",
|
||||||
|
"maximum": "Maximum"
|
||||||
|
}
|
||||||
|
},
|
||||||
"sleep_times": {
|
"sleep_times": {
|
||||||
"name": "Sleep",
|
"name": "Sleep",
|
||||||
"state": {
|
"state": {
|
||||||
|
|||||||
@@ -22,6 +22,17 @@ class OAuth2FlowHandler(
|
|||||||
VERSION = CONFIG_FLOW_VERSION
|
VERSION = CONFIG_FLOW_VERSION
|
||||||
MINOR_VERSION = CONFIG_FLOW_MINOR_VERSION
|
MINOR_VERSION = CONFIG_FLOW_MINOR_VERSION
|
||||||
|
|
||||||
|
async def async_step_user(
|
||||||
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
) -> ConfigFlowResult:
|
||||||
|
"""Check we have the cloud integration set up."""
|
||||||
|
if "cloud" not in self.hass.config.components:
|
||||||
|
return self.async_abort(
|
||||||
|
reason="cloud_not_enabled",
|
||||||
|
description_placeholders={"default_config": "default_config"},
|
||||||
|
)
|
||||||
|
return await super().async_step_user(user_input)
|
||||||
|
|
||||||
async def async_step_reauth(
|
async def async_step_reauth(
|
||||||
self, user_input: Mapping[str, Any]
|
self, user_input: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
"no_url_available": "[%key:common::config_flow::abort::oauth2_no_url_available%]",
|
"no_url_available": "[%key:common::config_flow::abort::oauth2_no_url_available%]",
|
||||||
"user_rejected_authorize": "[%key:common::config_flow::abort::oauth2_user_rejected_authorize%]",
|
"user_rejected_authorize": "[%key:common::config_flow::abort::oauth2_user_rejected_authorize%]",
|
||||||
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]",
|
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]",
|
||||||
"wrong_account": "You are authenticated with a different account than the one set up. Please authenticate with the configured account."
|
"wrong_account": "You are authenticated with a different account than the one set up. Please authenticate with the configured account.",
|
||||||
|
"cloud_not_enabled": "Please make sure you run Home Assistant with `{default_config}` enabled in your configuration.yaml."
|
||||||
},
|
},
|
||||||
"create_entry": {
|
"create_entry": {
|
||||||
"default": "[%key:common::config_flow::create_entry::authenticated%]"
|
"default": "[%key:common::config_flow::create_entry::authenticated%]"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from aioamazondevices.api import AmazonDevice
|
|||||||
from aioamazondevices.const import SENSOR_STATE_OFF
|
from aioamazondevices.const import SENSOR_STATE_OFF
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
|
DOMAIN as BINARY_SENSOR_DOMAIN,
|
||||||
BinarySensorDeviceClass,
|
BinarySensorDeviceClass,
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
BinarySensorEntityDescription,
|
BinarySensorEntityDescription,
|
||||||
@@ -20,6 +21,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
|||||||
|
|
||||||
from .coordinator import AmazonConfigEntry
|
from .coordinator import AmazonConfigEntry
|
||||||
from .entity import AmazonEntity
|
from .entity import AmazonEntity
|
||||||
|
from .utils import async_update_unique_id
|
||||||
|
|
||||||
# Coordinator is used to centralize the data updates
|
# Coordinator is used to centralize the data updates
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
@@ -31,6 +33,7 @@ class AmazonBinarySensorEntityDescription(BinarySensorEntityDescription):
|
|||||||
|
|
||||||
is_on_fn: Callable[[AmazonDevice, str], bool]
|
is_on_fn: Callable[[AmazonDevice, str], bool]
|
||||||
is_supported: Callable[[AmazonDevice, str], bool] = lambda device, key: True
|
is_supported: Callable[[AmazonDevice, str], bool] = lambda device, key: True
|
||||||
|
is_available_fn: Callable[[AmazonDevice, str], bool] = lambda device, key: True
|
||||||
|
|
||||||
|
|
||||||
BINARY_SENSORS: Final = (
|
BINARY_SENSORS: Final = (
|
||||||
@@ -41,46 +44,15 @@ BINARY_SENSORS: Final = (
|
|||||||
is_on_fn=lambda device, _: device.online,
|
is_on_fn=lambda device, _: device.online,
|
||||||
),
|
),
|
||||||
AmazonBinarySensorEntityDescription(
|
AmazonBinarySensorEntityDescription(
|
||||||
key="bluetooth",
|
key="detectionState",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
|
||||||
translation_key="bluetooth",
|
|
||||||
is_on_fn=lambda device, _: device.bluetooth_state,
|
|
||||||
),
|
|
||||||
AmazonBinarySensorEntityDescription(
|
|
||||||
key="babyCryDetectionState",
|
|
||||||
translation_key="baby_cry_detection",
|
|
||||||
is_on_fn=lambda device, key: (device.sensors[key].value != SENSOR_STATE_OFF),
|
|
||||||
is_supported=lambda device, key: device.sensors.get(key) is not None,
|
|
||||||
),
|
|
||||||
AmazonBinarySensorEntityDescription(
|
|
||||||
key="beepingApplianceDetectionState",
|
|
||||||
translation_key="beeping_appliance_detection",
|
|
||||||
is_on_fn=lambda device, key: (device.sensors[key].value != SENSOR_STATE_OFF),
|
|
||||||
is_supported=lambda device, key: device.sensors.get(key) is not None,
|
|
||||||
),
|
|
||||||
AmazonBinarySensorEntityDescription(
|
|
||||||
key="coughDetectionState",
|
|
||||||
translation_key="cough_detection",
|
|
||||||
is_on_fn=lambda device, key: (device.sensors[key].value != SENSOR_STATE_OFF),
|
|
||||||
is_supported=lambda device, key: device.sensors.get(key) is not None,
|
|
||||||
),
|
|
||||||
AmazonBinarySensorEntityDescription(
|
|
||||||
key="dogBarkDetectionState",
|
|
||||||
translation_key="dog_bark_detection",
|
|
||||||
is_on_fn=lambda device, key: (device.sensors[key].value != SENSOR_STATE_OFF),
|
|
||||||
is_supported=lambda device, key: device.sensors.get(key) is not None,
|
|
||||||
),
|
|
||||||
AmazonBinarySensorEntityDescription(
|
|
||||||
key="humanPresenceDetectionState",
|
|
||||||
device_class=BinarySensorDeviceClass.MOTION,
|
device_class=BinarySensorDeviceClass.MOTION,
|
||||||
is_on_fn=lambda device, key: (device.sensors[key].value != SENSOR_STATE_OFF),
|
is_on_fn=lambda device, key: bool(
|
||||||
is_supported=lambda device, key: device.sensors.get(key) is not None,
|
device.sensors[key].value != SENSOR_STATE_OFF
|
||||||
),
|
),
|
||||||
AmazonBinarySensorEntityDescription(
|
|
||||||
key="waterSoundsDetectionState",
|
|
||||||
translation_key="water_sounds_detection",
|
|
||||||
is_on_fn=lambda device, key: (device.sensors[key].value != SENSOR_STATE_OFF),
|
|
||||||
is_supported=lambda device, key: device.sensors.get(key) is not None,
|
is_supported=lambda device, key: device.sensors.get(key) is not None,
|
||||||
|
is_available_fn=lambda device, key: (
|
||||||
|
device.online and device.sensors[key].error is False
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -94,12 +66,33 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = entry.runtime_data
|
coordinator = entry.runtime_data
|
||||||
|
|
||||||
|
# Replace unique id for "detectionState" binary sensor
|
||||||
|
await async_update_unique_id(
|
||||||
|
hass,
|
||||||
|
coordinator,
|
||||||
|
BINARY_SENSOR_DOMAIN,
|
||||||
|
"humanPresenceDetectionState",
|
||||||
|
"detectionState",
|
||||||
|
)
|
||||||
|
|
||||||
|
known_devices: set[str] = set()
|
||||||
|
|
||||||
|
def _check_device() -> None:
|
||||||
|
current_devices = set(coordinator.data)
|
||||||
|
new_devices = current_devices - known_devices
|
||||||
|
if new_devices:
|
||||||
|
known_devices.update(new_devices)
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
AmazonBinarySensorEntity(coordinator, serial_num, sensor_desc)
|
AmazonBinarySensorEntity(coordinator, serial_num, sensor_desc)
|
||||||
for sensor_desc in BINARY_SENSORS
|
for sensor_desc in BINARY_SENSORS
|
||||||
for serial_num in coordinator.data
|
for serial_num in new_devices
|
||||||
if sensor_desc.is_supported(coordinator.data[serial_num], sensor_desc.key)
|
if sensor_desc.is_supported(
|
||||||
|
coordinator.data[serial_num], sensor_desc.key
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
_check_device()
|
||||||
|
entry.async_on_unload(coordinator.async_add_listener(_check_device))
|
||||||
|
|
||||||
|
|
||||||
class AmazonBinarySensorEntity(AmazonEntity, BinarySensorEntity):
|
class AmazonBinarySensorEntity(AmazonEntity, BinarySensorEntity):
|
||||||
@@ -113,3 +106,13 @@ class AmazonBinarySensorEntity(AmazonEntity, BinarySensorEntity):
|
|||||||
return self.entity_description.is_on_fn(
|
return self.entity_description.is_on_fn(
|
||||||
self.device, self.entity_description.key
|
self.device, self.entity_description.key
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""Return if entity is available."""
|
||||||
|
return (
|
||||||
|
self.entity_description.is_available_fn(
|
||||||
|
self.device, self.entity_description.key
|
||||||
|
)
|
||||||
|
and super().available
|
||||||
|
)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class AmazonDevicesConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
data = await validate_input(self.hass, user_input)
|
data = await validate_input(self.hass, user_input)
|
||||||
except CannotConnect:
|
except CannotConnect:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except (CannotAuthenticate, TypeError):
|
except CannotAuthenticate:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except CannotRetrieveData:
|
except CannotRetrieveData:
|
||||||
errors["base"] = "cannot_retrieve_data"
|
errors["base"] = "cannot_retrieve_data"
|
||||||
@@ -112,7 +112,7 @@ class AmazonDevicesConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
)
|
)
|
||||||
except CannotConnect:
|
except CannotConnect:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except (CannotAuthenticate, TypeError):
|
except CannotAuthenticate:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except CannotRetrieveData:
|
except CannotRetrieveData:
|
||||||
errors["base"] = "cannot_retrieve_data"
|
errors["base"] = "cannot_retrieve_data"
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class AmazonDevicesCoordinator(DataUpdateCoordinator[dict[str, AmazonDevice]]):
|
|||||||
translation_key="cannot_retrieve_data_with_error",
|
translation_key="cannot_retrieve_data_with_error",
|
||||||
translation_placeholders={"error": repr(err)},
|
translation_placeholders={"error": repr(err)},
|
||||||
) from err
|
) from err
|
||||||
except (CannotAuthenticate, TypeError) as err:
|
except CannotAuthenticate as err:
|
||||||
raise ConfigEntryAuthFailed(
|
raise ConfigEntryAuthFailed(
|
||||||
translation_domain=DOMAIN,
|
translation_domain=DOMAIN,
|
||||||
translation_key="invalid_auth",
|
translation_key="invalid_auth",
|
||||||
|
|||||||
@@ -60,7 +60,5 @@ def build_device_data(device: AmazonDevice) -> dict[str, Any]:
|
|||||||
"online": device.online,
|
"online": device.online,
|
||||||
"serial number": device.serial_number,
|
"serial number": device.serial_number,
|
||||||
"software version": device.software_version,
|
"software version": device.software_version,
|
||||||
"do not disturb": device.do_not_disturb,
|
"sensors": device.sensors,
|
||||||
"response style": device.response_style,
|
|
||||||
"bluetooth state": device.bluetooth_state,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,4 @@
|
|||||||
{
|
{
|
||||||
"entity": {
|
|
||||||
"binary_sensor": {
|
|
||||||
"bluetooth": {
|
|
||||||
"default": "mdi:bluetooth-off",
|
|
||||||
"state": {
|
|
||||||
"on": "mdi:bluetooth"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"baby_cry_detection": {
|
|
||||||
"default": "mdi:account-voice-off",
|
|
||||||
"state": {
|
|
||||||
"on": "mdi:account-voice"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"beeping_appliance_detection": {
|
|
||||||
"default": "mdi:bell-off",
|
|
||||||
"state": {
|
|
||||||
"on": "mdi:bell-ring"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"cough_detection": {
|
|
||||||
"default": "mdi:blur-off",
|
|
||||||
"state": {
|
|
||||||
"on": "mdi:blur"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dog_bark_detection": {
|
|
||||||
"default": "mdi:dog-side-off",
|
|
||||||
"state": {
|
|
||||||
"on": "mdi:dog-side"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"water_sounds_detection": {
|
|
||||||
"default": "mdi:water-pump-off",
|
|
||||||
"state": {
|
|
||||||
"on": "mdi:water-pump"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": {
|
"services": {
|
||||||
"send_sound": {
|
"send_sound": {
|
||||||
"service": "mdi:cast-audio"
|
"service": "mdi:cast-audio"
|
||||||
|
|||||||
@@ -7,6 +7,6 @@
|
|||||||
"integration_type": "hub",
|
"integration_type": "hub",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["aioamazondevices"],
|
"loggers": ["aioamazondevices"],
|
||||||
"quality_scale": "silver",
|
"quality_scale": "platinum",
|
||||||
"requirements": ["aioamazondevices==6.0.0"]
|
"requirements": ["aioamazondevices==6.2.7"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,14 +57,24 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = entry.runtime_data
|
coordinator = entry.runtime_data
|
||||||
|
|
||||||
|
known_devices: set[str] = set()
|
||||||
|
|
||||||
|
def _check_device() -> None:
|
||||||
|
current_devices = set(coordinator.data)
|
||||||
|
new_devices = current_devices - known_devices
|
||||||
|
if new_devices:
|
||||||
|
known_devices.update(new_devices)
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
AmazonNotifyEntity(coordinator, serial_num, sensor_desc)
|
AmazonNotifyEntity(coordinator, serial_num, sensor_desc)
|
||||||
for sensor_desc in NOTIFY
|
for sensor_desc in NOTIFY
|
||||||
for serial_num in coordinator.data
|
for serial_num in new_devices
|
||||||
if sensor_desc.subkey in coordinator.data[serial_num].capabilities
|
if sensor_desc.subkey in coordinator.data[serial_num].capabilities
|
||||||
and sensor_desc.is_supported(coordinator.data[serial_num])
|
and sensor_desc.is_supported(coordinator.data[serial_num])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_check_device()
|
||||||
|
entry.async_on_unload(coordinator.async_add_listener(_check_device))
|
||||||
|
|
||||||
|
|
||||||
class AmazonNotifyEntity(AmazonEntity, NotifyEntity):
|
class AmazonNotifyEntity(AmazonEntity, NotifyEntity):
|
||||||
"""Binary sensor notify platform."""
|
"""Binary sensor notify platform."""
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ rules:
|
|||||||
docs-supported-functions: done
|
docs-supported-functions: done
|
||||||
docs-troubleshooting: done
|
docs-troubleshooting: done
|
||||||
docs-use-cases: done
|
docs-use-cases: done
|
||||||
dynamic-devices: todo
|
dynamic-devices: done
|
||||||
entity-category: done
|
entity-category: done
|
||||||
entity-device-class: done
|
entity-device-class: done
|
||||||
entity-disabled-by-default: done
|
entity-disabled-by-default: done
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ class AmazonSensorEntityDescription(SensorEntityDescription):
|
|||||||
"""Amazon Devices sensor entity description."""
|
"""Amazon Devices sensor entity description."""
|
||||||
|
|
||||||
native_unit_of_measurement_fn: Callable[[AmazonDevice, str], str] | None = None
|
native_unit_of_measurement_fn: Callable[[AmazonDevice, str], str] | None = None
|
||||||
|
is_available_fn: Callable[[AmazonDevice, str], bool] = lambda device, key: (
|
||||||
|
device.online and device.sensors[key].error is False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
SENSORS: Final = (
|
SENSORS: Final = (
|
||||||
@@ -62,13 +65,23 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = entry.runtime_data
|
coordinator = entry.runtime_data
|
||||||
|
|
||||||
|
known_devices: set[str] = set()
|
||||||
|
|
||||||
|
def _check_device() -> None:
|
||||||
|
current_devices = set(coordinator.data)
|
||||||
|
new_devices = current_devices - known_devices
|
||||||
|
if new_devices:
|
||||||
|
known_devices.update(new_devices)
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
AmazonSensorEntity(coordinator, serial_num, sensor_desc)
|
AmazonSensorEntity(coordinator, serial_num, sensor_desc)
|
||||||
for sensor_desc in SENSORS
|
for sensor_desc in SENSORS
|
||||||
for serial_num in coordinator.data
|
for serial_num in new_devices
|
||||||
if coordinator.data[serial_num].sensors.get(sensor_desc.key) is not None
|
if coordinator.data[serial_num].sensors.get(sensor_desc.key) is not None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_check_device()
|
||||||
|
entry.async_on_unload(coordinator.async_add_listener(_check_device))
|
||||||
|
|
||||||
|
|
||||||
class AmazonSensorEntity(AmazonEntity, SensorEntity):
|
class AmazonSensorEntity(AmazonEntity, SensorEntity):
|
||||||
"""Sensor device."""
|
"""Sensor device."""
|
||||||
@@ -89,3 +102,13 @@ class AmazonSensorEntity(AmazonEntity, SensorEntity):
|
|||||||
def native_value(self) -> StateType:
|
def native_value(self) -> StateType:
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self.device.sensors[self.entity_description.key].value
|
return self.device.sensors[self.entity_description.key].value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""Return if entity is available."""
|
||||||
|
return (
|
||||||
|
self.entity_description.is_available_fn(
|
||||||
|
self.device, self.entity_description.key
|
||||||
|
)
|
||||||
|
and super().available
|
||||||
|
)
|
||||||
|
|||||||
@@ -58,26 +58,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
"binary_sensor": {
|
|
||||||
"bluetooth": {
|
|
||||||
"name": "Bluetooth"
|
|
||||||
},
|
|
||||||
"baby_cry_detection": {
|
|
||||||
"name": "Baby crying"
|
|
||||||
},
|
|
||||||
"beeping_appliance_detection": {
|
|
||||||
"name": "Beeping appliance"
|
|
||||||
},
|
|
||||||
"cough_detection": {
|
|
||||||
"name": "Coughing"
|
|
||||||
},
|
|
||||||
"dog_bark_detection": {
|
|
||||||
"name": "Dog barking"
|
|
||||||
},
|
|
||||||
"water_sounds_detection": {
|
|
||||||
"name": "Water sounds"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notify": {
|
"notify": {
|
||||||
"speak": {
|
"speak": {
|
||||||
"name": "Speak"
|
"name": "Speak"
|
||||||
|
|||||||
@@ -8,13 +8,17 @@ from typing import TYPE_CHECKING, Any, Final
|
|||||||
|
|
||||||
from aioamazondevices.api import AmazonDevice
|
from aioamazondevices.api import AmazonDevice
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
|
from homeassistant.components.switch import (
|
||||||
|
DOMAIN as SWITCH_DOMAIN,
|
||||||
|
SwitchEntity,
|
||||||
|
SwitchEntityDescription,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .coordinator import AmazonConfigEntry
|
from .coordinator import AmazonConfigEntry
|
||||||
from .entity import AmazonEntity
|
from .entity import AmazonEntity
|
||||||
from .utils import alexa_api_call
|
from .utils import alexa_api_call, async_update_unique_id
|
||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
|
|
||||||
@@ -24,16 +28,17 @@ class AmazonSwitchEntityDescription(SwitchEntityDescription):
|
|||||||
"""Alexa Devices switch entity description."""
|
"""Alexa Devices switch entity description."""
|
||||||
|
|
||||||
is_on_fn: Callable[[AmazonDevice], bool]
|
is_on_fn: Callable[[AmazonDevice], bool]
|
||||||
subkey: str
|
is_available_fn: Callable[[AmazonDevice, str], bool] = lambda device, key: (
|
||||||
|
device.online and device.sensors[key].error is False
|
||||||
|
)
|
||||||
method: str
|
method: str
|
||||||
|
|
||||||
|
|
||||||
SWITCHES: Final = (
|
SWITCHES: Final = (
|
||||||
AmazonSwitchEntityDescription(
|
AmazonSwitchEntityDescription(
|
||||||
key="do_not_disturb",
|
key="dnd",
|
||||||
subkey="AUDIO_PLAYER",
|
|
||||||
translation_key="do_not_disturb",
|
translation_key="do_not_disturb",
|
||||||
is_on_fn=lambda _device: _device.do_not_disturb,
|
is_on_fn=lambda device: bool(device.sensors["dnd"].value),
|
||||||
method="set_do_not_disturb",
|
method="set_do_not_disturb",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -48,13 +53,28 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = entry.runtime_data
|
coordinator = entry.runtime_data
|
||||||
|
|
||||||
|
# Replace unique id for "DND" switch and remove from Speaker Group
|
||||||
|
await async_update_unique_id(
|
||||||
|
hass, coordinator, SWITCH_DOMAIN, "do_not_disturb", "dnd"
|
||||||
|
)
|
||||||
|
|
||||||
|
known_devices: set[str] = set()
|
||||||
|
|
||||||
|
def _check_device() -> None:
|
||||||
|
current_devices = set(coordinator.data)
|
||||||
|
new_devices = current_devices - known_devices
|
||||||
|
if new_devices:
|
||||||
|
known_devices.update(new_devices)
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
AmazonSwitchEntity(coordinator, serial_num, switch_desc)
|
AmazonSwitchEntity(coordinator, serial_num, switch_desc)
|
||||||
for switch_desc in SWITCHES
|
for switch_desc in SWITCHES
|
||||||
for serial_num in coordinator.data
|
for serial_num in new_devices
|
||||||
if switch_desc.subkey in coordinator.data[serial_num].capabilities
|
if switch_desc.key in coordinator.data[serial_num].sensors
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_check_device()
|
||||||
|
entry.async_on_unload(coordinator.async_add_listener(_check_device))
|
||||||
|
|
||||||
|
|
||||||
class AmazonSwitchEntity(AmazonEntity, SwitchEntity):
|
class AmazonSwitchEntity(AmazonEntity, SwitchEntity):
|
||||||
"""Switch device."""
|
"""Switch device."""
|
||||||
@@ -84,3 +104,13 @@ class AmazonSwitchEntity(AmazonEntity, SwitchEntity):
|
|||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return True if switch is on."""
|
"""Return True if switch is on."""
|
||||||
return self.entity_description.is_on_fn(self.device)
|
return self.entity_description.is_on_fn(self.device)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""Return if entity is available."""
|
||||||
|
return (
|
||||||
|
self.entity_description.is_available_fn(
|
||||||
|
self.device, self.entity_description.key
|
||||||
|
)
|
||||||
|
and super().available
|
||||||
|
)
|
||||||
|
|||||||
@@ -6,9 +6,12 @@ from typing import Any, Concatenate
|
|||||||
|
|
||||||
from aioamazondevices.exceptions import CannotConnect, CannotRetrieveData
|
from aioamazondevices.exceptions import CannotConnect, CannotRetrieveData
|
||||||
|
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
import homeassistant.helpers.entity_registry as er
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import _LOGGER, DOMAIN
|
||||||
|
from .coordinator import AmazonDevicesCoordinator
|
||||||
from .entity import AmazonEntity
|
from .entity import AmazonEntity
|
||||||
|
|
||||||
|
|
||||||
@@ -38,3 +41,23 @@ def alexa_api_call[_T: AmazonEntity, **_P](
|
|||||||
) from err
|
) from err
|
||||||
|
|
||||||
return cmd_wrapper
|
return cmd_wrapper
|
||||||
|
|
||||||
|
|
||||||
|
async def async_update_unique_id(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
coordinator: AmazonDevicesCoordinator,
|
||||||
|
domain: str,
|
||||||
|
old_key: str,
|
||||||
|
new_key: str,
|
||||||
|
) -> None:
|
||||||
|
"""Update unique id for entities created with old format."""
|
||||||
|
entity_registry = er.async_get(hass)
|
||||||
|
|
||||||
|
for serial_num in coordinator.data:
|
||||||
|
unique_id = f"{serial_num}-{old_key}"
|
||||||
|
if entity_id := entity_registry.async_get_entity_id(domain, DOMAIN, unique_id):
|
||||||
|
_LOGGER.debug("Updating unique_id for %s", entity_id)
|
||||||
|
new_unique_id = unique_id.replace(old_key, new_key)
|
||||||
|
|
||||||
|
# Update the registry with the new unique_id
|
||||||
|
entity_registry.async_update_entity(entity_id, new_unique_id=new_unique_id)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ from homeassistant.helpers.hassio import is_hassio
|
|||||||
from homeassistant.helpers.singleton import singleton
|
from homeassistant.helpers.singleton import singleton
|
||||||
from homeassistant.helpers.storage import Store
|
from homeassistant.helpers.storage import Store
|
||||||
from homeassistant.helpers.system_info import async_get_system_info
|
from homeassistant.helpers.system_info import async_get_system_info
|
||||||
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
|
from homeassistant.helpers.typing import UNDEFINED
|
||||||
from homeassistant.loader import (
|
from homeassistant.loader import (
|
||||||
Integration,
|
Integration,
|
||||||
IntegrationNotFound,
|
IntegrationNotFound,
|
||||||
@@ -142,7 +142,6 @@ class EntityAnalyticsModifications:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
remove: bool = False
|
remove: bool = False
|
||||||
capabilities: dict[str, Any] | None | UndefinedType = UNDEFINED
|
|
||||||
|
|
||||||
|
|
||||||
class AnalyticsPlatformProtocol(Protocol):
|
class AnalyticsPlatformProtocol(Protocol):
|
||||||
@@ -514,6 +513,8 @@ async def async_devices_payload(hass: HomeAssistant) -> dict: # noqa: C901
|
|||||||
integration_inputs: dict[str, tuple[list[str], list[str]]] = {}
|
integration_inputs: dict[str, tuple[list[str], list[str]]] = {}
|
||||||
integration_configs: dict[str, AnalyticsModifications] = {}
|
integration_configs: dict[str, AnalyticsModifications] = {}
|
||||||
|
|
||||||
|
removed_devices: set[str] = set()
|
||||||
|
|
||||||
# Get device list
|
# Get device list
|
||||||
for device_entry in dev_reg.devices.values():
|
for device_entry in dev_reg.devices.values():
|
||||||
if not device_entry.primary_config_entry:
|
if not device_entry.primary_config_entry:
|
||||||
@@ -526,6 +527,10 @@ async def async_devices_payload(hass: HomeAssistant) -> dict: # noqa: C901
|
|||||||
if config_entry is None:
|
if config_entry is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if device_entry.entry_type is dr.DeviceEntryType.SERVICE:
|
||||||
|
removed_devices.add(device_entry.id)
|
||||||
|
continue
|
||||||
|
|
||||||
integration_domain = config_entry.domain
|
integration_domain = config_entry.domain
|
||||||
|
|
||||||
integration_input = integration_inputs.setdefault(integration_domain, ([], []))
|
integration_input = integration_inputs.setdefault(integration_domain, ([], []))
|
||||||
@@ -538,6 +543,23 @@ async def async_devices_payload(hass: HomeAssistant) -> dict: # noqa: C901
|
|||||||
integration_input = integration_inputs.setdefault(integration_domain, ([], []))
|
integration_input = integration_inputs.setdefault(integration_domain, ([], []))
|
||||||
integration_input[1].append(entity_entry.entity_id)
|
integration_input[1].append(entity_entry.entity_id)
|
||||||
|
|
||||||
|
integrations = {
|
||||||
|
domain: integration
|
||||||
|
for domain, integration in (
|
||||||
|
await async_get_integrations(hass, integration_inputs.keys())
|
||||||
|
).items()
|
||||||
|
if isinstance(integration, Integration)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Filter out custom integrations and integrations that are not device or hub type
|
||||||
|
integration_inputs = {
|
||||||
|
domain: integration_info
|
||||||
|
for domain, integration_info in integration_inputs.items()
|
||||||
|
if (integration := integrations.get(domain)) is not None
|
||||||
|
and integration.is_built_in
|
||||||
|
and integration.manifest.get("integration_type") in ("device", "hub")
|
||||||
|
}
|
||||||
|
|
||||||
# Call integrations that implement the analytics platform
|
# Call integrations that implement the analytics platform
|
||||||
for integration_domain, integration_input in integration_inputs.items():
|
for integration_domain, integration_input in integration_inputs.items():
|
||||||
if (
|
if (
|
||||||
@@ -598,11 +620,12 @@ async def async_devices_payload(hass: HomeAssistant) -> dict: # noqa: C901
|
|||||||
device_config = integration_config.devices.get(device_id, device_config)
|
device_config = integration_config.devices.get(device_id, device_config)
|
||||||
|
|
||||||
if device_config.remove:
|
if device_config.remove:
|
||||||
|
removed_devices.add(device_id)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
device_entry = dev_reg.devices[device_id]
|
device_entry = dev_reg.devices[device_id]
|
||||||
|
|
||||||
device_id_mapping[device_entry.id] = (integration_domain, len(devices_info))
|
device_id_mapping[device_id] = (integration_domain, len(devices_info))
|
||||||
|
|
||||||
devices_info.append(
|
devices_info.append(
|
||||||
{
|
{
|
||||||
@@ -653,58 +676,41 @@ async def async_devices_payload(hass: HomeAssistant) -> dict: # noqa: C901
|
|||||||
|
|
||||||
entity_entry = ent_reg.entities[entity_id]
|
entity_entry = ent_reg.entities[entity_id]
|
||||||
|
|
||||||
entity_state = hass.states.get(entity_entry.entity_id)
|
entity_state = hass.states.get(entity_id)
|
||||||
|
|
||||||
entity_info = {
|
entity_info = {
|
||||||
# LIMITATION: `assumed_state` can be overridden by users;
|
# LIMITATION: `assumed_state` can be overridden by users;
|
||||||
# we should replace it with the original value in the future.
|
# we should replace it with the original value in the future.
|
||||||
# It is also not present, if entity is not in the state machine,
|
# It is also not present, if entity is not in the state machine,
|
||||||
# which can happen for disabled entities.
|
# which can happen for disabled entities.
|
||||||
"assumed_state": entity_state.attributes.get(ATTR_ASSUMED_STATE, False)
|
"assumed_state": (
|
||||||
|
entity_state.attributes.get(ATTR_ASSUMED_STATE, False)
|
||||||
if entity_state is not None
|
if entity_state is not None
|
||||||
else None,
|
else None
|
||||||
"capabilities": entity_config.capabilities
|
),
|
||||||
if entity_config.capabilities is not UNDEFINED
|
|
||||||
else entity_entry.capabilities,
|
|
||||||
"domain": entity_entry.domain,
|
"domain": entity_entry.domain,
|
||||||
"entity_category": entity_entry.entity_category,
|
"entity_category": entity_entry.entity_category,
|
||||||
"has_entity_name": entity_entry.has_entity_name,
|
"has_entity_name": entity_entry.has_entity_name,
|
||||||
"modified_by_integration": ["capabilities"]
|
|
||||||
if entity_config.capabilities is not UNDEFINED
|
|
||||||
else None,
|
|
||||||
"original_device_class": entity_entry.original_device_class,
|
"original_device_class": entity_entry.original_device_class,
|
||||||
# LIMITATION: `unit_of_measurement` can be overridden by users;
|
# LIMITATION: `unit_of_measurement` can be overridden by users;
|
||||||
# we should replace it with the original value in the future.
|
# we should replace it with the original value in the future.
|
||||||
"unit_of_measurement": entity_entry.unit_of_measurement,
|
"unit_of_measurement": entity_entry.unit_of_measurement,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (device_id_ := entity_entry.device_id) is not None:
|
||||||
|
if device_id_ in removed_devices:
|
||||||
|
# The device was removed, so we remove the entity too
|
||||||
|
continue
|
||||||
|
|
||||||
if (
|
if (
|
||||||
((device_id_ := entity_entry.device_id) is not None)
|
new_device_id := device_id_mapping.get(device_id_)
|
||||||
and ((new_device_id := device_id_mapping.get(device_id_)) is not None)
|
) is not None and (new_device_id[0] == integration_domain):
|
||||||
and (new_device_id[0] == integration_domain)
|
|
||||||
):
|
|
||||||
device_info = devices_info[new_device_id[1]]
|
device_info = devices_info[new_device_id[1]]
|
||||||
device_info["entities"].append(entity_info)
|
device_info["entities"].append(entity_info)
|
||||||
else:
|
continue
|
||||||
|
|
||||||
entities_info.append(entity_info)
|
entities_info.append(entity_info)
|
||||||
|
|
||||||
integrations = {
|
|
||||||
domain: integration
|
|
||||||
for domain, integration in (
|
|
||||||
await async_get_integrations(hass, integrations_info.keys())
|
|
||||||
).items()
|
|
||||||
if isinstance(integration, Integration)
|
|
||||||
}
|
|
||||||
|
|
||||||
for domain, integration_info in integrations_info.items():
|
|
||||||
if integration := integrations.get(domain):
|
|
||||||
integration_info["is_custom_integration"] = not integration.is_built_in
|
|
||||||
# Include version for custom integrations
|
|
||||||
if not integration.is_built_in and integration.version:
|
|
||||||
integration_info["custom_integration_version"] = str(
|
|
||||||
integration.version
|
|
||||||
)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"version": "home-assistant:1",
|
"version": "home-assistant:1",
|
||||||
"home_assistant": HA_VERSION,
|
"home_assistant": HA_VERSION,
|
||||||
|
|||||||
@@ -1308,7 +1308,9 @@ class PipelineRun:
|
|||||||
# instead of a full response.
|
# instead of a full response.
|
||||||
all_targets_in_satellite_area = (
|
all_targets_in_satellite_area = (
|
||||||
self._get_all_targets_in_satellite_area(
|
self._get_all_targets_in_satellite_area(
|
||||||
conversation_result.response, self._device_id
|
conversation_result.response,
|
||||||
|
self._satellite_id,
|
||||||
|
self._device_id,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1337,39 +1339,62 @@ class PipelineRun:
|
|||||||
return (speech, all_targets_in_satellite_area)
|
return (speech, all_targets_in_satellite_area)
|
||||||
|
|
||||||
def _get_all_targets_in_satellite_area(
|
def _get_all_targets_in_satellite_area(
|
||||||
self, intent_response: intent.IntentResponse, device_id: str | None
|
self,
|
||||||
|
intent_response: intent.IntentResponse,
|
||||||
|
satellite_id: str | None,
|
||||||
|
device_id: str | None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Return true if all targeted entities were in the same area as the device."""
|
"""Return true if all targeted entities were in the same area as the device."""
|
||||||
if (
|
if (
|
||||||
(intent_response.response_type != intent.IntentResponseType.ACTION_DONE)
|
intent_response.response_type != intent.IntentResponseType.ACTION_DONE
|
||||||
or (not intent_response.matched_states)
|
or not intent_response.matched_states
|
||||||
or (not device_id)
|
|
||||||
):
|
|
||||||
return False
|
|
||||||
|
|
||||||
device_registry = dr.async_get(self.hass)
|
|
||||||
|
|
||||||
if (not (device := device_registry.async_get(device_id))) or (
|
|
||||||
not device.area_id
|
|
||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
entity_registry = er.async_get(self.hass)
|
entity_registry = er.async_get(self.hass)
|
||||||
for state in intent_response.matched_states:
|
device_registry = dr.async_get(self.hass)
|
||||||
entity = entity_registry.async_get(state.entity_id)
|
|
||||||
if not entity:
|
|
||||||
return False
|
|
||||||
|
|
||||||
if (entity_area_id := entity.area_id) is None:
|
area_id: str | None = None
|
||||||
if (entity.device_id is None) or (
|
|
||||||
(entity_device := device_registry.async_get(entity.device_id))
|
if (
|
||||||
is None
|
satellite_id is not None
|
||||||
|
and (target_entity_entry := entity_registry.async_get(satellite_id))
|
||||||
|
is not None
|
||||||
):
|
):
|
||||||
|
area_id = target_entity_entry.area_id
|
||||||
|
device_id = target_entity_entry.device_id
|
||||||
|
|
||||||
|
if area_id is None:
|
||||||
|
if device_id is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
entity_area_id = entity_device.area_id
|
device_entry = device_registry.async_get(device_id)
|
||||||
|
if device_entry is None:
|
||||||
|
return False
|
||||||
|
|
||||||
if entity_area_id != device.area_id:
|
area_id = device_entry.area_id
|
||||||
|
if area_id is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
for state in intent_response.matched_states:
|
||||||
|
target_entity_entry = entity_registry.async_get(state.entity_id)
|
||||||
|
if target_entity_entry is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
target_area_id = target_entity_entry.area_id
|
||||||
|
if target_area_id is None:
|
||||||
|
if target_entity_entry.device_id is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
target_device_entry = device_registry.async_get(
|
||||||
|
target_entity_entry.device_id
|
||||||
|
)
|
||||||
|
if target_device_entry is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
target_area_id = target_device_entry.area_id
|
||||||
|
|
||||||
|
if target_area_id != area_id:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
"""Analytics platform."""
|
|
||||||
|
|
||||||
from homeassistant.components.analytics import (
|
|
||||||
AnalyticsInput,
|
|
||||||
AnalyticsModifications,
|
|
||||||
EntityAnalyticsModifications,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
|
||||||
from homeassistant.helpers import entity_registry as er
|
|
||||||
|
|
||||||
|
|
||||||
async def async_modify_analytics(
|
|
||||||
hass: HomeAssistant, analytics_input: AnalyticsInput
|
|
||||||
) -> AnalyticsModifications:
|
|
||||||
"""Modify the analytics."""
|
|
||||||
ent_reg = er.async_get(hass)
|
|
||||||
|
|
||||||
entities: dict[str, EntityAnalyticsModifications] = {}
|
|
||||||
for entity_id in analytics_input.entity_ids:
|
|
||||||
entity_entry = ent_reg.entities[entity_id]
|
|
||||||
if entity_entry.capabilities is not None:
|
|
||||||
entities[entity_id] = EntityAnalyticsModifications(capabilities=None)
|
|
||||||
|
|
||||||
return AnalyticsModifications(entities=entities)
|
|
||||||
@@ -272,6 +272,13 @@ async def async_setup_entry(
|
|||||||
observations: list[ConfigType] = [
|
observations: list[ConfigType] = [
|
||||||
dict(subentry.data) for subentry in config_entry.subentries.values()
|
dict(subentry.data) for subentry in config_entry.subentries.values()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
for observation in observations:
|
||||||
|
if observation[CONF_PLATFORM] == CONF_TEMPLATE:
|
||||||
|
observation[CONF_VALUE_TEMPLATE] = Template(
|
||||||
|
observation[CONF_VALUE_TEMPLATE], hass
|
||||||
|
)
|
||||||
|
|
||||||
prior: float = config[CONF_PRIOR]
|
prior: float = config[CONF_PRIOR]
|
||||||
probability_threshold: float = config[CONF_PROBABILITY_THRESHOLD]
|
probability_threshold: float = config[CONF_PROBABILITY_THRESHOLD]
|
||||||
device_class: BinarySensorDeviceClass | None = config.get(CONF_DEVICE_CLASS)
|
device_class: BinarySensorDeviceClass | None = config.get(CONF_DEVICE_CLASS)
|
||||||
|
|||||||
@@ -13,20 +13,30 @@ from bluecurrent_api.exceptions import (
|
|||||||
RequestLimitReached,
|
RequestLimitReached,
|
||||||
WebsocketError,
|
WebsocketError,
|
||||||
)
|
)
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
|
||||||
from homeassistant.const import CONF_API_TOKEN, Platform
|
from homeassistant.const import CONF_API_TOKEN, CONF_DEVICE_ID, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
from homeassistant.exceptions import (
|
||||||
|
ConfigEntryAuthFailed,
|
||||||
|
ConfigEntryNotReady,
|
||||||
|
ServiceValidationError,
|
||||||
|
)
|
||||||
|
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
|
BCU_APP,
|
||||||
CHARGEPOINT_SETTINGS,
|
CHARGEPOINT_SETTINGS,
|
||||||
CHARGEPOINT_STATUS,
|
CHARGEPOINT_STATUS,
|
||||||
|
CHARGING_CARD_ID,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
EVSE_ID,
|
EVSE_ID,
|
||||||
LOGGER,
|
LOGGER,
|
||||||
PLUG_AND_CHARGE,
|
PLUG_AND_CHARGE,
|
||||||
|
SERVICE_START_CHARGE_SESSION,
|
||||||
VALUE,
|
VALUE,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -34,6 +44,7 @@ type BlueCurrentConfigEntry = ConfigEntry[Connector]
|
|||||||
|
|
||||||
PLATFORMS = [Platform.BUTTON, Platform.SENSOR, Platform.SWITCH]
|
PLATFORMS = [Platform.BUTTON, Platform.SENSOR, Platform.SWITCH]
|
||||||
CHARGE_POINTS = "CHARGE_POINTS"
|
CHARGE_POINTS = "CHARGE_POINTS"
|
||||||
|
CHARGE_CARDS = "CHARGE_CARDS"
|
||||||
DATA = "data"
|
DATA = "data"
|
||||||
DELAY = 5
|
DELAY = 5
|
||||||
|
|
||||||
@@ -41,6 +52,16 @@ GRID = "GRID"
|
|||||||
OBJECT = "object"
|
OBJECT = "object"
|
||||||
VALUE_TYPES = [CHARGEPOINT_STATUS, CHARGEPOINT_SETTINGS]
|
VALUE_TYPES = [CHARGEPOINT_STATUS, CHARGEPOINT_SETTINGS]
|
||||||
|
|
||||||
|
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
||||||
|
|
||||||
|
SERVICE_START_CHARGE_SESSION_SCHEMA = vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Required(CONF_DEVICE_ID): cv.string,
|
||||||
|
# When no charging card is provided, use no charging card (BCU_APP = no charging card).
|
||||||
|
vol.Optional(CHARGING_CARD_ID, default=BCU_APP): cv.string,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, config_entry: BlueCurrentConfigEntry
|
hass: HomeAssistant, config_entry: BlueCurrentConfigEntry
|
||||||
@@ -67,6 +88,66 @@ async def async_setup_entry(
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
|
"""Set up Blue Current."""
|
||||||
|
|
||||||
|
async def start_charge_session(service_call: ServiceCall) -> None:
|
||||||
|
"""Start a charge session with the provided device and charge card ID."""
|
||||||
|
# When no charge card is provided, use the default charge card set in the config flow.
|
||||||
|
charging_card_id = service_call.data[CHARGING_CARD_ID]
|
||||||
|
device_id = service_call.data[CONF_DEVICE_ID]
|
||||||
|
|
||||||
|
# Get the device based on the given device ID.
|
||||||
|
device = dr.async_get(hass).devices.get(device_id)
|
||||||
|
|
||||||
|
if device is None:
|
||||||
|
raise ServiceValidationError(
|
||||||
|
translation_domain=DOMAIN, translation_key="invalid_device_id"
|
||||||
|
)
|
||||||
|
|
||||||
|
blue_current_config_entry: ConfigEntry | None = None
|
||||||
|
|
||||||
|
for config_entry_id in device.config_entries:
|
||||||
|
config_entry = hass.config_entries.async_get_entry(config_entry_id)
|
||||||
|
if not config_entry or config_entry.domain != DOMAIN:
|
||||||
|
# Not the blue_current config entry.
|
||||||
|
continue
|
||||||
|
|
||||||
|
if config_entry.state is not ConfigEntryState.LOADED:
|
||||||
|
raise ServiceValidationError(
|
||||||
|
translation_domain=DOMAIN, translation_key="config_entry_not_loaded"
|
||||||
|
)
|
||||||
|
|
||||||
|
blue_current_config_entry = config_entry
|
||||||
|
break
|
||||||
|
|
||||||
|
if not blue_current_config_entry:
|
||||||
|
# The device is not connected to a valid blue_current config entry.
|
||||||
|
raise ServiceValidationError(
|
||||||
|
translation_domain=DOMAIN, translation_key="no_config_entry"
|
||||||
|
)
|
||||||
|
|
||||||
|
connector = blue_current_config_entry.runtime_data
|
||||||
|
|
||||||
|
# Get the evse_id from the identifier of the device.
|
||||||
|
evse_id = next(
|
||||||
|
identifier[1]
|
||||||
|
for identifier in device.identifiers
|
||||||
|
if identifier[0] == DOMAIN
|
||||||
|
)
|
||||||
|
|
||||||
|
await connector.client.start_session(evse_id, charging_card_id)
|
||||||
|
|
||||||
|
hass.services.async_register(
|
||||||
|
DOMAIN,
|
||||||
|
SERVICE_START_CHARGE_SESSION,
|
||||||
|
start_charge_session,
|
||||||
|
SERVICE_START_CHARGE_SESSION_SCHEMA,
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(
|
async def async_unload_entry(
|
||||||
hass: HomeAssistant, config_entry: BlueCurrentConfigEntry
|
hass: HomeAssistant, config_entry: BlueCurrentConfigEntry
|
||||||
) -> bool:
|
) -> bool:
|
||||||
@@ -87,6 +168,7 @@ class Connector:
|
|||||||
self.client = client
|
self.client = client
|
||||||
self.charge_points: dict[str, dict] = {}
|
self.charge_points: dict[str, dict] = {}
|
||||||
self.grid: dict[str, Any] = {}
|
self.grid: dict[str, Any] = {}
|
||||||
|
self.charge_cards: dict[str, dict[str, Any]] = {}
|
||||||
|
|
||||||
async def on_data(self, message: dict) -> None:
|
async def on_data(self, message: dict) -> None:
|
||||||
"""Handle received data."""
|
"""Handle received data."""
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ LOGGER = logging.getLogger(__package__)
|
|||||||
|
|
||||||
EVSE_ID = "evse_id"
|
EVSE_ID = "evse_id"
|
||||||
MODEL_TYPE = "model_type"
|
MODEL_TYPE = "model_type"
|
||||||
|
CARD = "card"
|
||||||
|
UID = "uid"
|
||||||
|
BCU_APP = "BCU-APP"
|
||||||
|
WITHOUT_CHARGING_CARD = "without_charging_card"
|
||||||
|
CHARGING_CARD_ID = "charging_card_id"
|
||||||
|
SERVICE_START_CHARGE_SESSION = "start_charge_session"
|
||||||
PLUG_AND_CHARGE = "plug_and_charge"
|
PLUG_AND_CHARGE = "plug_and_charge"
|
||||||
VALUE = "value"
|
VALUE = "value"
|
||||||
PERMISSION = "permission"
|
PERMISSION = "permission"
|
||||||
|
|||||||
@@ -42,5 +42,10 @@
|
|||||||
"default": "mdi:lock"
|
"default": "mdi:lock"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"services": {
|
||||||
|
"start_charge_session": {
|
||||||
|
"service": "mdi:play"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
homeassistant/components/blue_current/services.yaml
Normal file
12
homeassistant/components/blue_current/services.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
start_charge_session:
|
||||||
|
fields:
|
||||||
|
device_id:
|
||||||
|
selector:
|
||||||
|
device:
|
||||||
|
integration: blue_current
|
||||||
|
required: true
|
||||||
|
|
||||||
|
charging_card_id:
|
||||||
|
selector:
|
||||||
|
text:
|
||||||
|
required: false
|
||||||
@@ -22,6 +22,16 @@
|
|||||||
"wrong_account": "Wrong account: Please authenticate with the API token for {email}."
|
"wrong_account": "Wrong account: Please authenticate with the API token for {email}."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"options": {
|
||||||
|
"step": {
|
||||||
|
"init": {
|
||||||
|
"data": {
|
||||||
|
"card": "Card"
|
||||||
|
},
|
||||||
|
"description": "Select the default charging card you want to use"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
"sensor": {
|
"sensor": {
|
||||||
"activity": {
|
"activity": {
|
||||||
@@ -136,5 +146,39 @@
|
|||||||
"name": "Block charge point"
|
"name": "Block charge point"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"selector": {
|
||||||
|
"select_charging_card": {
|
||||||
|
"options": {
|
||||||
|
"without_charging_card": "Without charging card"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"services": {
|
||||||
|
"start_charge_session": {
|
||||||
|
"name": "Start charge session",
|
||||||
|
"description": "Starts a new charge session on a specified charge point.",
|
||||||
|
"fields": {
|
||||||
|
"charging_card_id": {
|
||||||
|
"name": "Charging card ID",
|
||||||
|
"description": "Optional charging card ID that will be used to start a charge session. When not provided, no charging card will be used."
|
||||||
|
},
|
||||||
|
"device_id": {
|
||||||
|
"name": "Device ID",
|
||||||
|
"description": "The ID of the Blue Current charge point."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"exceptions": {
|
||||||
|
"invalid_device_id": {
|
||||||
|
"message": "Invalid device ID given."
|
||||||
|
},
|
||||||
|
"config_entry_not_loaded": {
|
||||||
|
"message": "Config entry not loaded."
|
||||||
|
},
|
||||||
|
"no_config_entry": {
|
||||||
|
"message": "Device has not a valid blue_current config entry."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from asyncio import Future
|
|||||||
from collections.abc import Callable, Iterable
|
from collections.abc import Callable, Iterable
|
||||||
from typing import TYPE_CHECKING, cast
|
from typing import TYPE_CHECKING, cast
|
||||||
|
|
||||||
|
from bleak import BleakScanner
|
||||||
from habluetooth import (
|
from habluetooth import (
|
||||||
BaseHaScanner,
|
BaseHaScanner,
|
||||||
BluetoothScannerDevice,
|
BluetoothScannerDevice,
|
||||||
@@ -38,13 +39,16 @@ def _get_manager(hass: HomeAssistant) -> HomeAssistantBluetoothManager:
|
|||||||
|
|
||||||
|
|
||||||
@hass_callback
|
@hass_callback
|
||||||
def async_get_scanner(hass: HomeAssistant) -> HaBleakScannerWrapper:
|
def async_get_scanner(hass: HomeAssistant) -> BleakScanner:
|
||||||
"""Return a HaBleakScannerWrapper.
|
"""Return a HaBleakScannerWrapper cast to BleakScanner.
|
||||||
|
|
||||||
This is a wrapper around our BleakScanner singleton that allows
|
This is a wrapper around our BleakScanner singleton that allows
|
||||||
multiple integrations to share the same BleakScanner.
|
multiple integrations to share the same BleakScanner.
|
||||||
|
|
||||||
|
The wrapper is cast to BleakScanner for type compatibility with
|
||||||
|
libraries expecting a BleakScanner instance.
|
||||||
"""
|
"""
|
||||||
return HaBleakScannerWrapper()
|
return cast(BleakScanner, HaBleakScannerWrapper())
|
||||||
|
|
||||||
|
|
||||||
@hass_callback
|
@hass_callback
|
||||||
|
|||||||
@@ -29,10 +29,23 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = cast(ComelitVedoSystem, config_entry.runtime_data)
|
coordinator = cast(ComelitVedoSystem, config_entry.runtime_data)
|
||||||
|
|
||||||
|
known_devices: set[int] = set()
|
||||||
|
|
||||||
|
def _check_device() -> None:
|
||||||
|
current_devices = set(coordinator.data["alarm_zones"])
|
||||||
|
new_devices = current_devices - known_devices
|
||||||
|
if new_devices:
|
||||||
|
known_devices.update(new_devices)
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
ComelitVedoBinarySensorEntity(coordinator, device, config_entry.entry_id)
|
ComelitVedoBinarySensorEntity(
|
||||||
for device in coordinator.data["alarm_zones"].values()
|
coordinator, device, config_entry.entry_id
|
||||||
)
|
)
|
||||||
|
for device in coordinator.data["alarm_zones"].values()
|
||||||
|
if device.index in new_devices
|
||||||
|
)
|
||||||
|
|
||||||
|
_check_device()
|
||||||
|
config_entry.async_on_unload(coordinator.async_add_listener(_check_device))
|
||||||
|
|
||||||
|
|
||||||
class ComelitVedoBinarySensorEntity(
|
class ComelitVedoBinarySensorEntity(
|
||||||
|
|||||||
@@ -25,23 +25,27 @@ from .const import _LOGGER, DEFAULT_PORT, DEVICE_TYPE_LIST, DOMAIN
|
|||||||
from .utils import async_client_session
|
from .utils import async_client_session
|
||||||
|
|
||||||
DEFAULT_HOST = "192.168.1.252"
|
DEFAULT_HOST = "192.168.1.252"
|
||||||
DEFAULT_PIN = 111111
|
DEFAULT_PIN = "111111"
|
||||||
|
|
||||||
|
|
||||||
|
pin_regex = r"^[0-9]{4,10}$"
|
||||||
|
|
||||||
USER_SCHEMA = vol.Schema(
|
USER_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_HOST, default=DEFAULT_HOST): cv.string,
|
vol.Required(CONF_HOST, default=DEFAULT_HOST): cv.string,
|
||||||
vol.Required(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
vol.Required(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||||
vol.Optional(CONF_PIN, default=DEFAULT_PIN): cv.positive_int,
|
vol.Optional(CONF_PIN, default=DEFAULT_PIN): cv.matches_regex(pin_regex),
|
||||||
vol.Required(CONF_TYPE, default=BRIDGE): vol.In(DEVICE_TYPE_LIST),
|
vol.Required(CONF_TYPE, default=BRIDGE): vol.In(DEVICE_TYPE_LIST),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PIN): cv.positive_int})
|
STEP_REAUTH_DATA_SCHEMA = vol.Schema(
|
||||||
|
{vol.Required(CONF_PIN): cv.matches_regex(pin_regex)}
|
||||||
|
)
|
||||||
STEP_RECONFIGURE = vol.Schema(
|
STEP_RECONFIGURE = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_HOST): cv.string,
|
vol.Required(CONF_HOST): cv.string,
|
||||||
vol.Required(CONF_PORT): cv.port,
|
vol.Required(CONF_PORT): cv.port,
|
||||||
vol.Optional(CONF_PIN, default=DEFAULT_PIN): cv.positive_int,
|
vol.Optional(CONF_PIN, default=DEFAULT_PIN): cv.matches_regex(pin_regex),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -29,11 +29,22 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = cast(ComelitSerialBridge, config_entry.runtime_data)
|
coordinator = cast(ComelitSerialBridge, config_entry.runtime_data)
|
||||||
|
|
||||||
|
known_devices: set[int] = set()
|
||||||
|
|
||||||
|
def _check_device() -> None:
|
||||||
|
current_devices = set(coordinator.data[COVER])
|
||||||
|
new_devices = current_devices - known_devices
|
||||||
|
if new_devices:
|
||||||
|
known_devices.update(new_devices)
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
ComelitCoverEntity(coordinator, device, config_entry.entry_id)
|
ComelitCoverEntity(coordinator, device, config_entry.entry_id)
|
||||||
for device in coordinator.data[COVER].values()
|
for device in coordinator.data[COVER].values()
|
||||||
|
if device.index in new_devices
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_check_device()
|
||||||
|
config_entry.async_on_unload(coordinator.async_add_listener(_check_device))
|
||||||
|
|
||||||
|
|
||||||
class ComelitCoverEntity(ComelitBridgeBaseEntity, RestoreEntity, CoverEntity):
|
class ComelitCoverEntity(ComelitBridgeBaseEntity, RestoreEntity, CoverEntity):
|
||||||
"""Cover device."""
|
"""Cover device."""
|
||||||
|
|||||||
@@ -27,11 +27,22 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = cast(ComelitSerialBridge, config_entry.runtime_data)
|
coordinator = cast(ComelitSerialBridge, config_entry.runtime_data)
|
||||||
|
|
||||||
|
known_devices: set[int] = set()
|
||||||
|
|
||||||
|
def _check_device() -> None:
|
||||||
|
current_devices = set(coordinator.data[LIGHT])
|
||||||
|
new_devices = current_devices - known_devices
|
||||||
|
if new_devices:
|
||||||
|
known_devices.update(new_devices)
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
ComelitLightEntity(coordinator, device, config_entry.entry_id)
|
ComelitLightEntity(coordinator, device, config_entry.entry_id)
|
||||||
for device in coordinator.data[LIGHT].values()
|
for device in coordinator.data[LIGHT].values()
|
||||||
|
if device.index in new_devices
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_check_device()
|
||||||
|
config_entry.async_on_unload(coordinator.async_add_listener(_check_device))
|
||||||
|
|
||||||
|
|
||||||
class ComelitLightEntity(ComelitBridgeBaseEntity, LightEntity):
|
class ComelitLightEntity(ComelitBridgeBaseEntity, LightEntity):
|
||||||
"""Light device."""
|
"""Light device."""
|
||||||
|
|||||||
@@ -7,6 +7,6 @@
|
|||||||
"integration_type": "hub",
|
"integration_type": "hub",
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"loggers": ["aiocomelit"],
|
"loggers": ["aiocomelit"],
|
||||||
"quality_scale": "silver",
|
"quality_scale": "platinum",
|
||||||
"requirements": ["aiocomelit==0.12.3"]
|
"requirements": ["aiocomelit==0.12.3"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,9 +57,7 @@ rules:
|
|||||||
docs-supported-functions: done
|
docs-supported-functions: done
|
||||||
docs-troubleshooting: done
|
docs-troubleshooting: done
|
||||||
docs-use-cases: done
|
docs-use-cases: done
|
||||||
dynamic-devices:
|
dynamic-devices: done
|
||||||
status: todo
|
|
||||||
comment: missing implementation
|
|
||||||
entity-category:
|
entity-category:
|
||||||
status: exempt
|
status: exempt
|
||||||
comment: no config or diagnostic entities
|
comment: no config or diagnostic entities
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Final, cast
|
from typing import Final, cast
|
||||||
|
|
||||||
from aiocomelit import ComelitSerialBridgeObject, ComelitVedoZoneObject
|
from aiocomelit.api import ComelitSerialBridgeObject, ComelitVedoZoneObject
|
||||||
from aiocomelit.const import BRIDGE, OTHER, AlarmZoneState
|
from aiocomelit.const import BRIDGE, OTHER, AlarmZoneState
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
@@ -65,15 +65,24 @@ async def async_setup_bridge_entry(
|
|||||||
|
|
||||||
coordinator = cast(ComelitSerialBridge, config_entry.runtime_data)
|
coordinator = cast(ComelitSerialBridge, config_entry.runtime_data)
|
||||||
|
|
||||||
entities: list[ComelitBridgeSensorEntity] = []
|
known_devices: set[int] = set()
|
||||||
for device in coordinator.data[OTHER].values():
|
|
||||||
entities.extend(
|
def _check_device() -> None:
|
||||||
|
current_devices = set(coordinator.data[OTHER])
|
||||||
|
new_devices = current_devices - known_devices
|
||||||
|
if new_devices:
|
||||||
|
known_devices.update(new_devices)
|
||||||
|
async_add_entities(
|
||||||
ComelitBridgeSensorEntity(
|
ComelitBridgeSensorEntity(
|
||||||
coordinator, device, config_entry.entry_id, sensor_desc
|
coordinator, device, config_entry.entry_id, sensor_desc
|
||||||
)
|
)
|
||||||
for sensor_desc in SENSOR_BRIDGE_TYPES
|
for sensor_desc in SENSOR_BRIDGE_TYPES
|
||||||
|
for device in coordinator.data[OTHER].values()
|
||||||
|
if device.index in new_devices
|
||||||
)
|
)
|
||||||
async_add_entities(entities)
|
|
||||||
|
_check_device()
|
||||||
|
config_entry.async_on_unload(coordinator.async_add_listener(_check_device))
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_vedo_entry(
|
async def async_setup_vedo_entry(
|
||||||
@@ -85,15 +94,24 @@ async def async_setup_vedo_entry(
|
|||||||
|
|
||||||
coordinator = cast(ComelitVedoSystem, config_entry.runtime_data)
|
coordinator = cast(ComelitVedoSystem, config_entry.runtime_data)
|
||||||
|
|
||||||
entities: list[ComelitVedoSensorEntity] = []
|
known_devices: set[int] = set()
|
||||||
for device in coordinator.data["alarm_zones"].values():
|
|
||||||
entities.extend(
|
def _check_device() -> None:
|
||||||
|
current_devices = set(coordinator.data["alarm_zones"])
|
||||||
|
new_devices = current_devices - known_devices
|
||||||
|
if new_devices:
|
||||||
|
known_devices.update(new_devices)
|
||||||
|
async_add_entities(
|
||||||
ComelitVedoSensorEntity(
|
ComelitVedoSensorEntity(
|
||||||
coordinator, device, config_entry.entry_id, sensor_desc
|
coordinator, device, config_entry.entry_id, sensor_desc
|
||||||
)
|
)
|
||||||
for sensor_desc in SENSOR_VEDO_TYPES
|
for sensor_desc in SENSOR_VEDO_TYPES
|
||||||
|
for device in coordinator.data["alarm_zones"].values()
|
||||||
|
if device.index in new_devices
|
||||||
)
|
)
|
||||||
async_add_entities(entities)
|
|
||||||
|
_check_device()
|
||||||
|
config_entry.async_on_unload(coordinator.async_add_listener(_check_device))
|
||||||
|
|
||||||
|
|
||||||
class ComelitBridgeSensorEntity(ComelitBridgeBaseEntity, SensorEntity):
|
class ComelitBridgeSensorEntity(ComelitBridgeBaseEntity, SensorEntity):
|
||||||
|
|||||||
@@ -39,6 +39,25 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
known_devices: dict[str, set[int]] = {
|
||||||
|
dev_type: set() for dev_type in (IRRIGATION, OTHER)
|
||||||
|
}
|
||||||
|
|
||||||
|
def _check_device() -> None:
|
||||||
|
for dev_type in (IRRIGATION, OTHER):
|
||||||
|
current_devices = set(coordinator.data[dev_type])
|
||||||
|
new_devices = current_devices - known_devices[dev_type]
|
||||||
|
if new_devices:
|
||||||
|
known_devices[dev_type].update(new_devices)
|
||||||
|
async_add_entities(
|
||||||
|
ComelitSwitchEntity(coordinator, device, config_entry.entry_id)
|
||||||
|
for device in coordinator.data[dev_type].values()
|
||||||
|
if device.index in new_devices
|
||||||
|
)
|
||||||
|
|
||||||
|
_check_device()
|
||||||
|
config_entry.async_on_unload(coordinator.async_add_listener(_check_device))
|
||||||
|
|
||||||
|
|
||||||
class ComelitSwitchEntity(ComelitBridgeBaseEntity, SwitchEntity):
|
class ComelitSwitchEntity(ComelitBridgeBaseEntity, SwitchEntity):
|
||||||
"""Switch device."""
|
"""Switch device."""
|
||||||
|
|||||||
@@ -6,5 +6,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/conversation",
|
"documentation": "https://www.home-assistant.io/integrations/conversation",
|
||||||
"integration_type": "entity",
|
"integration_type": "entity",
|
||||||
"quality_scale": "internal",
|
"quality_scale": "internal",
|
||||||
"requirements": ["hassil==3.2.0", "home-assistant-intents==2025.9.3"]
|
"requirements": ["hassil==3.2.0", "home-assistant-intents==2025.10.1"]
|
||||||
}
|
}
|
||||||
|
|||||||
58
homeassistant/components/cync/__init__.py
Normal file
58
homeassistant/components/cync/__init__.py
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
"""The Cync integration."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from pycync import Auth, Cync, User
|
||||||
|
from pycync.exceptions import AuthFailedError, CyncError
|
||||||
|
|
||||||
|
from homeassistant.const import CONF_ACCESS_TOKEN, Platform
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||||
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
|
from .const import (
|
||||||
|
CONF_AUTHORIZE_STRING,
|
||||||
|
CONF_EXPIRES_AT,
|
||||||
|
CONF_REFRESH_TOKEN,
|
||||||
|
CONF_USER_ID,
|
||||||
|
)
|
||||||
|
from .coordinator import CyncConfigEntry, CyncCoordinator
|
||||||
|
|
||||||
|
_PLATFORMS: list[Platform] = [Platform.LIGHT]
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup_entry(hass: HomeAssistant, entry: CyncConfigEntry) -> bool:
|
||||||
|
"""Set up Cync from a config entry."""
|
||||||
|
user_info = User(
|
||||||
|
entry.data[CONF_ACCESS_TOKEN],
|
||||||
|
entry.data[CONF_REFRESH_TOKEN],
|
||||||
|
entry.data[CONF_AUTHORIZE_STRING],
|
||||||
|
entry.data[CONF_USER_ID],
|
||||||
|
expires_at=entry.data[CONF_EXPIRES_AT],
|
||||||
|
)
|
||||||
|
cync_auth = Auth(async_get_clientsession(hass), user=user_info)
|
||||||
|
|
||||||
|
try:
|
||||||
|
cync = await Cync.create(cync_auth)
|
||||||
|
except AuthFailedError as ex:
|
||||||
|
raise ConfigEntryAuthFailed("User token invalid") from ex
|
||||||
|
except CyncError as ex:
|
||||||
|
raise ConfigEntryNotReady("Unable to connect to Cync") from ex
|
||||||
|
|
||||||
|
devices_coordinator = CyncCoordinator(hass, entry, cync)
|
||||||
|
|
||||||
|
cync.set_update_callback(devices_coordinator.on_data_update)
|
||||||
|
|
||||||
|
await devices_coordinator.async_config_entry_first_refresh()
|
||||||
|
entry.runtime_data = devices_coordinator
|
||||||
|
|
||||||
|
await hass.config_entries.async_forward_entry_setups(entry, _PLATFORMS)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
async def async_unload_entry(hass: HomeAssistant, entry: CyncConfigEntry) -> bool:
|
||||||
|
"""Unload a config entry."""
|
||||||
|
cync = entry.runtime_data.cync
|
||||||
|
await cync.shut_down()
|
||||||
|
return await hass.config_entries.async_unload_platforms(entry, _PLATFORMS)
|
||||||
118
homeassistant/components/cync/config_flow.py
Normal file
118
homeassistant/components/cync/config_flow.py
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
"""Config flow for the Cync integration."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from pycync import Auth
|
||||||
|
from pycync.exceptions import AuthFailedError, CyncError, TwoFactorRequiredError
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
|
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_EMAIL, CONF_PASSWORD
|
||||||
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
|
from .const import (
|
||||||
|
CONF_AUTHORIZE_STRING,
|
||||||
|
CONF_EXPIRES_AT,
|
||||||
|
CONF_REFRESH_TOKEN,
|
||||||
|
CONF_TWO_FACTOR_CODE,
|
||||||
|
CONF_USER_ID,
|
||||||
|
DOMAIN,
|
||||||
|
)
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
STEP_USER_DATA_SCHEMA = vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Required(CONF_EMAIL): str,
|
||||||
|
vol.Required(CONF_PASSWORD): str,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
STEP_TWO_FACTOR_SCHEMA = vol.Schema({vol.Required(CONF_TWO_FACTOR_CODE): str})
|
||||||
|
|
||||||
|
|
||||||
|
class CyncConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
"""Handle a config flow for Cync."""
|
||||||
|
|
||||||
|
VERSION = 1
|
||||||
|
|
||||||
|
cync_auth: Auth
|
||||||
|
|
||||||
|
async def async_step_user(
|
||||||
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
) -> ConfigFlowResult:
|
||||||
|
"""Attempt login with user credentials."""
|
||||||
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
if user_input is None:
|
||||||
|
return self.async_show_form(
|
||||||
|
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
|
||||||
|
)
|
||||||
|
|
||||||
|
self.cync_auth = Auth(
|
||||||
|
async_get_clientsession(self.hass),
|
||||||
|
username=user_input[CONF_EMAIL],
|
||||||
|
password=user_input[CONF_PASSWORD],
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
await self.cync_auth.login()
|
||||||
|
except AuthFailedError:
|
||||||
|
errors["base"] = "invalid_auth"
|
||||||
|
except TwoFactorRequiredError:
|
||||||
|
return await self.async_step_two_factor()
|
||||||
|
except CyncError:
|
||||||
|
errors["base"] = "cannot_connect"
|
||||||
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
|
errors["base"] = "unknown"
|
||||||
|
else:
|
||||||
|
return await self._create_config_entry(self.cync_auth.username)
|
||||||
|
|
||||||
|
return self.async_show_form(
|
||||||
|
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
|
||||||
|
)
|
||||||
|
|
||||||
|
async def async_step_two_factor(
|
||||||
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
) -> ConfigFlowResult:
|
||||||
|
"""Attempt login with the two factor auth code sent to the user."""
|
||||||
|
errors: dict[str, str] = {}
|
||||||
|
|
||||||
|
if user_input is None:
|
||||||
|
return self.async_show_form(
|
||||||
|
step_id="two_factor", data_schema=STEP_TWO_FACTOR_SCHEMA, errors=errors
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
await self.cync_auth.login(user_input[CONF_TWO_FACTOR_CODE])
|
||||||
|
except AuthFailedError:
|
||||||
|
errors["base"] = "invalid_auth"
|
||||||
|
except CyncError:
|
||||||
|
errors["base"] = "cannot_connect"
|
||||||
|
except Exception:
|
||||||
|
_LOGGER.exception("Unexpected exception")
|
||||||
|
errors["base"] = "unknown"
|
||||||
|
else:
|
||||||
|
return await self._create_config_entry(self.cync_auth.username)
|
||||||
|
|
||||||
|
return self.async_show_form(
|
||||||
|
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
|
||||||
|
)
|
||||||
|
|
||||||
|
async def _create_config_entry(self, user_email: str) -> ConfigFlowResult:
|
||||||
|
"""Create the Cync config entry using input user data."""
|
||||||
|
|
||||||
|
cync_user = self.cync_auth.user
|
||||||
|
await self.async_set_unique_id(str(cync_user.user_id))
|
||||||
|
self._abort_if_unique_id_configured()
|
||||||
|
|
||||||
|
config = {
|
||||||
|
CONF_USER_ID: cync_user.user_id,
|
||||||
|
CONF_AUTHORIZE_STRING: cync_user.authorize,
|
||||||
|
CONF_EXPIRES_AT: cync_user.expires_at,
|
||||||
|
CONF_ACCESS_TOKEN: cync_user.access_token,
|
||||||
|
CONF_REFRESH_TOKEN: cync_user.refresh_token,
|
||||||
|
}
|
||||||
|
return self.async_create_entry(title=user_email, data=config)
|
||||||
9
homeassistant/components/cync/const.py
Normal file
9
homeassistant/components/cync/const.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
"""Constants for the Cync integration."""
|
||||||
|
|
||||||
|
DOMAIN = "cync"
|
||||||
|
|
||||||
|
CONF_TWO_FACTOR_CODE = "two_factor_code"
|
||||||
|
CONF_USER_ID = "user_id"
|
||||||
|
CONF_AUTHORIZE_STRING = "authorize_string"
|
||||||
|
CONF_EXPIRES_AT = "expires_at"
|
||||||
|
CONF_REFRESH_TOKEN = "refresh_token"
|
||||||
87
homeassistant/components/cync/coordinator.py
Normal file
87
homeassistant/components/cync/coordinator.py
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
"""Coordinator to handle keeping device states up to date."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from datetime import timedelta
|
||||||
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
from pycync import Cync, CyncDevice, User
|
||||||
|
from pycync.exceptions import AuthFailedError
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||||
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
|
||||||
|
from .const import CONF_EXPIRES_AT, CONF_REFRESH_TOKEN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
type CyncConfigEntry = ConfigEntry[CyncCoordinator]
|
||||||
|
|
||||||
|
|
||||||
|
class CyncCoordinator(DataUpdateCoordinator[dict[int, CyncDevice]]):
|
||||||
|
"""Coordinator to handle updating Cync device states."""
|
||||||
|
|
||||||
|
config_entry: CyncConfigEntry
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, hass: HomeAssistant, config_entry: CyncConfigEntry, cync: Cync
|
||||||
|
) -> None:
|
||||||
|
"""Initialize the Cync coordinator."""
|
||||||
|
super().__init__(
|
||||||
|
hass,
|
||||||
|
_LOGGER,
|
||||||
|
name="Cync Data Coordinator",
|
||||||
|
config_entry=config_entry,
|
||||||
|
update_interval=timedelta(seconds=30),
|
||||||
|
always_update=True,
|
||||||
|
)
|
||||||
|
self.cync = cync
|
||||||
|
|
||||||
|
async def on_data_update(self, data: dict[int, CyncDevice]) -> None:
|
||||||
|
"""Update registered devices with new data."""
|
||||||
|
merged_data = self.data | data if self.data else data
|
||||||
|
self.async_set_updated_data(merged_data)
|
||||||
|
|
||||||
|
async def _async_setup(self) -> None:
|
||||||
|
"""Set up the coordinator with initial device states."""
|
||||||
|
logged_in_user = self.cync.get_logged_in_user()
|
||||||
|
if logged_in_user.access_token != self.config_entry.data[CONF_ACCESS_TOKEN]:
|
||||||
|
await self._update_config_cync_credentials(logged_in_user)
|
||||||
|
|
||||||
|
async def _async_update_data(self) -> dict[int, CyncDevice]:
|
||||||
|
"""First, refresh the user's auth token if it is set to expire in less than one hour.
|
||||||
|
|
||||||
|
Then, fetch all current device states.
|
||||||
|
"""
|
||||||
|
|
||||||
|
logged_in_user = self.cync.get_logged_in_user()
|
||||||
|
if logged_in_user.expires_at - time.time() < 3600:
|
||||||
|
await self._async_refresh_cync_credentials()
|
||||||
|
|
||||||
|
self.cync.update_device_states()
|
||||||
|
current_device_states = self.cync.get_devices()
|
||||||
|
|
||||||
|
return {device.device_id: device for device in current_device_states}
|
||||||
|
|
||||||
|
async def _async_refresh_cync_credentials(self) -> None:
|
||||||
|
"""Attempt to refresh the Cync user's authentication token."""
|
||||||
|
|
||||||
|
try:
|
||||||
|
refreshed_user = await self.cync.refresh_credentials()
|
||||||
|
except AuthFailedError as ex:
|
||||||
|
raise ConfigEntryAuthFailed("Unable to refresh user token") from ex
|
||||||
|
else:
|
||||||
|
await self._update_config_cync_credentials(refreshed_user)
|
||||||
|
|
||||||
|
async def _update_config_cync_credentials(self, user_info: User) -> None:
|
||||||
|
"""Update the config entry with current user info."""
|
||||||
|
|
||||||
|
new_data = {**self.config_entry.data}
|
||||||
|
new_data[CONF_ACCESS_TOKEN] = user_info.access_token
|
||||||
|
new_data[CONF_REFRESH_TOKEN] = user_info.refresh_token
|
||||||
|
new_data[CONF_EXPIRES_AT] = user_info.expires_at
|
||||||
|
self.hass.config_entries.async_update_entry(self.config_entry, data=new_data)
|
||||||
45
homeassistant/components/cync/entity.py
Normal file
45
homeassistant/components/cync/entity.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
"""Setup for a generic entity type for the Cync integration."""
|
||||||
|
|
||||||
|
from pycync.devices import CyncDevice
|
||||||
|
|
||||||
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
|
from .coordinator import CyncCoordinator
|
||||||
|
|
||||||
|
|
||||||
|
class CyncBaseEntity(CoordinatorEntity[CyncCoordinator]):
|
||||||
|
"""Generic base entity for Cync devices."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
device: CyncDevice,
|
||||||
|
coordinator: CyncCoordinator,
|
||||||
|
room_name: str | None = None,
|
||||||
|
) -> None:
|
||||||
|
"""Pass coordinator to CoordinatorEntity."""
|
||||||
|
super().__init__(coordinator)
|
||||||
|
|
||||||
|
self._cync_device_id = device.device_id
|
||||||
|
self._attr_unique_id = device.unique_id
|
||||||
|
|
||||||
|
self._attr_device_info = DeviceInfo(
|
||||||
|
identifiers={(DOMAIN, device.unique_id)},
|
||||||
|
manufacturer="GE Lighting",
|
||||||
|
name=device.name,
|
||||||
|
suggested_area=room_name,
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""Determines whether this device is currently available."""
|
||||||
|
|
||||||
|
return (
|
||||||
|
super().available
|
||||||
|
and self.coordinator.data is not None
|
||||||
|
and self._cync_device_id in self.coordinator.data
|
||||||
|
and self.coordinator.data[self._cync_device_id].is_online
|
||||||
|
)
|
||||||
180
homeassistant/components/cync/light.py
Normal file
180
homeassistant/components/cync/light.py
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
"""Support for Cync light entities."""
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from pycync import CyncLight
|
||||||
|
from pycync.devices.capabilities import CyncCapability
|
||||||
|
|
||||||
|
from homeassistant.components.light import (
|
||||||
|
ATTR_BRIGHTNESS,
|
||||||
|
ATTR_COLOR_TEMP_KELVIN,
|
||||||
|
ATTR_RGB_COLOR,
|
||||||
|
ColorMode,
|
||||||
|
LightEntity,
|
||||||
|
filter_supported_color_modes,
|
||||||
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
from homeassistant.util.color import value_to_brightness
|
||||||
|
from homeassistant.util.scaling import scale_ranged_value_to_int_range
|
||||||
|
|
||||||
|
from .coordinator import CyncConfigEntry, CyncCoordinator
|
||||||
|
from .entity import CyncBaseEntity
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entry: CyncConfigEntry,
|
||||||
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
|
"""Set up Cync lights from a config entry."""
|
||||||
|
|
||||||
|
coordinator = entry.runtime_data
|
||||||
|
cync = coordinator.cync
|
||||||
|
|
||||||
|
entities_to_add = []
|
||||||
|
|
||||||
|
for home in cync.get_homes():
|
||||||
|
for room in home.rooms:
|
||||||
|
room_lights = [
|
||||||
|
CyncLightEntity(device, coordinator, room.name)
|
||||||
|
for device in room.devices
|
||||||
|
if isinstance(device, CyncLight)
|
||||||
|
]
|
||||||
|
entities_to_add.extend(room_lights)
|
||||||
|
|
||||||
|
group_lights = [
|
||||||
|
CyncLightEntity(device, coordinator, room.name)
|
||||||
|
for group in room.groups
|
||||||
|
for device in group.devices
|
||||||
|
if isinstance(device, CyncLight)
|
||||||
|
]
|
||||||
|
entities_to_add.extend(group_lights)
|
||||||
|
|
||||||
|
async_add_entities(entities_to_add)
|
||||||
|
|
||||||
|
|
||||||
|
class CyncLightEntity(CyncBaseEntity, LightEntity):
|
||||||
|
"""Representation of a Cync light."""
|
||||||
|
|
||||||
|
_attr_color_mode = ColorMode.ONOFF
|
||||||
|
_attr_min_color_temp_kelvin = 2000
|
||||||
|
_attr_max_color_temp_kelvin = 7000
|
||||||
|
_attr_translation_key = "light"
|
||||||
|
_attr_name = None
|
||||||
|
|
||||||
|
BRIGHTNESS_SCALE = (0, 100)
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
device: CyncLight,
|
||||||
|
coordinator: CyncCoordinator,
|
||||||
|
room_name: str | None = None,
|
||||||
|
) -> None:
|
||||||
|
"""Set up base attributes."""
|
||||||
|
super().__init__(device, coordinator, room_name)
|
||||||
|
|
||||||
|
supported_color_modes = {ColorMode.ONOFF}
|
||||||
|
if device.supports_capability(CyncCapability.CCT_COLOR):
|
||||||
|
supported_color_modes.add(ColorMode.COLOR_TEMP)
|
||||||
|
if device.supports_capability(CyncCapability.DIMMING):
|
||||||
|
supported_color_modes.add(ColorMode.BRIGHTNESS)
|
||||||
|
if device.supports_capability(CyncCapability.RGB_COLOR):
|
||||||
|
supported_color_modes.add(ColorMode.RGB)
|
||||||
|
self._attr_supported_color_modes = filter_supported_color_modes(
|
||||||
|
supported_color_modes
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_on(self) -> bool | None:
|
||||||
|
"""Return True if the light is on."""
|
||||||
|
return self._device.is_on
|
||||||
|
|
||||||
|
@property
|
||||||
|
def brightness(self) -> int:
|
||||||
|
"""Provide the light's current brightness."""
|
||||||
|
return value_to_brightness(self.BRIGHTNESS_SCALE, self._device.brightness)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def color_temp_kelvin(self) -> int:
|
||||||
|
"""Return color temperature in kelvin."""
|
||||||
|
return scale_ranged_value_to_int_range(
|
||||||
|
(1, 100),
|
||||||
|
(self.min_color_temp_kelvin, self.max_color_temp_kelvin),
|
||||||
|
self._device.color_temp,
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def rgb_color(self) -> tuple[int, int, int]:
|
||||||
|
"""Provide the light's current color in RGB format."""
|
||||||
|
return self._device.rgb
|
||||||
|
|
||||||
|
@property
|
||||||
|
def color_mode(self) -> str | None:
|
||||||
|
"""Return the active color mode."""
|
||||||
|
|
||||||
|
if (
|
||||||
|
self._device.supports_capability(CyncCapability.CCT_COLOR)
|
||||||
|
and self._device.color_mode > 0
|
||||||
|
and self._device.color_mode <= 100
|
||||||
|
):
|
||||||
|
return ColorMode.COLOR_TEMP
|
||||||
|
if (
|
||||||
|
self._device.supports_capability(CyncCapability.RGB_COLOR)
|
||||||
|
and self._device.color_mode == 254
|
||||||
|
):
|
||||||
|
return ColorMode.RGB
|
||||||
|
if self._device.supports_capability(CyncCapability.DIMMING):
|
||||||
|
return ColorMode.BRIGHTNESS
|
||||||
|
|
||||||
|
return ColorMode.ONOFF
|
||||||
|
|
||||||
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
|
"""Process an action on the light."""
|
||||||
|
if not kwargs:
|
||||||
|
await self._device.turn_on()
|
||||||
|
|
||||||
|
elif kwargs.get(ATTR_COLOR_TEMP_KELVIN) is not None:
|
||||||
|
color_temp = kwargs.get(ATTR_COLOR_TEMP_KELVIN)
|
||||||
|
converted_color_temp = self._normalize_color_temp(color_temp)
|
||||||
|
|
||||||
|
await self._device.set_color_temp(converted_color_temp)
|
||||||
|
elif kwargs.get(ATTR_RGB_COLOR) is not None:
|
||||||
|
rgb = kwargs.get(ATTR_RGB_COLOR)
|
||||||
|
|
||||||
|
await self._device.set_rgb(rgb)
|
||||||
|
elif kwargs.get(ATTR_BRIGHTNESS) is not None:
|
||||||
|
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
||||||
|
converted_brightness = self._normalize_brightness(brightness)
|
||||||
|
|
||||||
|
await self._device.set_brightness(converted_brightness)
|
||||||
|
|
||||||
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
|
"""Turn off the light."""
|
||||||
|
await self._device.turn_off()
|
||||||
|
|
||||||
|
def _normalize_brightness(self, brightness: float | None) -> int | None:
|
||||||
|
"""Return calculated brightness value scaled between 0-100."""
|
||||||
|
if brightness is not None:
|
||||||
|
return int((brightness / 255) * 100)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _normalize_color_temp(self, color_temp_kelvin: float | None) -> int | None:
|
||||||
|
"""Return calculated color temp value scaled between 1-100."""
|
||||||
|
if color_temp_kelvin is not None:
|
||||||
|
kelvin_range = self.max_color_temp_kelvin - self.min_color_temp_kelvin
|
||||||
|
scaled_kelvin = int(
|
||||||
|
((color_temp_kelvin - self.min_color_temp_kelvin) / kelvin_range) * 100
|
||||||
|
)
|
||||||
|
if scaled_kelvin == 0:
|
||||||
|
scaled_kelvin += 1
|
||||||
|
|
||||||
|
return scaled_kelvin
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _device(self) -> CyncLight:
|
||||||
|
"""Fetch the reference to the backing Cync light for this device."""
|
||||||
|
|
||||||
|
return self.coordinator.data[self._cync_device_id]
|
||||||
11
homeassistant/components/cync/manifest.json
Normal file
11
homeassistant/components/cync/manifest.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"domain": "cync",
|
||||||
|
"name": "Cync",
|
||||||
|
"codeowners": ["@Kinachi249"],
|
||||||
|
"config_flow": true,
|
||||||
|
"documentation": "https://www.home-assistant.io/integrations/cync",
|
||||||
|
"integration_type": "hub",
|
||||||
|
"iot_class": "cloud_push",
|
||||||
|
"quality_scale": "bronze",
|
||||||
|
"requirements": ["pycync==0.4.0"]
|
||||||
|
}
|
||||||
69
homeassistant/components/cync/quality_scale.yaml
Normal file
69
homeassistant/components/cync/quality_scale.yaml
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
rules:
|
||||||
|
# Bronze
|
||||||
|
action-setup:
|
||||||
|
status: exempt
|
||||||
|
comment: |
|
||||||
|
This integration does not provide additional actions.
|
||||||
|
appropriate-polling: done
|
||||||
|
brands: done
|
||||||
|
common-modules: done
|
||||||
|
config-flow-test-coverage: done
|
||||||
|
config-flow: done
|
||||||
|
dependency-transparency: done
|
||||||
|
docs-actions:
|
||||||
|
status: exempt
|
||||||
|
comment: |
|
||||||
|
This integration does not provide additional actions.
|
||||||
|
docs-high-level-description: done
|
||||||
|
docs-installation-instructions: done
|
||||||
|
docs-removal-instructions: done
|
||||||
|
entity-event-setup: done
|
||||||
|
entity-unique-id: done
|
||||||
|
has-entity-name: done
|
||||||
|
runtime-data: done
|
||||||
|
test-before-configure: done
|
||||||
|
test-before-setup: done
|
||||||
|
unique-config-entry: done
|
||||||
|
|
||||||
|
# Silver
|
||||||
|
action-exceptions:
|
||||||
|
status: exempt
|
||||||
|
comment: |
|
||||||
|
This integration does not provide additional actions.
|
||||||
|
config-entry-unloading: done
|
||||||
|
docs-configuration-parameters: todo
|
||||||
|
docs-installation-parameters: todo
|
||||||
|
entity-unavailable: todo
|
||||||
|
integration-owner: done
|
||||||
|
log-when-unavailable: todo
|
||||||
|
parallel-updates: todo
|
||||||
|
reauthentication-flow: todo
|
||||||
|
test-coverage: todo
|
||||||
|
|
||||||
|
# Gold
|
||||||
|
devices: done
|
||||||
|
diagnostics: todo
|
||||||
|
discovery-update-info: todo
|
||||||
|
discovery: todo
|
||||||
|
docs-data-update: todo
|
||||||
|
docs-examples: todo
|
||||||
|
docs-known-limitations: done
|
||||||
|
docs-supported-devices: todo
|
||||||
|
docs-supported-functions: done
|
||||||
|
docs-troubleshooting: todo
|
||||||
|
docs-use-cases: todo
|
||||||
|
dynamic-devices: todo
|
||||||
|
entity-category: todo
|
||||||
|
entity-device-class: todo
|
||||||
|
entity-disabled-by-default: todo
|
||||||
|
entity-translations: todo
|
||||||
|
exception-translations: todo
|
||||||
|
icon-translations: todo
|
||||||
|
reconfiguration-flow: todo
|
||||||
|
repair-issues: todo
|
||||||
|
stale-devices: todo
|
||||||
|
|
||||||
|
# Platinum
|
||||||
|
async-dependency: done
|
||||||
|
inject-websession: done
|
||||||
|
strict-typing: todo
|
||||||
32
homeassistant/components/cync/strings.json
Normal file
32
homeassistant/components/cync/strings.json
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"config": {
|
||||||
|
"step": {
|
||||||
|
"user": {
|
||||||
|
"data": {
|
||||||
|
"email": "[%key:common::config_flow::data::email%]",
|
||||||
|
"password": "[%key:common::config_flow::data::password%]"
|
||||||
|
},
|
||||||
|
"data_description": {
|
||||||
|
"email": "Your Cync account's email address",
|
||||||
|
"password": "Your Cync account's password"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"two_factor": {
|
||||||
|
"data": {
|
||||||
|
"two_factor_code": "Two-factor code"
|
||||||
|
},
|
||||||
|
"data_description": {
|
||||||
|
"two_factor_code": "The two-factor code sent to your Cync account's email"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||||
|
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
||||||
|
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||||
|
},
|
||||||
|
"abort": {
|
||||||
|
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from ipaddress import IPv4Address, IPv6Address
|
from ipaddress import IPv4Address, IPv6Address
|
||||||
import logging
|
import logging
|
||||||
@@ -88,8 +89,8 @@ class WanIpSensor(SensorEntity):
|
|||||||
self._attr_name = "IPv6" if ipv6 else None
|
self._attr_name = "IPv6" if ipv6 else None
|
||||||
self._attr_unique_id = f"{hostname}_{ipv6}"
|
self._attr_unique_id = f"{hostname}_{ipv6}"
|
||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
self.resolver = aiodns.DNSResolver(tcp_port=port, udp_port=port)
|
self.port = port
|
||||||
self.resolver.nameservers = [resolver]
|
self._resolver = resolver
|
||||||
self.querytype: Literal["A", "AAAA"] = "AAAA" if ipv6 else "A"
|
self.querytype: Literal["A", "AAAA"] = "AAAA" if ipv6 else "A"
|
||||||
self._retries = DEFAULT_RETRIES
|
self._retries = DEFAULT_RETRIES
|
||||||
self._attr_extra_state_attributes = {
|
self._attr_extra_state_attributes = {
|
||||||
@@ -103,14 +104,26 @@ class WanIpSensor(SensorEntity):
|
|||||||
model=aiodns.__version__,
|
model=aiodns.__version__,
|
||||||
name=name,
|
name=name,
|
||||||
)
|
)
|
||||||
|
self.resolver: aiodns.DNSResolver
|
||||||
|
self.create_dns_resolver()
|
||||||
|
|
||||||
|
def create_dns_resolver(self) -> None:
|
||||||
|
"""Create the DNS resolver."""
|
||||||
|
self.resolver = aiodns.DNSResolver(tcp_port=self.port, udp_port=self.port)
|
||||||
|
self.resolver.nameservers = [self._resolver]
|
||||||
|
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Get the current DNS IP address for hostname."""
|
"""Get the current DNS IP address for hostname."""
|
||||||
|
if self.resolver._closed: # noqa: SLF001
|
||||||
|
self.create_dns_resolver()
|
||||||
|
response = None
|
||||||
try:
|
try:
|
||||||
|
async with asyncio.timeout(10):
|
||||||
response = await self.resolver.query(self.hostname, self.querytype)
|
response = await self.resolver.query(self.hostname, self.querytype)
|
||||||
|
except TimeoutError:
|
||||||
|
await self.resolver.close()
|
||||||
except DNSError as err:
|
except DNSError as err:
|
||||||
_LOGGER.warning("Exception while resolving host: %s", err)
|
_LOGGER.warning("Exception while resolving host: %s", err)
|
||||||
response = None
|
|
||||||
|
|
||||||
if response:
|
if response:
|
||||||
sorted_ips = sort_ips(
|
sorted_ips = sort_ips(
|
||||||
|
|||||||
@@ -116,7 +116,11 @@ class EbusdData:
|
|||||||
try:
|
try:
|
||||||
_LOGGER.debug("Opening socket to ebusd %s", name)
|
_LOGGER.debug("Opening socket to ebusd %s", name)
|
||||||
command_result = ebusdpy.write(self._address, self._circuit, name, value)
|
command_result = ebusdpy.write(self._address, self._circuit, name, value)
|
||||||
if command_result is not None and "done" not in command_result:
|
if (
|
||||||
|
command_result is not None
|
||||||
|
and "done" not in command_result
|
||||||
|
and "empty" not in command_result
|
||||||
|
):
|
||||||
_LOGGER.warning("Write command failed: %s", name)
|
_LOGGER.warning("Write command failed: %s", name)
|
||||||
except RuntimeError as err:
|
except RuntimeError as err:
|
||||||
_LOGGER.error(err)
|
_LOGGER.error(err)
|
||||||
|
|||||||
@@ -176,7 +176,7 @@
|
|||||||
"description": "Sets the participating sensors for a climate program.",
|
"description": "Sets the participating sensors for a climate program.",
|
||||||
"fields": {
|
"fields": {
|
||||||
"preset_mode": {
|
"preset_mode": {
|
||||||
"name": "Climate Name",
|
"name": "Climate program",
|
||||||
"description": "Name of the climate program to set the sensors active on.\nDefaults to currently active program."
|
"description": "Name of the climate program to set the sensors active on.\nDefaults to currently active program."
|
||||||
},
|
},
|
||||||
"device_ids": {
|
"device_ids": {
|
||||||
@@ -188,7 +188,7 @@
|
|||||||
},
|
},
|
||||||
"exceptions": {
|
"exceptions": {
|
||||||
"invalid_preset": {
|
"invalid_preset": {
|
||||||
"message": "Invalid climate name, available options are: {options}"
|
"message": "Invalid climate program, available options are: {options}"
|
||||||
},
|
},
|
||||||
"invalid_sensor": {
|
"invalid_sensor": {
|
||||||
"message": "Invalid sensor for thermostat, available options are: {options}"
|
"message": "Invalid sensor for thermostat, available options are: {options}"
|
||||||
|
|||||||
@@ -69,7 +69,9 @@ class EcovacsMap(
|
|||||||
await super().async_added_to_hass()
|
await super().async_added_to_hass()
|
||||||
|
|
||||||
async def on_info(event: CachedMapInfoEvent) -> None:
|
async def on_info(event: CachedMapInfoEvent) -> None:
|
||||||
self._attr_extra_state_attributes["map_name"] = event.name
|
for map_obj in event.maps:
|
||||||
|
if map_obj.using:
|
||||||
|
self._attr_extra_state_attributes["map_name"] = map_obj.name
|
||||||
|
|
||||||
async def on_changed(event: MapChangedEvent) -> None:
|
async def on_changed(event: MapChangedEvent) -> None:
|
||||||
self._attr_image_last_updated = event.when
|
self._attr_image_last_updated = event.when
|
||||||
|
|||||||
@@ -6,5 +6,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/ecovacs",
|
"documentation": "https://www.home-assistant.io/integrations/ecovacs",
|
||||||
"iot_class": "cloud_push",
|
"iot_class": "cloud_push",
|
||||||
"loggers": ["sleekxmppfs", "sucks", "deebot_client"],
|
"loggers": ["sleekxmppfs", "sucks", "deebot_client"],
|
||||||
"requirements": ["py-sucks==0.9.11", "deebot-client==14.0.0"]
|
"requirements": ["py-sucks==0.9.11", "deebot-client==15.0.0"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,5 +6,5 @@
|
|||||||
"dependencies": ["webhook"],
|
"dependencies": ["webhook"],
|
||||||
"documentation": "https://www.home-assistant.io/integrations/ecowitt",
|
"documentation": "https://www.home-assistant.io/integrations/ecowitt",
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"requirements": ["aioecowitt==2025.9.1"]
|
"requirements": ["aioecowitt==2025.9.2"]
|
||||||
}
|
}
|
||||||
|
|||||||
24
homeassistant/components/ekeybionyx/__init__.py
Normal file
24
homeassistant/components/ekeybionyx/__init__.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
"""The Ekey Bionyx integration."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.const import Platform
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
PLATFORMS: list[Platform] = [Platform.EVENT]
|
||||||
|
|
||||||
|
|
||||||
|
type EkeyBionyxConfigEntry = ConfigEntry
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup_entry(hass: HomeAssistant, entry: EkeyBionyxConfigEntry) -> bool:
|
||||||
|
"""Set up the Ekey Bionyx config entry."""
|
||||||
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
async def async_unload_entry(hass: HomeAssistant, entry: EkeyBionyxConfigEntry) -> bool:
|
||||||
|
"""Unload a config entry."""
|
||||||
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
"""application_credentials platform the Ekey Bionyx integration."""
|
||||||
|
|
||||||
|
from homeassistant.components.application_credentials import AuthorizationServer
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
from .const import OAUTH2_AUTHORIZE, OAUTH2_TOKEN
|
||||||
|
|
||||||
|
|
||||||
|
async def async_get_authorization_server(hass: HomeAssistant) -> AuthorizationServer:
|
||||||
|
"""Return authorization server."""
|
||||||
|
return AuthorizationServer(
|
||||||
|
authorize_url=OAUTH2_AUTHORIZE,
|
||||||
|
token_url=OAUTH2_TOKEN,
|
||||||
|
)
|
||||||
271
homeassistant/components/ekeybionyx/config_flow.py
Normal file
271
homeassistant/components/ekeybionyx/config_flow.py
Normal file
@@ -0,0 +1,271 @@
|
|||||||
|
"""Config flow for ekey bionyx."""
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import re
|
||||||
|
import secrets
|
||||||
|
from typing import Any, NotRequired, TypedDict
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
|
import ekey_bionyxpy
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.components.webhook import (
|
||||||
|
async_generate_id as webhook_generate_id,
|
||||||
|
async_generate_path as webhook_generate_path,
|
||||||
|
)
|
||||||
|
from homeassistant.config_entries import ConfigFlowResult
|
||||||
|
from homeassistant.const import CONF_TOKEN, CONF_URL
|
||||||
|
from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv
|
||||||
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
from homeassistant.helpers.network import get_url
|
||||||
|
from homeassistant.helpers.selector import SelectOptionDict, SelectSelector
|
||||||
|
|
||||||
|
from .const import API_URL, DOMAIN, INTEGRATION_NAME, SCOPE
|
||||||
|
|
||||||
|
# Valid webhook name: starts with letter or underscore, contains letters, digits, spaces, dots, and underscores, does not end with space or dot
|
||||||
|
VALID_NAME_PATTERN = re.compile(r"^(?![\d\s])[\w\d \.]*[\w\d]$")
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigFlowEkeyApi(ekey_bionyxpy.AbstractAuth):
|
||||||
|
"""ekey bionyx authentication before a ConfigEntry exists.
|
||||||
|
|
||||||
|
This implementation directly provides the token without supporting refresh.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
websession: aiohttp.ClientSession,
|
||||||
|
token: dict[str, Any],
|
||||||
|
) -> None:
|
||||||
|
"""Initialize ConfigFlowEkeyApi."""
|
||||||
|
super().__init__(websession, API_URL)
|
||||||
|
self._token = token
|
||||||
|
|
||||||
|
async def async_get_access_token(self) -> str:
|
||||||
|
"""Return the token for the Ekey API."""
|
||||||
|
return self._token["access_token"]
|
||||||
|
|
||||||
|
|
||||||
|
class EkeyFlowData(TypedDict):
|
||||||
|
"""Type for Flow Data."""
|
||||||
|
|
||||||
|
api: NotRequired[ekey_bionyxpy.BionyxAPI]
|
||||||
|
system: NotRequired[ekey_bionyxpy.System]
|
||||||
|
systems: NotRequired[list[ekey_bionyxpy.System]]
|
||||||
|
|
||||||
|
|
||||||
|
class OAuth2FlowHandler(
|
||||||
|
config_entry_oauth2_flow.AbstractOAuth2FlowHandler, domain=DOMAIN
|
||||||
|
):
|
||||||
|
"""Config flow to handle ekey bionyx OAuth2 authentication."""
|
||||||
|
|
||||||
|
DOMAIN = DOMAIN
|
||||||
|
|
||||||
|
check_deletion_task: asyncio.Task[None] | None = None
|
||||||
|
|
||||||
|
def __init__(self) -> None:
|
||||||
|
"""Initialize OAuth2FlowHandler."""
|
||||||
|
super().__init__()
|
||||||
|
self._data: EkeyFlowData = {}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def logger(self) -> logging.Logger:
|
||||||
|
"""Return logger."""
|
||||||
|
return logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def extra_authorize_data(self) -> dict[str, Any]:
|
||||||
|
"""Extra data that needs to be appended to the authorize url."""
|
||||||
|
return {"scope": SCOPE}
|
||||||
|
|
||||||
|
async def async_oauth_create_entry(self, data: dict[str, Any]) -> ConfigFlowResult:
|
||||||
|
"""Start the user facing flow by initializing the API and getting the systems."""
|
||||||
|
client = ConfigFlowEkeyApi(async_get_clientsession(self.hass), data[CONF_TOKEN])
|
||||||
|
ap = ekey_bionyxpy.BionyxAPI(client)
|
||||||
|
self._data["api"] = ap
|
||||||
|
try:
|
||||||
|
system_res = await ap.get_systems()
|
||||||
|
except aiohttp.ClientResponseError:
|
||||||
|
return self.async_abort(
|
||||||
|
reason="cannot_connect",
|
||||||
|
description_placeholders={"ekeybionyx": INTEGRATION_NAME},
|
||||||
|
)
|
||||||
|
system = [s for s in system_res if s.own_system]
|
||||||
|
if len(system) == 0:
|
||||||
|
return self.async_abort(reason="no_own_systems")
|
||||||
|
self._data["systems"] = system
|
||||||
|
if len(system) == 1:
|
||||||
|
# skipping choose_system since there is only one
|
||||||
|
self._data["system"] = system[0]
|
||||||
|
return await self.async_step_check_system(user_input=None)
|
||||||
|
return await self.async_step_choose_system(user_input=None)
|
||||||
|
|
||||||
|
async def async_step_choose_system(
|
||||||
|
self, user_input: dict[str, Any] | None
|
||||||
|
) -> ConfigFlowResult:
|
||||||
|
"""Dialog to choose System if multiple systems are present."""
|
||||||
|
if user_input is None:
|
||||||
|
options: list[SelectOptionDict] = [
|
||||||
|
{"value": s.system_id, "label": s.system_name}
|
||||||
|
for s in self._data["systems"]
|
||||||
|
]
|
||||||
|
data_schema = {vol.Required("system"): SelectSelector({"options": options})}
|
||||||
|
return self.async_show_form(
|
||||||
|
step_id="choose_system",
|
||||||
|
data_schema=vol.Schema(data_schema),
|
||||||
|
description_placeholders={"ekeybionyx": INTEGRATION_NAME},
|
||||||
|
)
|
||||||
|
self._data["system"] = [
|
||||||
|
s for s in self._data["systems"] if s.system_id == user_input["system"]
|
||||||
|
][0]
|
||||||
|
return await self.async_step_check_system(user_input=None)
|
||||||
|
|
||||||
|
async def async_step_check_system(
|
||||||
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
) -> ConfigFlowResult:
|
||||||
|
"""Check if system has open webhooks."""
|
||||||
|
system = self._data["system"]
|
||||||
|
await self.async_set_unique_id(system.system_id)
|
||||||
|
self._abort_if_unique_id_configured()
|
||||||
|
|
||||||
|
if (
|
||||||
|
system.function_webhook_quotas["free"] == 0
|
||||||
|
and system.function_webhook_quotas["used"] == 0
|
||||||
|
):
|
||||||
|
return self.async_abort(
|
||||||
|
reason="no_available_webhooks",
|
||||||
|
description_placeholders={"ekeybionyx": INTEGRATION_NAME},
|
||||||
|
)
|
||||||
|
|
||||||
|
if system.function_webhook_quotas["used"] > 0:
|
||||||
|
return await self.async_step_delete_webhooks()
|
||||||
|
return await self.async_step_webhooks(user_input=None)
|
||||||
|
|
||||||
|
async def async_step_webhooks(
|
||||||
|
self, user_input: dict[str, Any] | None
|
||||||
|
) -> ConfigFlowResult:
|
||||||
|
"""Dialog to setup webhooks."""
|
||||||
|
system = self._data["system"]
|
||||||
|
|
||||||
|
errors: dict[str, str] | None = None
|
||||||
|
if user_input is not None:
|
||||||
|
errors = {}
|
||||||
|
for key, webhook_name in user_input.items():
|
||||||
|
if key == CONF_URL:
|
||||||
|
continue
|
||||||
|
if not re.match(VALID_NAME_PATTERN, webhook_name):
|
||||||
|
errors.update({key: "invalid_name"})
|
||||||
|
try:
|
||||||
|
cv.url(user_input[CONF_URL])
|
||||||
|
except vol.Invalid:
|
||||||
|
errors[CONF_URL] = "invalid_url"
|
||||||
|
if set(user_input) == {CONF_URL}:
|
||||||
|
errors["base"] = "no_webhooks_provided"
|
||||||
|
|
||||||
|
if not errors:
|
||||||
|
webhook_data = [
|
||||||
|
{
|
||||||
|
"auth": secrets.token_hex(32),
|
||||||
|
"name": webhook_name,
|
||||||
|
"webhook_id": webhook_generate_id(),
|
||||||
|
}
|
||||||
|
for key, webhook_name in user_input.items()
|
||||||
|
if key != CONF_URL
|
||||||
|
]
|
||||||
|
for webhook in webhook_data:
|
||||||
|
wh_def: ekey_bionyxpy.WebhookData = {
|
||||||
|
"integrationName": "Home Assistant",
|
||||||
|
"functionName": webhook["name"],
|
||||||
|
"locationName": "Home Assistant",
|
||||||
|
"definition": {
|
||||||
|
"url": user_input[CONF_URL]
|
||||||
|
+ webhook_generate_path(webhook["webhook_id"]),
|
||||||
|
"authentication": {"apiAuthenticationType": "None"},
|
||||||
|
"securityLevel": "AllowHttp",
|
||||||
|
"method": "Post",
|
||||||
|
"body": {
|
||||||
|
"contentType": "application/json",
|
||||||
|
"content": json.dumps({"auth": webhook["auth"]}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
webhook["ekey_id"] = (await system.add_webhook(wh_def)).webhook_id
|
||||||
|
return self.async_create_entry(
|
||||||
|
title=self._data["system"].system_name,
|
||||||
|
data={"webhooks": webhook_data},
|
||||||
|
)
|
||||||
|
|
||||||
|
data_schema: dict[Any, Any] = {
|
||||||
|
vol.Optional(f"webhook{i + 1}"): vol.All(str, vol.Length(max=50))
|
||||||
|
for i in range(self._data["system"].function_webhook_quotas["free"])
|
||||||
|
}
|
||||||
|
data_schema[vol.Required(CONF_URL)] = str
|
||||||
|
return self.async_show_form(
|
||||||
|
step_id="webhooks",
|
||||||
|
data_schema=self.add_suggested_values_to_schema(
|
||||||
|
vol.Schema(data_schema),
|
||||||
|
{
|
||||||
|
CONF_URL: get_url(
|
||||||
|
self.hass,
|
||||||
|
allow_ip=True,
|
||||||
|
prefer_external=False,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
| (user_input or {}),
|
||||||
|
),
|
||||||
|
errors=errors,
|
||||||
|
description_placeholders={
|
||||||
|
"webhooks_available": str(
|
||||||
|
self._data["system"].function_webhook_quotas["free"]
|
||||||
|
),
|
||||||
|
"ekeybionyx": INTEGRATION_NAME,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
async def async_step_delete_webhooks(
|
||||||
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
) -> ConfigFlowResult:
|
||||||
|
"""Form to delete Webhooks."""
|
||||||
|
if user_input is None:
|
||||||
|
return self.async_show_form(step_id="delete_webhooks")
|
||||||
|
for webhook in await self._data["system"].get_webhooks():
|
||||||
|
await webhook.delete()
|
||||||
|
return await self.async_step_wait_for_deletion(user_input=None)
|
||||||
|
|
||||||
|
async def async_step_wait_for_deletion(
|
||||||
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
) -> ConfigFlowResult:
|
||||||
|
"""Wait for webhooks to be deleted in another flow."""
|
||||||
|
uncompleted_task: asyncio.Task[None] | None = None
|
||||||
|
|
||||||
|
if not self.check_deletion_task:
|
||||||
|
self.check_deletion_task = self.hass.async_create_task(
|
||||||
|
self.async_check_deletion_status()
|
||||||
|
)
|
||||||
|
if not self.check_deletion_task.done():
|
||||||
|
progress_action = "check_deletion_status"
|
||||||
|
uncompleted_task = self.check_deletion_task
|
||||||
|
if uncompleted_task:
|
||||||
|
return self.async_show_progress(
|
||||||
|
step_id="wait_for_deletion",
|
||||||
|
description_placeholders={"ekeybionyx": INTEGRATION_NAME},
|
||||||
|
progress_action=progress_action,
|
||||||
|
progress_task=uncompleted_task,
|
||||||
|
)
|
||||||
|
self.check_deletion_task = None
|
||||||
|
return self.async_show_progress_done(next_step_id="webhooks")
|
||||||
|
|
||||||
|
async def async_check_deletion_status(self) -> None:
|
||||||
|
"""Check if webhooks have been deleted."""
|
||||||
|
while True:
|
||||||
|
self._data["systems"] = await self._data["api"].get_systems()
|
||||||
|
self._data["system"] = [
|
||||||
|
s
|
||||||
|
for s in self._data["systems"]
|
||||||
|
if s.system_id == self._data["system"].system_id
|
||||||
|
][0]
|
||||||
|
if self._data["system"].function_webhook_quotas["used"] == 0:
|
||||||
|
break
|
||||||
|
await asyncio.sleep(5)
|
||||||
13
homeassistant/components/ekeybionyx/const.py
Normal file
13
homeassistant/components/ekeybionyx/const.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
"""Constants for the Ekey Bionyx integration."""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
DOMAIN = "ekeybionyx"
|
||||||
|
INTEGRATION_NAME = "ekey bionyx"
|
||||||
|
|
||||||
|
LOGGER = logging.getLogger(__package__)
|
||||||
|
|
||||||
|
OAUTH2_AUTHORIZE = "https://ekeybionyxprod.b2clogin.com/ekeybionyxprod.onmicrosoft.com/B2C_1_sign_in_v2/oauth2/v2.0/authorize"
|
||||||
|
OAUTH2_TOKEN = "https://ekeybionyxprod.b2clogin.com/ekeybionyxprod.onmicrosoft.com/B2C_1_sign_in_v2/oauth2/v2.0/token"
|
||||||
|
API_URL = "https://api.bionyx.io/3rd-party/api"
|
||||||
|
SCOPE = "https://ekeybionyxprod.onmicrosoft.com/3rd-party-api/api-access"
|
||||||
70
homeassistant/components/ekeybionyx/event.py
Normal file
70
homeassistant/components/ekeybionyx/event.py
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
"""Event platform for ekey bionyx integration."""
|
||||||
|
|
||||||
|
from aiohttp.hdrs import METH_POST
|
||||||
|
from aiohttp.web import Request, Response
|
||||||
|
|
||||||
|
from homeassistant.components.event import EventDeviceClass, EventEntity
|
||||||
|
from homeassistant.components.webhook import (
|
||||||
|
async_register as webhook_register,
|
||||||
|
async_unregister as webhook_unregister,
|
||||||
|
)
|
||||||
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
|
from . import EkeyBionyxConfigEntry
|
||||||
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entry: EkeyBionyxConfigEntry,
|
||||||
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
|
"""Set up Ekey event."""
|
||||||
|
async_add_entities(EkeyEvent(data) for data in entry.data["webhooks"])
|
||||||
|
|
||||||
|
|
||||||
|
class EkeyEvent(EventEntity):
|
||||||
|
"""Ekey Event."""
|
||||||
|
|
||||||
|
_attr_device_class = EventDeviceClass.BUTTON
|
||||||
|
_attr_event_types = ["event happened"]
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
data: dict[str, str],
|
||||||
|
) -> None:
|
||||||
|
"""Initialise a Ekey event entity."""
|
||||||
|
self._attr_name = data["name"]
|
||||||
|
self._attr_unique_id = data["ekey_id"]
|
||||||
|
self._webhook_id = data["webhook_id"]
|
||||||
|
self._auth = data["auth"]
|
||||||
|
|
||||||
|
@callback
|
||||||
|
def _async_handle_event(self) -> None:
|
||||||
|
"""Handle the webhook event."""
|
||||||
|
self._trigger_event("event happened")
|
||||||
|
self.async_write_ha_state()
|
||||||
|
|
||||||
|
async def async_added_to_hass(self) -> None:
|
||||||
|
"""Register callbacks with your device API/library."""
|
||||||
|
|
||||||
|
async def async_webhook_handler(
|
||||||
|
hass: HomeAssistant, webhook_id: str, request: Request
|
||||||
|
) -> Response | None:
|
||||||
|
if (await request.json())["auth"] == self._auth:
|
||||||
|
self._async_handle_event()
|
||||||
|
return None
|
||||||
|
|
||||||
|
webhook_register(
|
||||||
|
self.hass,
|
||||||
|
DOMAIN,
|
||||||
|
f"Ekey {self._attr_name}",
|
||||||
|
self._webhook_id,
|
||||||
|
async_webhook_handler,
|
||||||
|
allowed_methods=[METH_POST],
|
||||||
|
)
|
||||||
|
|
||||||
|
async def async_will_remove_from_hass(self) -> None:
|
||||||
|
"""Unregister Webhook."""
|
||||||
|
webhook_unregister(self.hass, self._webhook_id)
|
||||||
11
homeassistant/components/ekeybionyx/manifest.json
Normal file
11
homeassistant/components/ekeybionyx/manifest.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"domain": "ekeybionyx",
|
||||||
|
"name": "ekey bionyx",
|
||||||
|
"codeowners": ["@richardpolzer"],
|
||||||
|
"config_flow": true,
|
||||||
|
"dependencies": ["application_credentials", "http"],
|
||||||
|
"documentation": "https://www.home-assistant.io/integrations/ekeybionyx",
|
||||||
|
"iot_class": "local_push",
|
||||||
|
"quality_scale": "bronze",
|
||||||
|
"requirements": ["ekey-bionyxpy==1.0.0"]
|
||||||
|
}
|
||||||
92
homeassistant/components/ekeybionyx/quality_scale.yaml
Normal file
92
homeassistant/components/ekeybionyx/quality_scale.yaml
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
rules:
|
||||||
|
# Bronze
|
||||||
|
action-setup:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration does not provide actions.
|
||||||
|
appropriate-polling:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration does not poll.
|
||||||
|
brands: done
|
||||||
|
common-modules: done
|
||||||
|
config-flow: done
|
||||||
|
config-flow-test-coverage: done
|
||||||
|
dependency-transparency: done
|
||||||
|
docs-actions:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration does not provide actions.
|
||||||
|
docs-high-level-description: done
|
||||||
|
docs-installation-instructions: done
|
||||||
|
docs-removal-instructions: done
|
||||||
|
entity-event-setup: done
|
||||||
|
entity-unique-id: done
|
||||||
|
has-entity-name: done
|
||||||
|
runtime-data:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration does not connect to any device or service.
|
||||||
|
test-before-configure: done
|
||||||
|
test-before-setup:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration does not connect to any device or service.
|
||||||
|
unique-config-entry: done
|
||||||
|
|
||||||
|
# Silver
|
||||||
|
action-exceptions:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration does not provide actions.
|
||||||
|
config-entry-unloading: done
|
||||||
|
docs-configuration-parameters: todo
|
||||||
|
docs-installation-parameters: todo
|
||||||
|
entity-unavailable:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration has no way of knowing if the fingerprint reader is offline.
|
||||||
|
integration-owner: done
|
||||||
|
log-when-unavailable:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration has no way of knowing if the fingerprint reader is offline.
|
||||||
|
parallel-updates:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration does not poll.
|
||||||
|
reauthentication-flow:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration does not store the tokens.
|
||||||
|
test-coverage: todo
|
||||||
|
|
||||||
|
# Gold
|
||||||
|
devices:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration does not connect to any device or service.
|
||||||
|
diagnostics: todo
|
||||||
|
discovery-update-info:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration does not support discovery.
|
||||||
|
discovery:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration does not support discovery.
|
||||||
|
docs-data-update: todo
|
||||||
|
docs-examples: todo
|
||||||
|
docs-known-limitations: done
|
||||||
|
docs-supported-devices: todo
|
||||||
|
docs-supported-functions: todo
|
||||||
|
docs-troubleshooting: todo
|
||||||
|
docs-use-cases: todo
|
||||||
|
dynamic-devices:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration does not connect to any device or service.
|
||||||
|
entity-category: todo
|
||||||
|
entity-device-class: done
|
||||||
|
entity-disabled-by-default:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration has no entities that should be disabled by default.
|
||||||
|
entity-translations: todo
|
||||||
|
exception-translations: todo
|
||||||
|
icon-translations: todo
|
||||||
|
reconfiguration-flow: todo
|
||||||
|
repair-issues: todo
|
||||||
|
stale-devices:
|
||||||
|
status: exempt
|
||||||
|
comment: This integration does not connect to any device or service.
|
||||||
|
|
||||||
|
# Platinum
|
||||||
|
async-dependency: done
|
||||||
|
inject-websession: done
|
||||||
|
strict-typing: todo
|
||||||
66
homeassistant/components/ekeybionyx/strings.json
Normal file
66
homeassistant/components/ekeybionyx/strings.json
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
"config": {
|
||||||
|
"step": {
|
||||||
|
"pick_implementation": {
|
||||||
|
"title": "[%key:common::config_flow::title::oauth2_pick_implementation%]"
|
||||||
|
},
|
||||||
|
"choose_system": {
|
||||||
|
"data": {
|
||||||
|
"system": "System"
|
||||||
|
},
|
||||||
|
"data_description": {
|
||||||
|
"system": "System the event entities should be set up for."
|
||||||
|
},
|
||||||
|
"description": "Please select the {ekeybionyx} system which you want to connect to Home Assistant."
|
||||||
|
},
|
||||||
|
"webhooks": {
|
||||||
|
"description": "Please name your event entities. These event entities will be mapped as functions in the {ekeybionyx} app. You can configure up to {webhooks_available} event entities. Leaving a name empty will skip the setup of that event entity.",
|
||||||
|
"data": {
|
||||||
|
"webhook1": "Event entity 1",
|
||||||
|
"webhook2": "Event entity 2",
|
||||||
|
"webhook3": "Event entity 3",
|
||||||
|
"webhook4": "Event entity 4",
|
||||||
|
"webhook5": "Event entity 5",
|
||||||
|
"url": "Home Assistant URL"
|
||||||
|
},
|
||||||
|
"data_description": {
|
||||||
|
"webhook1": "Name of event entity 1 that will be mapped into a function",
|
||||||
|
"webhook2": "Name of event entity 2 that will be mapped into a function",
|
||||||
|
"webhook3": "Name of event entity 3 that will be mapped into a function",
|
||||||
|
"webhook4": "Name of event entity 4 that will be mapped into a function",
|
||||||
|
"webhook5": "Name of event entity 5 that will be mapped into a function",
|
||||||
|
"url": "Home Assistant instance URL which can be reached from the fingerprint controller"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete_webhooks": {
|
||||||
|
"description": "This system has already been connected to Home Assistant. If you continue, the previously configured functions will be deleted."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"progress": {
|
||||||
|
"check_deletion_status": "Please open the {ekeybionyx} app and confirm the deletion of the functions."
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"invalid_name": "Name is invalid",
|
||||||
|
"invalid_url": "URL is invalid",
|
||||||
|
"no_webhooks_provided": "No event names provided"
|
||||||
|
},
|
||||||
|
"abort": {
|
||||||
|
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]",
|
||||||
|
"already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]",
|
||||||
|
"oauth_error": "[%key:common::config_flow::abort::oauth2_error%]",
|
||||||
|
"oauth_failed": "[%key:common::config_flow::abort::oauth2_failed%]",
|
||||||
|
"oauth_timeout": "[%key:common::config_flow::abort::oauth2_timeout%]",
|
||||||
|
"oauth_unauthorized": "[%key:common::config_flow::abort::oauth2_unauthorized%]",
|
||||||
|
"missing_configuration": "[%key:common::config_flow::abort::oauth2_missing_configuration%]",
|
||||||
|
"authorize_url_timeout": "[%key:common::config_flow::abort::oauth2_authorize_url_timeout%]",
|
||||||
|
"no_url_available": "[%key:common::config_flow::abort::oauth2_no_url_available%]",
|
||||||
|
"user_rejected_authorize": "[%key:common::config_flow::abort::oauth2_user_rejected_authorize%]",
|
||||||
|
"no_available_webhooks": "There are no available webhooks in the {ekeybionyx} system. Please delete some and try again.",
|
||||||
|
"no_own_systems": "Your account does not have admin access to any systems.",
|
||||||
|
"cannot_connect": "Connection to {ekeybionyx} failed. Please check your Internet connection and try again."
|
||||||
|
},
|
||||||
|
"create_entry": {
|
||||||
|
"default": "[%key:common::config_flow::create_entry::authenticated%]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,14 +3,15 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from enum import IntEnum
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from pyephember2.pyephember2 import (
|
from pyephember2.pyephember2 import (
|
||||||
EphEmber,
|
EphEmber,
|
||||||
ZoneMode,
|
ZoneMode,
|
||||||
|
boiler_state,
|
||||||
zone_current_temperature,
|
zone_current_temperature,
|
||||||
zone_is_active,
|
|
||||||
zone_is_hotwater,
|
zone_is_hotwater,
|
||||||
zone_mode,
|
zone_mode,
|
||||||
zone_name,
|
zone_name,
|
||||||
@@ -53,6 +54,15 @@ EPH_TO_HA_STATE = {
|
|||||||
"OFF": HVACMode.OFF,
|
"OFF": HVACMode.OFF,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class EPHBoilerStates(IntEnum):
|
||||||
|
"""Boiler states for a zone given by the api."""
|
||||||
|
|
||||||
|
FIXME = 0
|
||||||
|
OFF = 1
|
||||||
|
ON = 2
|
||||||
|
|
||||||
|
|
||||||
HA_STATE_TO_EPH = {value: key for key, value in EPH_TO_HA_STATE.items()}
|
HA_STATE_TO_EPH = {value: key for key, value in EPH_TO_HA_STATE.items()}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,7 +133,7 @@ class EphEmberThermostat(ClimateEntity):
|
|||||||
@property
|
@property
|
||||||
def hvac_action(self) -> HVACAction:
|
def hvac_action(self) -> HVACAction:
|
||||||
"""Return current HVAC action."""
|
"""Return current HVAC action."""
|
||||||
if zone_is_active(self._zone):
|
if boiler_state(self._zone) == EPHBoilerStates.ON:
|
||||||
return HVACAction.HEATING
|
return HVACAction.HEATING
|
||||||
|
|
||||||
return HVACAction.IDLE
|
return HVACAction.IDLE
|
||||||
|
|||||||
11
homeassistant/components/esphome/analytics.py
Normal file
11
homeassistant/components/esphome/analytics.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
"""Analytics platform."""
|
||||||
|
|
||||||
|
from homeassistant.components.analytics import AnalyticsInput, AnalyticsModifications
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
|
||||||
|
async def async_modify_analytics(
|
||||||
|
hass: HomeAssistant, analytics_input: AnalyticsInput
|
||||||
|
) -> AnalyticsModifications:
|
||||||
|
"""Modify the analytics."""
|
||||||
|
return AnalyticsModifications(remove=True)
|
||||||
@@ -57,6 +57,7 @@ from .manager import async_replace_device
|
|||||||
|
|
||||||
ERROR_REQUIRES_ENCRYPTION_KEY = "requires_encryption_key"
|
ERROR_REQUIRES_ENCRYPTION_KEY = "requires_encryption_key"
|
||||||
ERROR_INVALID_ENCRYPTION_KEY = "invalid_psk"
|
ERROR_INVALID_ENCRYPTION_KEY = "invalid_psk"
|
||||||
|
ERROR_INVALID_PASSWORD_AUTH = "invalid_auth"
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ZERO_NOISE_PSK = "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDA="
|
ZERO_NOISE_PSK = "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDA="
|
||||||
@@ -137,6 +138,11 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self._password = ""
|
self._password = ""
|
||||||
return await self._async_authenticate_or_add()
|
return await self._async_authenticate_or_add()
|
||||||
|
|
||||||
|
if error == ERROR_INVALID_PASSWORD_AUTH or (
|
||||||
|
error is None and self._device_info and self._device_info.uses_password
|
||||||
|
):
|
||||||
|
return await self.async_step_authenticate()
|
||||||
|
|
||||||
if error is None and entry_data.get(CONF_NOISE_PSK):
|
if error is None and entry_data.get(CONF_NOISE_PSK):
|
||||||
# Device was configured with encryption but now connects without it.
|
# Device was configured with encryption but now connects without it.
|
||||||
# Check if it's the same device before offering to remove encryption.
|
# Check if it's the same device before offering to remove encryption.
|
||||||
@@ -690,13 +696,15 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
cli = APIClient(
|
cli = APIClient(
|
||||||
host,
|
host,
|
||||||
port or DEFAULT_PORT,
|
port or DEFAULT_PORT,
|
||||||
"",
|
self._password or "",
|
||||||
zeroconf_instance=zeroconf_instance,
|
zeroconf_instance=zeroconf_instance,
|
||||||
noise_psk=noise_psk,
|
noise_psk=noise_psk,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
await cli.connect()
|
await cli.connect()
|
||||||
self._device_info = await cli.device_info()
|
self._device_info = await cli.device_info()
|
||||||
|
except InvalidAuthAPIError:
|
||||||
|
return ERROR_INVALID_PASSWORD_AUTH
|
||||||
except RequiresEncryptionAPIError:
|
except RequiresEncryptionAPIError:
|
||||||
return ERROR_REQUIRES_ENCRYPTION_KEY
|
return ERROR_REQUIRES_ENCRYPTION_KEY
|
||||||
except InvalidEncryptionKeyAPIError as ex:
|
except InvalidEncryptionKeyAPIError as ex:
|
||||||
|
|||||||
@@ -372,6 +372,9 @@ class ESPHomeManager:
|
|||||||
"""Subscribe to states and list entities on successful API login."""
|
"""Subscribe to states and list entities on successful API login."""
|
||||||
try:
|
try:
|
||||||
await self._on_connect()
|
await self._on_connect()
|
||||||
|
except InvalidAuthAPIError as err:
|
||||||
|
_LOGGER.warning("Authentication failed for %s: %s", self.host, err)
|
||||||
|
await self._start_reauth_and_disconnect()
|
||||||
except APIConnectionError as err:
|
except APIConnectionError as err:
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Error getting setting up connection for %s: %s", self.host, err
|
"Error getting setting up connection for %s: %s", self.host, err
|
||||||
@@ -641,7 +644,14 @@ class ESPHomeManager:
|
|||||||
if self.reconnect_logic:
|
if self.reconnect_logic:
|
||||||
await self.reconnect_logic.stop()
|
await self.reconnect_logic.stop()
|
||||||
return
|
return
|
||||||
|
await self._start_reauth_and_disconnect()
|
||||||
|
|
||||||
|
async def _start_reauth_and_disconnect(self) -> None:
|
||||||
|
"""Start reauth flow and stop reconnection attempts."""
|
||||||
self.entry.async_start_reauth(self.hass)
|
self.entry.async_start_reauth(self.hass)
|
||||||
|
await self.cli.disconnect()
|
||||||
|
if self.reconnect_logic:
|
||||||
|
await self.reconnect_logic.stop()
|
||||||
|
|
||||||
async def _handle_dynamic_encryption_key(
|
async def _handle_dynamic_encryption_key(
|
||||||
self, device_info: EsphomeDeviceInfo
|
self, device_info: EsphomeDeviceInfo
|
||||||
@@ -1063,7 +1073,7 @@ def _async_register_service(
|
|||||||
service_name,
|
service_name,
|
||||||
{
|
{
|
||||||
"description": (
|
"description": (
|
||||||
f"Calls the service {service.name} of the node {device_info.name}"
|
f"Performs the action {service.name} of the node {device_info.name}"
|
||||||
),
|
),
|
||||||
"fields": fields,
|
"fields": fields,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
"mqtt": ["esphome/discover/#"],
|
"mqtt": ["esphome/discover/#"],
|
||||||
"quality_scale": "platinum",
|
"quality_scale": "platinum",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"aioesphomeapi==41.9.0",
|
"aioesphomeapi==41.11.0",
|
||||||
"esphome-dashboard-api==1.3.0",
|
"esphome-dashboard-api==1.3.0",
|
||||||
"bleak-esphome==3.3.0"
|
"bleak-esphome==3.3.0"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -26,11 +26,14 @@ class EzvizEntity(CoordinatorEntity[EzvizDataUpdateCoordinator], Entity):
|
|||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._serial = serial
|
self._serial = serial
|
||||||
self._camera_name = self.data["name"]
|
self._camera_name = self.data["name"]
|
||||||
|
|
||||||
|
connections = set()
|
||||||
|
if mac_address := self.data["mac_address"]:
|
||||||
|
connections.add((CONNECTION_NETWORK_MAC, mac_address))
|
||||||
|
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, serial)},
|
identifiers={(DOMAIN, serial)},
|
||||||
connections={
|
connections=connections,
|
||||||
(CONNECTION_NETWORK_MAC, self.data["mac_address"]),
|
|
||||||
},
|
|
||||||
manufacturer=MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
model=self.data["device_sub_category"],
|
model=self.data["device_sub_category"],
|
||||||
name=self.data["name"],
|
name=self.data["name"],
|
||||||
@@ -62,11 +65,14 @@ class EzvizBaseEntity(Entity):
|
|||||||
self._serial = serial
|
self._serial = serial
|
||||||
self.coordinator = coordinator
|
self.coordinator = coordinator
|
||||||
self._camera_name = self.data["name"]
|
self._camera_name = self.data["name"]
|
||||||
|
|
||||||
|
connections = set()
|
||||||
|
if mac_address := self.data["mac_address"]:
|
||||||
|
connections.add((CONNECTION_NETWORK_MAC, mac_address))
|
||||||
|
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, serial)},
|
identifiers={(DOMAIN, serial)},
|
||||||
connections={
|
connections=connections,
|
||||||
(CONNECTION_NETWORK_MAC, self.data["mac_address"]),
|
|
||||||
},
|
|
||||||
manufacturer=MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
model=self.data["device_sub_category"],
|
model=self.data["device_sub_category"],
|
||||||
name=self.data["name"],
|
name=self.data["name"],
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ async def async_get_config_entry_diagnostics(
|
|||||||
}
|
}
|
||||||
for _, device in avm_wrapper.devices.items()
|
for _, device in avm_wrapper.devices.items()
|
||||||
],
|
],
|
||||||
|
"cpu_temperatures": await hass.async_add_executor_job(
|
||||||
|
avm_wrapper.fritz_status.get_cpu_temperatures
|
||||||
|
),
|
||||||
"wan_link_properties": await avm_wrapper.async_get_wan_link_properties(),
|
"wan_link_properties": await avm_wrapper.async_get_wan_link_properties(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,5 +20,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/frontend",
|
"documentation": "https://www.home-assistant.io/integrations/frontend",
|
||||||
"integration_type": "system",
|
"integration_type": "system",
|
||||||
"quality_scale": "internal",
|
"quality_scale": "internal",
|
||||||
"requirements": ["home-assistant-frontend==20250903.5"]
|
"requirements": ["home-assistant-frontend==20251001.0"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,10 +77,10 @@ class GeniusDevice(GeniusEntity):
|
|||||||
|
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Update an entity's state data."""
|
"""Update an entity's state data."""
|
||||||
if "_state" in self._device.data: # only via v3 API
|
if (state := self._device.data.get("_state")) and (
|
||||||
self._last_comms = dt_util.utc_from_timestamp(
|
last_comms := state.get("lastComms")
|
||||||
self._device.data["_state"]["lastComms"]
|
) is not None: # only via v3 API
|
||||||
)
|
self._last_comms = dt_util.utc_from_timestamp(last_comms)
|
||||||
|
|
||||||
|
|
||||||
class GeniusZone(GeniusEntity):
|
class GeniusZone(GeniusEntity):
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from homeassistant.components.homeassistant_hardware import firmware_config_flow
|
|||||||
from homeassistant.components.homeassistant_hardware.util import (
|
from homeassistant.components.homeassistant_hardware.util import (
|
||||||
ApplicationType,
|
ApplicationType,
|
||||||
FirmwareInfo,
|
FirmwareInfo,
|
||||||
|
ResetTarget,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
@@ -67,6 +68,11 @@ class ZBT2FirmwareMixin(ConfigEntryBaseFlow, FirmwareInstallFlowProtocol):
|
|||||||
|
|
||||||
context: ConfigFlowContext
|
context: ConfigFlowContext
|
||||||
|
|
||||||
|
# `rts_dtr` targets older adapters, `baudrate` works for newer ones. The reason we
|
||||||
|
# try them in this order is that on older adapters `baudrate` entered the ESP32-S3
|
||||||
|
# bootloader instead of the MG24 bootloader.
|
||||||
|
BOOTLOADER_RESET_METHODS = [ResetTarget.RTS_DTR, ResetTarget.BAUDRATE]
|
||||||
|
|
||||||
async def async_step_install_zigbee_firmware(
|
async def async_step_install_zigbee_firmware(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
|
|||||||
@@ -27,6 +27,12 @@
|
|||||||
"install_addon": {
|
"install_addon": {
|
||||||
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::install_addon::title%]"
|
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::install_addon::title%]"
|
||||||
},
|
},
|
||||||
|
"install_thread_firmware": {
|
||||||
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_thread_firmware::title%]"
|
||||||
|
},
|
||||||
|
"install_zigbee_firmware": {
|
||||||
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_zigbee_firmware::title%]"
|
||||||
|
},
|
||||||
"notify_channel_change": {
|
"notify_channel_change": {
|
||||||
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::notify_channel_change::title%]",
|
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::notify_channel_change::title%]",
|
||||||
"description": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::notify_channel_change::description%]"
|
"description": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::notify_channel_change::description%]"
|
||||||
@@ -69,12 +75,10 @@
|
|||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_zigbee::description%]"
|
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_zigbee::description%]"
|
||||||
},
|
},
|
||||||
"install_otbr_addon": {
|
"install_otbr_addon": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::title%]"
|
||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::description%]"
|
|
||||||
},
|
},
|
||||||
"start_otbr_addon": {
|
"start_otbr_addon": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::title%]"
|
||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::description%]"
|
|
||||||
},
|
},
|
||||||
"otbr_failed": {
|
"otbr_failed": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::otbr_failed::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::otbr_failed::title%]",
|
||||||
@@ -129,14 +133,21 @@
|
|||||||
},
|
},
|
||||||
"progress": {
|
"progress": {
|
||||||
"install_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::install_addon%]",
|
"install_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::install_addon%]",
|
||||||
|
"install_firmware": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_firmware%]",
|
||||||
|
"install_otbr_addon": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_otbr_addon%]",
|
||||||
"start_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
"start_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
||||||
"start_otbr_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
"start_otbr_addon": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::start_otbr_addon%]"
|
||||||
"install_firmware": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_firmware%]"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"flow_title": "{model}",
|
"flow_title": "{model}",
|
||||||
"step": {
|
"step": {
|
||||||
|
"install_thread_firmware": {
|
||||||
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_thread_firmware::title%]"
|
||||||
|
},
|
||||||
|
"install_zigbee_firmware": {
|
||||||
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_zigbee_firmware::title%]"
|
||||||
|
},
|
||||||
"pick_firmware": {
|
"pick_firmware": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::pick_firmware::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::pick_firmware::title%]",
|
||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::pick_firmware::description%]",
|
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::pick_firmware::description%]",
|
||||||
@@ -158,12 +169,10 @@
|
|||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_zigbee::description%]"
|
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_zigbee::description%]"
|
||||||
},
|
},
|
||||||
"install_otbr_addon": {
|
"install_otbr_addon": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::title%]"
|
||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::description%]"
|
|
||||||
},
|
},
|
||||||
"start_otbr_addon": {
|
"start_otbr_addon": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::title%]"
|
||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::description%]"
|
|
||||||
},
|
},
|
||||||
"otbr_failed": {
|
"otbr_failed": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::otbr_failed::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::otbr_failed::title%]",
|
||||||
@@ -215,9 +224,10 @@
|
|||||||
},
|
},
|
||||||
"progress": {
|
"progress": {
|
||||||
"install_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::install_addon%]",
|
"install_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::install_addon%]",
|
||||||
|
"install_firmware": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_firmware%]",
|
||||||
|
"install_otbr_addon": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_otbr_addon%]",
|
||||||
"start_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
"start_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
||||||
"start_otbr_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
"start_otbr_addon": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::start_otbr_addon%]"
|
||||||
"install_firmware": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_firmware%]"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"exceptions": {
|
"exceptions": {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from homeassistant.components.homeassistant_hardware.update import (
|
|||||||
from homeassistant.components.homeassistant_hardware.util import (
|
from homeassistant.components.homeassistant_hardware.util import (
|
||||||
ApplicationType,
|
ApplicationType,
|
||||||
FirmwareInfo,
|
FirmwareInfo,
|
||||||
|
ResetTarget,
|
||||||
)
|
)
|
||||||
from homeassistant.components.update import UpdateDeviceClass
|
from homeassistant.components.update import UpdateDeviceClass
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@@ -156,7 +157,7 @@ async def async_setup_entry(
|
|||||||
class FirmwareUpdateEntity(BaseFirmwareUpdateEntity):
|
class FirmwareUpdateEntity(BaseFirmwareUpdateEntity):
|
||||||
"""Connect ZBT-2 firmware update entity."""
|
"""Connect ZBT-2 firmware update entity."""
|
||||||
|
|
||||||
bootloader_reset_type = None
|
bootloader_reset_methods = [ResetTarget.RTS_DTR, ResetTarget.BAUDRATE]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ from homeassistant.config_entries import (
|
|||||||
OptionsFlow,
|
OptionsFlow,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import AbortFlow
|
from homeassistant.data_entry_flow import AbortFlow, progress_step
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.hassio import is_hassio
|
from homeassistant.helpers.hassio import is_hassio
|
||||||
@@ -39,6 +39,7 @@ from .util import (
|
|||||||
FirmwareInfo,
|
FirmwareInfo,
|
||||||
OwningAddon,
|
OwningAddon,
|
||||||
OwningIntegration,
|
OwningIntegration,
|
||||||
|
ResetTarget,
|
||||||
async_flash_silabs_firmware,
|
async_flash_silabs_firmware,
|
||||||
get_otbr_addon_manager,
|
get_otbr_addon_manager,
|
||||||
guess_firmware_info,
|
guess_firmware_info,
|
||||||
@@ -61,6 +62,13 @@ class PickedFirmwareType(StrEnum):
|
|||||||
ZIGBEE = "zigbee"
|
ZIGBEE = "zigbee"
|
||||||
|
|
||||||
|
|
||||||
|
class ZigbeeFlowStrategy(StrEnum):
|
||||||
|
"""Zigbee setup strategies that can be picked."""
|
||||||
|
|
||||||
|
ADVANCED = "advanced"
|
||||||
|
RECOMMENDED = "recommended"
|
||||||
|
|
||||||
|
|
||||||
class ZigbeeIntegration(StrEnum):
|
class ZigbeeIntegration(StrEnum):
|
||||||
"""Zigbee integrations that can be picked."""
|
"""Zigbee integrations that can be picked."""
|
||||||
|
|
||||||
@@ -72,9 +80,10 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
"""Base flow to install firmware."""
|
"""Base flow to install firmware."""
|
||||||
|
|
||||||
ZIGBEE_BAUDRATE = 115200 # Default, subclasses may override
|
ZIGBEE_BAUDRATE = 115200 # Default, subclasses may override
|
||||||
_failed_addon_name: str
|
BOOTLOADER_RESET_METHODS: list[ResetTarget] = [] # Default, subclasses may override
|
||||||
_failed_addon_reason: str
|
|
||||||
_picked_firmware_type: PickedFirmwareType
|
_picked_firmware_type: PickedFirmwareType
|
||||||
|
_zigbee_flow_strategy: ZigbeeFlowStrategy = ZigbeeFlowStrategy.RECOMMENDED
|
||||||
|
|
||||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||||
"""Instantiate base flow."""
|
"""Instantiate base flow."""
|
||||||
@@ -85,8 +94,6 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
self._hardware_name: str = "unknown" # To be set in a subclass
|
self._hardware_name: str = "unknown" # To be set in a subclass
|
||||||
self._zigbee_integration = ZigbeeIntegration.ZHA
|
self._zigbee_integration = ZigbeeIntegration.ZHA
|
||||||
|
|
||||||
self.addon_install_task: asyncio.Task | None = None
|
|
||||||
self.addon_start_task: asyncio.Task | None = None
|
|
||||||
self.addon_uninstall_task: asyncio.Task | None = None
|
self.addon_uninstall_task: asyncio.Task | None = None
|
||||||
self.firmware_install_task: asyncio.Task[None] | None = None
|
self.firmware_install_task: asyncio.Task[None] | None = None
|
||||||
self.installing_firmware_name: str | None = None
|
self.installing_firmware_name: str | None = None
|
||||||
@@ -127,8 +134,12 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Pick Thread or Zigbee firmware."""
|
"""Pick Thread or Zigbee firmware."""
|
||||||
# Determine if ZHA or Thread are already configured to present migrate options
|
# Determine if ZHA or Thread are already configured to present migrate options
|
||||||
zha_entries = self.hass.config_entries.async_entries(ZHA_DOMAIN)
|
zha_entries = self.hass.config_entries.async_entries(
|
||||||
otbr_entries = self.hass.config_entries.async_entries(OTBR_DOMAIN)
|
ZHA_DOMAIN, include_ignore=False
|
||||||
|
)
|
||||||
|
otbr_entries = self.hass.config_entries.async_entries(
|
||||||
|
OTBR_DOMAIN, include_ignore=False
|
||||||
|
)
|
||||||
|
|
||||||
return self.async_show_menu(
|
return self.async_show_menu(
|
||||||
step_id="pick_firmware",
|
step_id="pick_firmware",
|
||||||
@@ -147,34 +158,6 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
description_placeholders=self._get_translation_placeholders(),
|
description_placeholders=self._get_translation_placeholders(),
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _probe_firmware_info(
|
|
||||||
self,
|
|
||||||
probe_methods: tuple[ApplicationType, ...] = (
|
|
||||||
# We probe in order of frequency: Zigbee, Thread, then multi-PAN
|
|
||||||
ApplicationType.GECKO_BOOTLOADER,
|
|
||||||
ApplicationType.EZSP,
|
|
||||||
ApplicationType.SPINEL,
|
|
||||||
ApplicationType.CPC,
|
|
||||||
),
|
|
||||||
) -> bool:
|
|
||||||
"""Probe the firmware currently on the device."""
|
|
||||||
assert self._device is not None
|
|
||||||
|
|
||||||
self._probed_firmware_info = await probe_silabs_firmware_info(
|
|
||||||
self._device,
|
|
||||||
probe_methods=probe_methods,
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
|
||||||
self._probed_firmware_info is not None
|
|
||||||
and self._probed_firmware_info.firmware_type
|
|
||||||
in (
|
|
||||||
ApplicationType.EZSP,
|
|
||||||
ApplicationType.SPINEL,
|
|
||||||
ApplicationType.CPC,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
async def _install_firmware_step(
|
async def _install_firmware_step(
|
||||||
self,
|
self,
|
||||||
fw_update_url: str,
|
fw_update_url: str,
|
||||||
@@ -228,12 +211,6 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
expected_installed_firmware_type: ApplicationType,
|
expected_installed_firmware_type: ApplicationType,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Install firmware."""
|
"""Install firmware."""
|
||||||
if not await self._probe_firmware_info():
|
|
||||||
raise AbortFlow(
|
|
||||||
reason="unsupported_firmware",
|
|
||||||
description_placeholders=self._get_translation_placeholders(),
|
|
||||||
)
|
|
||||||
|
|
||||||
assert self._device is not None
|
assert self._device is not None
|
||||||
|
|
||||||
# Keep track of the firmware we're working with, for error messages
|
# Keep track of the firmware we're working with, for error messages
|
||||||
@@ -242,6 +219,8 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
# Installing new firmware is only truly required if the wrong type is
|
# Installing new firmware is only truly required if the wrong type is
|
||||||
# installed: upgrading to the latest release of the current firmware type
|
# installed: upgrading to the latest release of the current firmware type
|
||||||
# isn't strictly necessary for functionality.
|
# isn't strictly necessary for functionality.
|
||||||
|
self._probed_firmware_info = await probe_silabs_firmware_info(self._device)
|
||||||
|
|
||||||
firmware_install_required = self._probed_firmware_info is None or (
|
firmware_install_required = self._probed_firmware_info is None or (
|
||||||
self._probed_firmware_info.firmware_type != expected_installed_firmware_type
|
self._probed_firmware_info.firmware_type != expected_installed_firmware_type
|
||||||
)
|
)
|
||||||
@@ -293,12 +272,12 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
# Otherwise, fail
|
# Otherwise, fail
|
||||||
raise AbortFlow(reason="firmware_download_failed") from err
|
raise AbortFlow(reason="firmware_download_failed") from err
|
||||||
|
|
||||||
await async_flash_silabs_firmware(
|
self._probed_firmware_info = await async_flash_silabs_firmware(
|
||||||
hass=self.hass,
|
hass=self.hass,
|
||||||
device=self._device,
|
device=self._device,
|
||||||
fw_data=fw_data,
|
fw_data=fw_data,
|
||||||
expected_installed_firmware_type=expected_installed_firmware_type,
|
expected_installed_firmware_type=expected_installed_firmware_type,
|
||||||
bootloader_reset_type=None,
|
bootloader_reset_methods=self.BOOTLOADER_RESET_METHODS,
|
||||||
progress_callback=lambda offset, total: self.async_update_progress(
|
progress_callback=lambda offset, total: self.async_update_progress(
|
||||||
offset / total
|
offset / total
|
||||||
),
|
),
|
||||||
@@ -306,15 +285,6 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
|
|
||||||
async def _configure_and_start_otbr_addon(self) -> None:
|
async def _configure_and_start_otbr_addon(self) -> None:
|
||||||
"""Configure and start the OTBR addon."""
|
"""Configure and start the OTBR addon."""
|
||||||
|
|
||||||
# Before we start the addon, confirm that the correct firmware is running
|
|
||||||
# and populate `self._probed_firmware_info` with the correct information
|
|
||||||
if not await self._probe_firmware_info(probe_methods=(ApplicationType.SPINEL,)):
|
|
||||||
raise AbortFlow(
|
|
||||||
"unsupported_firmware",
|
|
||||||
description_placeholders=self._get_translation_placeholders(),
|
|
||||||
)
|
|
||||||
|
|
||||||
otbr_manager = get_otbr_addon_manager(self.hass)
|
otbr_manager = get_otbr_addon_manager(self.hass)
|
||||||
addon_info = await self._async_get_addon_info(otbr_manager)
|
addon_info = await self._async_get_addon_info(otbr_manager)
|
||||||
|
|
||||||
@@ -395,12 +365,14 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Select recommended installation type."""
|
"""Select recommended installation type."""
|
||||||
self._zigbee_integration = ZigbeeIntegration.ZHA
|
self._zigbee_integration = ZigbeeIntegration.ZHA
|
||||||
|
self._zigbee_flow_strategy = ZigbeeFlowStrategy.RECOMMENDED
|
||||||
return await self._async_continue_picked_firmware()
|
return await self._async_continue_picked_firmware()
|
||||||
|
|
||||||
async def async_step_zigbee_intent_custom(
|
async def async_step_zigbee_intent_custom(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Select custom installation type."""
|
"""Select custom installation type."""
|
||||||
|
self._zigbee_flow_strategy = ZigbeeFlowStrategy.ADVANCED
|
||||||
return await self.async_step_zigbee_integration()
|
return await self.async_step_zigbee_integration()
|
||||||
|
|
||||||
async def async_step_zigbee_integration(
|
async def async_step_zigbee_integration(
|
||||||
@@ -434,12 +406,12 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
if self._picked_firmware_type == PickedFirmwareType.ZIGBEE:
|
if self._picked_firmware_type == PickedFirmwareType.ZIGBEE:
|
||||||
return await self.async_step_install_zigbee_firmware()
|
return await self.async_step_install_zigbee_firmware()
|
||||||
|
|
||||||
return await self.async_step_prepare_thread_installation()
|
return await self.async_step_install_thread_firmware()
|
||||||
|
|
||||||
async def async_step_prepare_thread_installation(
|
async def async_step_finish_thread_installation(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Prepare for Thread installation by stopping the OTBR addon if needed."""
|
"""Finish Thread installation by starting the OTBR addon."""
|
||||||
if not is_hassio(self.hass):
|
if not is_hassio(self.hass):
|
||||||
return self.async_abort(
|
return self.async_abort(
|
||||||
reason="not_hassio_thread",
|
reason="not_hassio_thread",
|
||||||
@@ -449,22 +421,12 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
otbr_manager = get_otbr_addon_manager(self.hass)
|
otbr_manager = get_otbr_addon_manager(self.hass)
|
||||||
addon_info = await self._async_get_addon_info(otbr_manager)
|
addon_info = await self._async_get_addon_info(otbr_manager)
|
||||||
|
|
||||||
if addon_info.state == AddonState.RUNNING:
|
|
||||||
# Stop the addon before continuing to flash firmware
|
|
||||||
await otbr_manager.async_stop_addon()
|
|
||||||
|
|
||||||
return await self.async_step_install_thread_firmware()
|
|
||||||
|
|
||||||
async def async_step_finish_thread_installation(
|
|
||||||
self, user_input: dict[str, Any] | None = None
|
|
||||||
) -> ConfigFlowResult:
|
|
||||||
"""Finish Thread installation by starting the OTBR addon."""
|
|
||||||
otbr_manager = get_otbr_addon_manager(self.hass)
|
|
||||||
addon_info = await self._async_get_addon_info(otbr_manager)
|
|
||||||
|
|
||||||
if addon_info.state == AddonState.NOT_INSTALLED:
|
if addon_info.state == AddonState.NOT_INSTALLED:
|
||||||
return await self.async_step_install_otbr_addon()
|
return await self.async_step_install_otbr_addon()
|
||||||
|
|
||||||
|
if addon_info.state == AddonState.RUNNING:
|
||||||
|
await otbr_manager.async_stop_addon()
|
||||||
|
|
||||||
return await self.async_step_start_otbr_addon()
|
return await self.async_step_start_otbr_addon()
|
||||||
|
|
||||||
async def async_step_pick_firmware_zigbee(
|
async def async_step_pick_firmware_zigbee(
|
||||||
@@ -486,18 +448,6 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
"""Install Zigbee firmware."""
|
"""Install Zigbee firmware."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
async def async_step_addon_operation_failed(
|
|
||||||
self, user_input: dict[str, Any] | None = None
|
|
||||||
) -> ConfigFlowResult:
|
|
||||||
"""Abort when add-on installation or start failed."""
|
|
||||||
return self.async_abort(
|
|
||||||
reason=self._failed_addon_reason,
|
|
||||||
description_placeholders={
|
|
||||||
**self._get_translation_placeholders(),
|
|
||||||
"addon_name": self._failed_addon_name,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
async def async_step_pre_confirm_zigbee(
|
async def async_step_pre_confirm_zigbee(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
@@ -513,12 +463,6 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
assert self._device is not None
|
assert self._device is not None
|
||||||
assert self._hardware_name is not None
|
assert self._hardware_name is not None
|
||||||
|
|
||||||
if not await self._probe_firmware_info(probe_methods=(ApplicationType.EZSP,)):
|
|
||||||
return self.async_abort(
|
|
||||||
reason="unsupported_firmware",
|
|
||||||
description_placeholders=self._get_translation_placeholders(),
|
|
||||||
)
|
|
||||||
|
|
||||||
if self._zigbee_integration == ZigbeeIntegration.OTHER:
|
if self._zigbee_integration == ZigbeeIntegration.OTHER:
|
||||||
return self._async_flow_finished()
|
return self._async_flow_finished()
|
||||||
|
|
||||||
@@ -533,6 +477,7 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
"flow_control": "hardware",
|
"flow_control": "hardware",
|
||||||
},
|
},
|
||||||
"radio_type": "ezsp",
|
"radio_type": "ezsp",
|
||||||
|
"flow_strategy": self._zigbee_flow_strategy,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return self._continue_zha_flow(result)
|
return self._continue_zha_flow(result)
|
||||||
@@ -561,6 +506,12 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
"""Install Thread firmware."""
|
"""Install Thread firmware."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@progress_step(
|
||||||
|
description_placeholders=lambda self: {
|
||||||
|
**self._get_translation_placeholders(),
|
||||||
|
"addon_name": get_otbr_addon_manager(self.hass).addon_name,
|
||||||
|
}
|
||||||
|
)
|
||||||
async def async_step_install_otbr_addon(
|
async def async_step_install_otbr_addon(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
@@ -570,70 +521,43 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
|
|
||||||
_LOGGER.debug("OTBR addon info: %s", addon_info)
|
_LOGGER.debug("OTBR addon info: %s", addon_info)
|
||||||
|
|
||||||
if not self.addon_install_task:
|
try:
|
||||||
self.addon_install_task = self.hass.async_create_task(
|
await addon_manager.async_install_addon_waiting()
|
||||||
addon_manager.async_install_addon_waiting(),
|
except AddonError as err:
|
||||||
"OTBR addon install",
|
_LOGGER.error(err)
|
||||||
)
|
raise AbortFlow(
|
||||||
|
"addon_install_failed",
|
||||||
if not self.addon_install_task.done():
|
|
||||||
return self.async_show_progress(
|
|
||||||
step_id="install_otbr_addon",
|
|
||||||
progress_action="install_addon",
|
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
**self._get_translation_placeholders(),
|
**self._get_translation_placeholders(),
|
||||||
"addon_name": addon_manager.addon_name,
|
"addon_name": addon_manager.addon_name,
|
||||||
},
|
},
|
||||||
progress_task=self.addon_install_task,
|
) from err
|
||||||
|
|
||||||
|
return await self.async_step_finish_thread_installation()
|
||||||
|
|
||||||
|
@progress_step(
|
||||||
|
description_placeholders=lambda self: {
|
||||||
|
**self._get_translation_placeholders(),
|
||||||
|
"addon_name": get_otbr_addon_manager(self.hass).addon_name,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
|
||||||
await self.addon_install_task
|
|
||||||
except AddonError as err:
|
|
||||||
_LOGGER.error(err)
|
|
||||||
self._failed_addon_name = addon_manager.addon_name
|
|
||||||
self._failed_addon_reason = "addon_install_failed"
|
|
||||||
return self.async_show_progress_done(next_step_id="addon_operation_failed")
|
|
||||||
finally:
|
|
||||||
self.addon_install_task = None
|
|
||||||
|
|
||||||
return self.async_show_progress_done(next_step_id="finish_thread_installation")
|
|
||||||
|
|
||||||
async def async_step_start_otbr_addon(
|
async def async_step_start_otbr_addon(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Configure OTBR to point to the SkyConnect and run the addon."""
|
"""Configure OTBR to point to the SkyConnect and run the addon."""
|
||||||
otbr_manager = get_otbr_addon_manager(self.hass)
|
try:
|
||||||
|
await self._configure_and_start_otbr_addon()
|
||||||
if not self.addon_start_task:
|
except AddonError as err:
|
||||||
self.addon_start_task = self.hass.async_create_task(
|
_LOGGER.error(err)
|
||||||
self._configure_and_start_otbr_addon()
|
raise AbortFlow(
|
||||||
)
|
"addon_start_failed",
|
||||||
|
|
||||||
if not self.addon_start_task.done():
|
|
||||||
return self.async_show_progress(
|
|
||||||
step_id="start_otbr_addon",
|
|
||||||
progress_action="start_otbr_addon",
|
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
**self._get_translation_placeholders(),
|
**self._get_translation_placeholders(),
|
||||||
"addon_name": otbr_manager.addon_name,
|
"addon_name": get_otbr_addon_manager(self.hass).addon_name,
|
||||||
},
|
},
|
||||||
progress_task=self.addon_start_task,
|
) from err
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
return await self.async_step_pre_confirm_otbr()
|
||||||
await self.addon_start_task
|
|
||||||
except (AddonError, AbortFlow) as err:
|
|
||||||
_LOGGER.error(err)
|
|
||||||
self._failed_addon_name = otbr_manager.addon_name
|
|
||||||
self._failed_addon_reason = (
|
|
||||||
err.reason if isinstance(err, AbortFlow) else "addon_start_failed"
|
|
||||||
)
|
|
||||||
return self.async_show_progress_done(next_step_id="addon_operation_failed")
|
|
||||||
finally:
|
|
||||||
self.addon_start_task = None
|
|
||||||
|
|
||||||
return self.async_show_progress_done(next_step_id="pre_confirm_otbr")
|
|
||||||
|
|
||||||
async def async_step_pre_confirm_otbr(
|
async def async_step_pre_confirm_otbr(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
@@ -641,20 +565,6 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC):
|
|||||||
"""Pre-confirm OTBR setup."""
|
"""Pre-confirm OTBR setup."""
|
||||||
|
|
||||||
# This step is necessary to prevent `user_input` from being passed through
|
# This step is necessary to prevent `user_input` from being passed through
|
||||||
return await self.async_step_confirm_otbr()
|
|
||||||
|
|
||||||
async def async_step_confirm_otbr(
|
|
||||||
self, user_input: dict[str, Any] | None = None
|
|
||||||
) -> ConfigFlowResult:
|
|
||||||
"""Confirm OTBR setup."""
|
|
||||||
assert self._device is not None
|
|
||||||
|
|
||||||
if user_input is None:
|
|
||||||
return self.async_show_form(
|
|
||||||
step_id="confirm_otbr",
|
|
||||||
description_placeholders=self._get_translation_placeholders(),
|
|
||||||
)
|
|
||||||
|
|
||||||
# OTBR discovery is done automatically via hassio
|
# OTBR discovery is done automatically via hassio
|
||||||
return self._async_flow_finished()
|
return self._async_flow_finished()
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/homeassistant_hardware",
|
"documentation": "https://www.home-assistant.io/integrations/homeassistant_hardware",
|
||||||
"integration_type": "system",
|
"integration_type": "system",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"universal-silabs-flasher==0.0.32",
|
"universal-silabs-flasher==0.0.34",
|
||||||
"ha-silabs-firmware-client==0.2.0"
|
"ha-silabs-firmware-client==0.2.0"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,12 +23,16 @@
|
|||||||
"description": "Your {model} is now a Zigbee coordinator and will be shown as discovered by the Zigbee Home Automation integration."
|
"description": "Your {model} is now a Zigbee coordinator and will be shown as discovered by the Zigbee Home Automation integration."
|
||||||
},
|
},
|
||||||
"install_otbr_addon": {
|
"install_otbr_addon": {
|
||||||
"title": "Installing OpenThread Border Router add-on",
|
"title": "Configuring Thread"
|
||||||
"description": "The OpenThread Border Router (OTBR) add-on is being installed."
|
},
|
||||||
|
"install_thread_firmware": {
|
||||||
|
"title": "Updating adapter"
|
||||||
|
},
|
||||||
|
"install_zigbee_firmware": {
|
||||||
|
"title": "Updating adapter"
|
||||||
},
|
},
|
||||||
"start_otbr_addon": {
|
"start_otbr_addon": {
|
||||||
"title": "Starting OpenThread Border Router add-on",
|
"title": "Configuring Thread"
|
||||||
"description": "The OpenThread Border Router (OTBR) add-on is now starting."
|
|
||||||
},
|
},
|
||||||
"otbr_failed": {
|
"otbr_failed": {
|
||||||
"title": "Failed to set up OpenThread Border Router",
|
"title": "Failed to set up OpenThread Border Router",
|
||||||
@@ -72,7 +76,9 @@
|
|||||||
"fw_install_failed": "{firmware_name} firmware failed to install, check Home Assistant logs for more information."
|
"fw_install_failed": "{firmware_name} firmware failed to install, check Home Assistant logs for more information."
|
||||||
},
|
},
|
||||||
"progress": {
|
"progress": {
|
||||||
"install_firmware": "Please wait while {firmware_name} firmware is installed to your {model}, this will take a few minutes. Do not make any changes to your hardware or software until this finishes."
|
"install_firmware": "Installing {firmware_name} firmware.\n\nDo not make any changes to your hardware or software until this finishes.",
|
||||||
|
"install_otbr_addon": "Installing add-on",
|
||||||
|
"start_otbr_addon": "Starting add-on"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,7 +22,12 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|||||||
|
|
||||||
from .coordinator import FirmwareUpdateCoordinator
|
from .coordinator import FirmwareUpdateCoordinator
|
||||||
from .helpers import async_register_firmware_info_callback
|
from .helpers import async_register_firmware_info_callback
|
||||||
from .util import ApplicationType, FirmwareInfo, async_flash_silabs_firmware
|
from .util import (
|
||||||
|
ApplicationType,
|
||||||
|
FirmwareInfo,
|
||||||
|
ResetTarget,
|
||||||
|
async_flash_silabs_firmware,
|
||||||
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -81,7 +86,7 @@ class BaseFirmwareUpdateEntity(
|
|||||||
|
|
||||||
# Subclasses provide the mapping between firmware types and entity descriptions
|
# Subclasses provide the mapping between firmware types and entity descriptions
|
||||||
entity_description: FirmwareUpdateEntityDescription
|
entity_description: FirmwareUpdateEntityDescription
|
||||||
bootloader_reset_type: str | None = None
|
bootloader_reset_methods: list[ResetTarget] = []
|
||||||
|
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
UpdateEntityFeature.INSTALL | UpdateEntityFeature.PROGRESS
|
UpdateEntityFeature.INSTALL | UpdateEntityFeature.PROGRESS
|
||||||
@@ -268,7 +273,7 @@ class BaseFirmwareUpdateEntity(
|
|||||||
device=self._current_device,
|
device=self._current_device,
|
||||||
fw_data=fw_data,
|
fw_data=fw_data,
|
||||||
expected_installed_firmware_type=self.entity_description.expected_firmware_type,
|
expected_installed_firmware_type=self.entity_description.expected_firmware_type,
|
||||||
bootloader_reset_type=self.bootloader_reset_type,
|
bootloader_reset_methods=self.bootloader_reset_methods,
|
||||||
progress_callback=self._update_progress,
|
progress_callback=self._update_progress,
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
@@ -4,13 +4,16 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from collections.abc import AsyncIterator, Callable, Iterable
|
from collections.abc import AsyncIterator, Callable, Iterable, Sequence
|
||||||
from contextlib import AsyncExitStack, asynccontextmanager
|
from contextlib import AsyncExitStack, asynccontextmanager
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import StrEnum
|
from enum import StrEnum
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from universal_silabs_flasher.const import ApplicationType as FlasherApplicationType
|
from universal_silabs_flasher.const import (
|
||||||
|
ApplicationType as FlasherApplicationType,
|
||||||
|
ResetTarget as FlasherResetTarget,
|
||||||
|
)
|
||||||
from universal_silabs_flasher.firmware import parse_firmware_image
|
from universal_silabs_flasher.firmware import parse_firmware_image
|
||||||
from universal_silabs_flasher.flasher import Flasher
|
from universal_silabs_flasher.flasher import Flasher
|
||||||
|
|
||||||
@@ -42,9 +45,9 @@ class ApplicationType(StrEnum):
|
|||||||
"""Application type running on a device."""
|
"""Application type running on a device."""
|
||||||
|
|
||||||
GECKO_BOOTLOADER = "bootloader"
|
GECKO_BOOTLOADER = "bootloader"
|
||||||
CPC = "cpc"
|
|
||||||
EZSP = "ezsp"
|
EZSP = "ezsp"
|
||||||
SPINEL = "spinel"
|
SPINEL = "spinel"
|
||||||
|
CPC = "cpc"
|
||||||
ROUTER = "router"
|
ROUTER = "router"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -59,6 +62,18 @@ class ApplicationType(StrEnum):
|
|||||||
return FlasherApplicationType(self.value)
|
return FlasherApplicationType(self.value)
|
||||||
|
|
||||||
|
|
||||||
|
class ResetTarget(StrEnum):
|
||||||
|
"""Methods to reset a device into bootloader mode."""
|
||||||
|
|
||||||
|
RTS_DTR = "rts_dtr"
|
||||||
|
BAUDRATE = "baudrate"
|
||||||
|
YELLOW = "yellow"
|
||||||
|
|
||||||
|
def as_flasher_reset_target(self) -> FlasherResetTarget:
|
||||||
|
"""Convert the reset target enum into one compatible with USF."""
|
||||||
|
return FlasherResetTarget(self.value)
|
||||||
|
|
||||||
|
|
||||||
@singleton(OTBR_ADDON_MANAGER_DATA)
|
@singleton(OTBR_ADDON_MANAGER_DATA)
|
||||||
@callback
|
@callback
|
||||||
def get_otbr_addon_manager(hass: HomeAssistant) -> WaitingAddonManager:
|
def get_otbr_addon_manager(hass: HomeAssistant) -> WaitingAddonManager:
|
||||||
@@ -342,7 +357,7 @@ async def async_flash_silabs_firmware(
|
|||||||
device: str,
|
device: str,
|
||||||
fw_data: bytes,
|
fw_data: bytes,
|
||||||
expected_installed_firmware_type: ApplicationType,
|
expected_installed_firmware_type: ApplicationType,
|
||||||
bootloader_reset_type: str | None = None,
|
bootloader_reset_methods: Sequence[ResetTarget] = (),
|
||||||
progress_callback: Callable[[int, int], None] | None = None,
|
progress_callback: Callable[[int, int], None] | None = None,
|
||||||
) -> FirmwareInfo:
|
) -> FirmwareInfo:
|
||||||
"""Flash firmware to the SiLabs device."""
|
"""Flash firmware to the SiLabs device."""
|
||||||
@@ -359,7 +374,9 @@ async def async_flash_silabs_firmware(
|
|||||||
ApplicationType.SPINEL.as_flasher_application_type(),
|
ApplicationType.SPINEL.as_flasher_application_type(),
|
||||||
ApplicationType.CPC.as_flasher_application_type(),
|
ApplicationType.CPC.as_flasher_application_type(),
|
||||||
),
|
),
|
||||||
bootloader_reset=bootloader_reset_type,
|
bootloader_reset=tuple(
|
||||||
|
m.as_flasher_reset_target() for m in bootloader_reset_methods
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
async with AsyncExitStack() as stack:
|
async with AsyncExitStack() as stack:
|
||||||
|
|||||||
@@ -27,6 +27,12 @@
|
|||||||
"install_addon": {
|
"install_addon": {
|
||||||
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::install_addon::title%]"
|
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::install_addon::title%]"
|
||||||
},
|
},
|
||||||
|
"install_thread_firmware": {
|
||||||
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_thread_firmware::title%]"
|
||||||
|
},
|
||||||
|
"install_zigbee_firmware": {
|
||||||
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_zigbee_firmware::title%]"
|
||||||
|
},
|
||||||
"notify_channel_change": {
|
"notify_channel_change": {
|
||||||
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::notify_channel_change::title%]",
|
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::notify_channel_change::title%]",
|
||||||
"description": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::notify_channel_change::description%]"
|
"description": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::notify_channel_change::description%]"
|
||||||
@@ -69,12 +75,10 @@
|
|||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_zigbee::description%]"
|
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_zigbee::description%]"
|
||||||
},
|
},
|
||||||
"install_otbr_addon": {
|
"install_otbr_addon": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::title%]"
|
||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::description%]"
|
|
||||||
},
|
},
|
||||||
"start_otbr_addon": {
|
"start_otbr_addon": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::title%]"
|
||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::description%]"
|
|
||||||
},
|
},
|
||||||
"otbr_failed": {
|
"otbr_failed": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::otbr_failed::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::otbr_failed::title%]",
|
||||||
@@ -129,9 +133,10 @@
|
|||||||
},
|
},
|
||||||
"progress": {
|
"progress": {
|
||||||
"install_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::install_addon%]",
|
"install_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::install_addon%]",
|
||||||
|
"install_firmware": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_firmware%]",
|
||||||
|
"install_otbr_addon": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_otbr_addon%]",
|
||||||
"start_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
"start_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
||||||
"start_otbr_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
"start_otbr_addon": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::start_otbr_addon%]"
|
||||||
"install_firmware": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_firmware%]"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
@@ -158,12 +163,16 @@
|
|||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_zigbee::description%]"
|
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_zigbee::description%]"
|
||||||
},
|
},
|
||||||
"install_otbr_addon": {
|
"install_otbr_addon": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::title%]"
|
||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::description%]"
|
},
|
||||||
|
"install_thread_firmware": {
|
||||||
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_thread_firmware::title%]"
|
||||||
|
},
|
||||||
|
"install_zigbee_firmware": {
|
||||||
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_zigbee_firmware::title%]"
|
||||||
},
|
},
|
||||||
"start_otbr_addon": {
|
"start_otbr_addon": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::title%]"
|
||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::description%]"
|
|
||||||
},
|
},
|
||||||
"otbr_failed": {
|
"otbr_failed": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::otbr_failed::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::otbr_failed::title%]",
|
||||||
@@ -215,9 +224,10 @@
|
|||||||
},
|
},
|
||||||
"progress": {
|
"progress": {
|
||||||
"install_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::install_addon%]",
|
"install_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::install_addon%]",
|
||||||
|
"install_firmware": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_firmware%]",
|
||||||
|
"install_otbr_addon": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_otbr_addon%]",
|
||||||
"start_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
"start_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
||||||
"start_otbr_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
"start_otbr_addon": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::start_otbr_addon%]"
|
||||||
"install_firmware": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_firmware%]"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"exceptions": {
|
"exceptions": {
|
||||||
|
|||||||
@@ -168,7 +168,8 @@ async def async_setup_entry(
|
|||||||
class FirmwareUpdateEntity(BaseFirmwareUpdateEntity):
|
class FirmwareUpdateEntity(BaseFirmwareUpdateEntity):
|
||||||
"""SkyConnect firmware update entity."""
|
"""SkyConnect firmware update entity."""
|
||||||
|
|
||||||
bootloader_reset_type = None
|
# The ZBT-1 does not have a hardware bootloader trigger
|
||||||
|
bootloader_reset_methods = []
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ from homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon
|
|||||||
from homeassistant.components.homeassistant_hardware.util import (
|
from homeassistant.components.homeassistant_hardware.util import (
|
||||||
ApplicationType,
|
ApplicationType,
|
||||||
FirmwareInfo,
|
FirmwareInfo,
|
||||||
|
ResetTarget,
|
||||||
|
probe_silabs_firmware_info,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
SOURCE_HARDWARE,
|
SOURCE_HARDWARE,
|
||||||
@@ -82,6 +84,8 @@ else:
|
|||||||
class YellowFirmwareMixin(ConfigEntryBaseFlow, FirmwareInstallFlowProtocol):
|
class YellowFirmwareMixin(ConfigEntryBaseFlow, FirmwareInstallFlowProtocol):
|
||||||
"""Mixin for Home Assistant Yellow firmware methods."""
|
"""Mixin for Home Assistant Yellow firmware methods."""
|
||||||
|
|
||||||
|
BOOTLOADER_RESET_METHODS = [ResetTarget.YELLOW]
|
||||||
|
|
||||||
async def async_step_install_zigbee_firmware(
|
async def async_step_install_zigbee_firmware(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
@@ -141,8 +145,10 @@ class HomeAssistantYellowConfigFlow(
|
|||||||
self, data: dict[str, Any] | None = None
|
self, data: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the initial step."""
|
"""Handle the initial step."""
|
||||||
|
assert self._device is not None
|
||||||
|
|
||||||
# We do not actually use any portion of `BaseFirmwareConfigFlow` beyond this
|
# We do not actually use any portion of `BaseFirmwareConfigFlow` beyond this
|
||||||
await self._probe_firmware_info()
|
self._probed_firmware_info = await probe_silabs_firmware_info(self._device)
|
||||||
|
|
||||||
# Kick off ZHA hardware discovery automatically if Zigbee firmware is running
|
# Kick off ZHA hardware discovery automatically if Zigbee firmware is running
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -35,6 +35,12 @@
|
|||||||
"install_addon": {
|
"install_addon": {
|
||||||
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::install_addon::title%]"
|
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::install_addon::title%]"
|
||||||
},
|
},
|
||||||
|
"install_thread_firmware": {
|
||||||
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_thread_firmware::title%]"
|
||||||
|
},
|
||||||
|
"install_zigbee_firmware": {
|
||||||
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_zigbee_firmware::title%]"
|
||||||
|
},
|
||||||
"notify_channel_change": {
|
"notify_channel_change": {
|
||||||
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::notify_channel_change::title%]",
|
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::notify_channel_change::title%]",
|
||||||
"description": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::notify_channel_change::description%]"
|
"description": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::notify_channel_change::description%]"
|
||||||
@@ -92,12 +98,10 @@
|
|||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_zigbee::description%]"
|
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::confirm_zigbee::description%]"
|
||||||
},
|
},
|
||||||
"install_otbr_addon": {
|
"install_otbr_addon": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::title%]"
|
||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::install_otbr_addon::description%]"
|
|
||||||
},
|
},
|
||||||
"start_otbr_addon": {
|
"start_otbr_addon": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::title%]"
|
||||||
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::description%]"
|
|
||||||
},
|
},
|
||||||
"otbr_failed": {
|
"otbr_failed": {
|
||||||
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::otbr_failed::title%]",
|
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::otbr_failed::title%]",
|
||||||
@@ -154,9 +158,10 @@
|
|||||||
},
|
},
|
||||||
"progress": {
|
"progress": {
|
||||||
"install_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::install_addon%]",
|
"install_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::install_addon%]",
|
||||||
|
"install_firmware": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_firmware%]",
|
||||||
|
"install_otbr_addon": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_otbr_addon%]",
|
||||||
"start_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
"start_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
||||||
"start_otbr_addon": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::progress::start_addon%]",
|
"start_otbr_addon": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::start_otbr_addon%]"
|
||||||
"install_firmware": "[%key:component::homeassistant_hardware::firmware_picker::options::progress::install_firmware%]"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from homeassistant.components.homeassistant_hardware.update import (
|
|||||||
from homeassistant.components.homeassistant_hardware.util import (
|
from homeassistant.components.homeassistant_hardware.util import (
|
||||||
ApplicationType,
|
ApplicationType,
|
||||||
FirmwareInfo,
|
FirmwareInfo,
|
||||||
|
ResetTarget,
|
||||||
)
|
)
|
||||||
from homeassistant.components.update import UpdateDeviceClass
|
from homeassistant.components.update import UpdateDeviceClass
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@@ -173,7 +174,7 @@ async def async_setup_entry(
|
|||||||
class FirmwareUpdateEntity(BaseFirmwareUpdateEntity):
|
class FirmwareUpdateEntity(BaseFirmwareUpdateEntity):
|
||||||
"""Yellow firmware update entity."""
|
"""Yellow firmware update entity."""
|
||||||
|
|
||||||
bootloader_reset_type = "yellow" # Triggers a GPIO reset
|
bootloader_reset_methods = [ResetTarget.YELLOW] # Triggers a GPIO reset
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ async def async_get_controller(hass: HomeAssistant) -> Controller:
|
|||||||
|
|
||||||
controller = Controller(
|
controller = Controller(
|
||||||
async_zeroconf_instance=async_zeroconf_instance,
|
async_zeroconf_instance=async_zeroconf_instance,
|
||||||
bleak_scanner_instance=bleak_scanner_instance, # type: ignore[arg-type]
|
bleak_scanner_instance=bleak_scanner_instance,
|
||||||
char_cache=char_cache,
|
char_cache=char_cache,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,11 @@ class HueMotionSensor(HueBaseEntity, BinarySensorEntity):
|
|||||||
if not self.resource.enabled:
|
if not self.resource.enabled:
|
||||||
# Force None (unknown) if the sensor is set to disabled in Hue
|
# Force None (unknown) if the sensor is set to disabled in Hue
|
||||||
return None
|
return None
|
||||||
return self.resource.motion.value
|
if not (motion_feature := self.resource.motion):
|
||||||
|
return None
|
||||||
|
if motion_feature.motion_report is not None:
|
||||||
|
return motion_feature.motion_report.motion
|
||||||
|
return motion_feature.motion
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable-next=hass-enforce-class-module
|
# pylint: disable-next=hass-enforce-class-module
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
"""Analytics platform."""
|
|
||||||
|
|
||||||
from homeassistant.components.analytics import (
|
|
||||||
AnalyticsInput,
|
|
||||||
AnalyticsModifications,
|
|
||||||
EntityAnalyticsModifications,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
|
||||||
from homeassistant.helpers import entity_registry as er
|
|
||||||
|
|
||||||
|
|
||||||
async def async_modify_analytics(
|
|
||||||
hass: HomeAssistant, analytics_input: AnalyticsInput
|
|
||||||
) -> AnalyticsModifications:
|
|
||||||
"""Modify the analytics."""
|
|
||||||
ent_reg = er.async_get(hass)
|
|
||||||
|
|
||||||
entities: dict[str, EntityAnalyticsModifications] = {}
|
|
||||||
for entity_id in analytics_input.entity_ids:
|
|
||||||
entity_entry = ent_reg.entities[entity_id]
|
|
||||||
if entity_entry.capabilities is not None:
|
|
||||||
capabilities = dict(entity_entry.capabilities)
|
|
||||||
capabilities["options"] = len(capabilities["options"])
|
|
||||||
entities[entity_id] = EntityAnalyticsModifications(
|
|
||||||
capabilities=capabilities
|
|
||||||
)
|
|
||||||
|
|
||||||
return AnalyticsModifications(entities=entities)
|
|
||||||
@@ -35,7 +35,7 @@ from homeassistant.const import (
|
|||||||
Platform,
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv, issue_registry as ir
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .config_flow import ( # Loading the config flow file will register the flow
|
from .config_flow import ( # Loading the config flow file will register the flow
|
||||||
@@ -221,6 +221,19 @@ PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR, Platform.SWITCH]
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the Konnected platform."""
|
"""Set up the Konnected platform."""
|
||||||
|
ir.async_create_issue(
|
||||||
|
hass,
|
||||||
|
DOMAIN,
|
||||||
|
"deprecated_firmware",
|
||||||
|
breaks_in_ha_version="2026.4.0",
|
||||||
|
is_fixable=False,
|
||||||
|
issue_domain=DOMAIN,
|
||||||
|
severity=ir.IssueSeverity.WARNING,
|
||||||
|
translation_key="deprecated_firmware",
|
||||||
|
translation_placeholders={
|
||||||
|
"kb_page_url": "https://support.konnected.io/migrating-from-konnected-legacy-home-assistant-integration-to-esphome",
|
||||||
|
},
|
||||||
|
)
|
||||||
if (cfg := config.get(DOMAIN)) is None:
|
if (cfg := config.get(DOMAIN)) is None:
|
||||||
cfg = {}
|
cfg = {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"domain": "konnected",
|
"domain": "konnected",
|
||||||
"name": "Konnected.io",
|
"name": "Konnected.io (Legacy)",
|
||||||
"codeowners": ["@heythisisnate"],
|
"codeowners": ["@heythisisnate"],
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"dependencies": ["http"],
|
"dependencies": ["http"],
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user