mirror of
https://github.com/home-assistant/core.git
synced 2025-10-23 18:49:31 +00:00
Compare commits
292 Commits
media-sour
...
2025.10.3
Author | SHA1 | Date | |
---|---|---|---|
![]() |
bb98ed6633 | ||
![]() |
59dace572a | ||
![]() |
735cf36a5b | ||
![]() |
90b0f50b8f | ||
![]() |
e731c07b77 | ||
![]() |
2c75635e95 | ||
![]() |
1f031695c2 | ||
![]() |
fb279212a9 | ||
![]() |
45869523d0 | ||
![]() |
a753926f22 | ||
![]() |
dc874ff53a | ||
![]() |
3ef6865708 | ||
![]() |
7f1989f9f2 | ||
![]() |
97e338c760 | ||
![]() |
101679c17d | ||
![]() |
bc784c356e | ||
![]() |
556cc57d8b | ||
![]() |
eef6e96a93 | ||
![]() |
56d237af7f | ||
![]() |
e5d1902d2a | ||
![]() |
a9a203678e | ||
![]() |
7f6237cc63 | ||
![]() |
5468e691ca | ||
![]() |
67cbbc3522 | ||
![]() |
504da54c11 | ||
![]() |
cdda2ef5c8 | ||
![]() |
f405f9eb4b | ||
![]() |
634f71835a | ||
![]() |
49bfb01fac | ||
![]() |
ad8f7fdcab | ||
![]() |
f82ec81062 | ||
![]() |
03b0842a01 | ||
![]() |
13e5cb5cc8 | ||
![]() |
f18cdaf4d8 | ||
![]() |
5b3bca1426 | ||
![]() |
d812e9d43c | ||
![]() |
fa1071b221 | ||
![]() |
e48c2c6c0b | ||
![]() |
bddd4100c0 | ||
![]() |
70d8df2e95 | ||
![]() |
08b3dd0173 | ||
![]() |
6723a7c4e1 | ||
![]() |
40d7f2a89e | ||
![]() |
13b717e2da | ||
![]() |
5fcfd3ad84 | ||
![]() |
324a7b5443 | ||
![]() |
491ae8f72c | ||
![]() |
259247892f | ||
![]() |
caeda0ef64 | ||
![]() |
df35c535e4 | ||
![]() |
f93b9e0ed0 | ||
![]() |
48a3372cf2 | ||
![]() |
d84fd72428 | ||
![]() |
e8cb386962 | ||
![]() |
5ac726703c | ||
![]() |
688649a799 | ||
![]() |
c5359ade3e | ||
![]() |
4e60dedc1b | ||
![]() |
221d74f83a | ||
![]() |
fbbb3d6415 | ||
![]() |
8297019011 | ||
![]() |
61715dcff3 | ||
![]() |
32b822ee99 | ||
![]() |
e6c2e0ad80 | ||
![]() |
1314427dc5 | ||
![]() |
bf499a45f7 | ||
![]() |
b955e22628 | ||
![]() |
1b222ff5fd | ||
![]() |
f0510e703f | ||
![]() |
cbe3956e15 | ||
![]() |
4588e9da8d | ||
![]() |
5445890fdf | ||
![]() |
9b49f77f86 | ||
![]() |
566c8fb786 | ||
![]() |
b36150c213 | ||
![]() |
809070d2ad | ||
![]() |
f4339dc031 | ||
![]() |
f3b37d24b0 | ||
![]() |
4c8348caa7 | ||
![]() |
b9e7c102ea | ||
![]() |
69d9fa89b7 | ||
![]() |
6f3f5a5ec1 | ||
![]() |
5ecfeca90a | ||
![]() |
00e0570fd4 | ||
![]() |
5a5b94f3af | ||
![]() |
34f00d9b33 | ||
![]() |
4cabc5b368 | ||
![]() |
4045125422 | ||
![]() |
d7393af76f | ||
![]() |
ad41386b27 | ||
![]() |
62d17ea20c | ||
![]() |
c4954731d0 | ||
![]() |
647723d3f0 | ||
![]() |
51c500e22c | ||
![]() |
f6fc13c1f2 | ||
![]() |
0009a7a042 | ||
![]() |
a3d1aa28e7 | ||
![]() |
9f53eb9b76 | ||
![]() |
f53a205ff3 | ||
![]() |
d08517c3df | ||
![]() |
d7398a44a1 | ||
![]() |
9acfc0cb88 | ||
![]() |
1b3d21523a | ||
![]() |
1d407d1326 | ||
![]() |
013346cead | ||
![]() |
5abaabc9da | ||
![]() |
32481312c3 | ||
![]() |
bdc9eb37d3 | ||
![]() |
e0afcbc02b | ||
![]() |
cd56a6a98d | ||
![]() |
9d85893bbb | ||
![]() |
9e8a70225f | ||
![]() |
96ec795d5e | ||
![]() |
65b796070d | ||
![]() |
32994812e5 | ||
![]() |
66ff9d63a3 | ||
![]() |
b2a63d4996 | ||
![]() |
f9f37b7f2a | ||
![]() |
7bdd9dd38a | ||
![]() |
1e8aae0a89 | ||
![]() |
cf668e9dc2 | ||
![]() |
2e91c8700f | ||
![]() |
9d14627daa | ||
![]() |
73b8283748 | ||
![]() |
edeaaa2e63 | ||
![]() |
d26dd8fc39 | ||
![]() |
34640ea735 | ||
![]() |
46a2e21ef0 | ||
![]() |
508af53e72 | ||
![]() |
5f7440608c | ||
![]() |
0d1aa38a26 | ||
![]() |
929f8c148a | ||
![]() |
92db1f5a04 | ||
![]() |
e66b5ce0bf | ||
![]() |
1e17150e9f | ||
![]() |
792902de3d | ||
![]() |
04d78c3dd5 | ||
![]() |
5c8d5bfb84 | ||
![]() |
99bff31869 | ||
![]() |
d949119fb0 | ||
![]() |
e7b737ece5 | ||
![]() |
fb8ddac2e8 | ||
![]() |
9a29cc53ef | ||
![]() |
55d5e769b2 | ||
![]() |
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.*
|
||||||
|
12
CODEOWNERS
generated
12
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
|
||||||
@@ -756,8 +760,8 @@ build.json @home-assistant/supervisor
|
|||||||
/homeassistant/components/intent/ @home-assistant/core @synesthesiam @arturpragacz
|
/homeassistant/components/intent/ @home-assistant/core @synesthesiam @arturpragacz
|
||||||
/tests/components/intent/ @home-assistant/core @synesthesiam @arturpragacz
|
/tests/components/intent/ @home-assistant/core @synesthesiam @arturpragacz
|
||||||
/homeassistant/components/intesishome/ @jnimmo
|
/homeassistant/components/intesishome/ @jnimmo
|
||||||
/homeassistant/components/iometer/ @MaestroOnICe
|
/homeassistant/components/iometer/ @jukrebs
|
||||||
/tests/components/iometer/ @MaestroOnICe
|
/tests/components/iometer/ @jukrebs
|
||||||
/homeassistant/components/ios/ @robbiet480
|
/homeassistant/components/ios/ @robbiet480
|
||||||
/tests/components/ios/ @robbiet480
|
/tests/components/ios/ @robbiet480
|
||||||
/homeassistant/components/iotawatt/ @gtdiehl @jyavenard
|
/homeassistant/components/iotawatt/ @gtdiehl @jyavenard
|
||||||
@@ -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.10.0
|
||||||
armhf: ghcr.io/home-assistant/armhf-homeassistant-base:2025.09.1
|
armhf: ghcr.io/home-assistant/armhf-homeassistant-base:2025.10.0
|
||||||
armv7: ghcr.io/home-assistant/armv7-homeassistant-base:2025.09.1
|
armv7: ghcr.io/home-assistant/armv7-homeassistant-base:2025.10.0
|
||||||
amd64: ghcr.io/home-assistant/amd64-homeassistant-base:2025.09.1
|
amd64: ghcr.io/home-assistant/amd64-homeassistant-base:2025.10.0
|
||||||
i386: ghcr.io/home-assistant/i386-homeassistant-base:2025.09.1
|
i386: ghcr.io/home-assistant/i386-homeassistant-base:2025.10.0
|
||||||
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
|
||||||
|
@@ -71,4 +71,4 @@ POLLEN_CATEGORY_MAP = {
|
|||||||
}
|
}
|
||||||
UPDATE_INTERVAL_OBSERVATION = timedelta(minutes=10)
|
UPDATE_INTERVAL_OBSERVATION = timedelta(minutes=10)
|
||||||
UPDATE_INTERVAL_DAILY_FORECAST = timedelta(hours=6)
|
UPDATE_INTERVAL_DAILY_FORECAST = timedelta(hours=6)
|
||||||
UPDATE_INTERVAL_HOURLY_FORECAST = timedelta(hours=30)
|
UPDATE_INTERVAL_HOURLY_FORECAST = timedelta(minutes=30)
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"entity": {
|
"entity": {
|
||||||
"sensor": {
|
"sensor": {
|
||||||
|
"air_quality": {
|
||||||
|
"default": "mdi:air-filter"
|
||||||
|
},
|
||||||
"cloud_ceiling": {
|
"cloud_ceiling": {
|
||||||
"default": "mdi:weather-fog"
|
"default": "mdi:weather-fog"
|
||||||
},
|
},
|
||||||
@@ -34,9 +37,6 @@
|
|||||||
"thunderstorm_probability_night": {
|
"thunderstorm_probability_night": {
|
||||||
"default": "mdi:weather-lightning"
|
"default": "mdi:weather-lightning"
|
||||||
},
|
},
|
||||||
"translation_key": {
|
|
||||||
"default": "mdi:air-filter"
|
|
||||||
},
|
|
||||||
"tree_pollen": {
|
"tree_pollen": {
|
||||||
"default": "mdi:tree-outline"
|
"default": "mdi:tree-outline"
|
||||||
},
|
},
|
||||||
|
@@ -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"]
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
"""Airgradient Update platform."""
|
"""Airgradient Update platform."""
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from airgradient import AirGradientConnectionError
|
||||||
from propcache.api import cached_property
|
from propcache.api import cached_property
|
||||||
|
|
||||||
from homeassistant.components.update import UpdateDeviceClass, UpdateEntity
|
from homeassistant.components.update import UpdateDeviceClass, UpdateEntity
|
||||||
@@ -13,6 +15,7 @@ from .entity import AirGradientEntity
|
|||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
SCAN_INTERVAL = timedelta(hours=1)
|
SCAN_INTERVAL = timedelta(hours=1)
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@@ -31,6 +34,7 @@ class AirGradientUpdate(AirGradientEntity, UpdateEntity):
|
|||||||
"""Representation of Airgradient Update."""
|
"""Representation of Airgradient Update."""
|
||||||
|
|
||||||
_attr_device_class = UpdateDeviceClass.FIRMWARE
|
_attr_device_class = UpdateDeviceClass.FIRMWARE
|
||||||
|
_server_unreachable_logged = False
|
||||||
|
|
||||||
def __init__(self, coordinator: AirGradientCoordinator) -> None:
|
def __init__(self, coordinator: AirGradientCoordinator) -> None:
|
||||||
"""Initialize the entity."""
|
"""Initialize the entity."""
|
||||||
@@ -47,10 +51,27 @@ class AirGradientUpdate(AirGradientEntity, UpdateEntity):
|
|||||||
"""Return the installed version of the entity."""
|
"""Return the installed version of the entity."""
|
||||||
return self.coordinator.data.measures.firmware_version
|
return self.coordinator.data.measures.firmware_version
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""Return if entity is available."""
|
||||||
|
return super().available and self._attr_available
|
||||||
|
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Update the entity."""
|
"""Update the entity."""
|
||||||
self._attr_latest_version = (
|
try:
|
||||||
await self.coordinator.client.get_latest_firmware_version(
|
self._attr_latest_version = (
|
||||||
self.coordinator.serial_number
|
await self.coordinator.client.get_latest_firmware_version(
|
||||||
|
self.coordinator.serial_number
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except AirGradientConnectionError:
|
||||||
|
self._attr_latest_version = None
|
||||||
|
self._attr_available = False
|
||||||
|
if not self._server_unreachable_logged:
|
||||||
|
_LOGGER.error(
|
||||||
|
"Unable to connect to AirGradient server to check for updates"
|
||||||
|
)
|
||||||
|
self._server_unreachable_logged = True
|
||||||
|
else:
|
||||||
|
self._server_unreachable_logged = False
|
||||||
|
self._attr_available = True
|
||||||
|
@@ -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(
|
||||||
|
@@ -6,5 +6,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/airos",
|
"documentation": "https://www.home-assistant.io/integrations/airos",
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"quality_scale": "bronze",
|
"quality_scale": "bronze",
|
||||||
"requirements": ["airos==0.5.1"]
|
"requirements": ["airos==0.5.5"]
|
||||||
}
|
}
|
||||||
|
@@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -7,5 +7,5 @@
|
|||||||
"integration_type": "hub",
|
"integration_type": "hub",
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"loggers": ["aioairq"],
|
"loggers": ["aioairq"],
|
||||||
"requirements": ["aioairq==0.4.6"]
|
"requirements": ["aioairq==0.4.7"]
|
||||||
}
|
}
|
||||||
|
@@ -2,17 +2,14 @@
|
|||||||
|
|
||||||
from airtouch4pyapi import AirTouch
|
from airtouch4pyapi import AirTouch
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import CONF_HOST, Platform
|
from homeassistant.const import CONF_HOST, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
|
|
||||||
from .coordinator import AirtouchDataUpdateCoordinator
|
from .coordinator import AirTouch4ConfigEntry, AirtouchDataUpdateCoordinator
|
||||||
|
|
||||||
PLATFORMS = [Platform.CLIMATE]
|
PLATFORMS = [Platform.CLIMATE]
|
||||||
|
|
||||||
type AirTouch4ConfigEntry = ConfigEntry[AirtouchDataUpdateCoordinator]
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: AirTouch4ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: AirTouch4ConfigEntry) -> bool:
|
||||||
"""Set up AirTouch4 from a config entry."""
|
"""Set up AirTouch4 from a config entry."""
|
||||||
@@ -22,7 +19,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: AirTouch4ConfigEntry) ->
|
|||||||
info = airtouch.GetAcs()
|
info = airtouch.GetAcs()
|
||||||
if not info:
|
if not info:
|
||||||
raise ConfigEntryNotReady
|
raise ConfigEntryNotReady
|
||||||
coordinator = AirtouchDataUpdateCoordinator(hass, airtouch)
|
coordinator = AirtouchDataUpdateCoordinator(hass, entry, airtouch)
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
entry.runtime_data = coordinator
|
entry.runtime_data = coordinator
|
||||||
|
|
||||||
|
@@ -2,26 +2,34 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from airtouch4pyapi import AirTouch
|
||||||
from airtouch4pyapi.airtouch import AirTouchStatus
|
from airtouch4pyapi.airtouch import AirTouchStatus
|
||||||
|
|
||||||
from homeassistant.components.climate import SCAN_INTERVAL
|
from homeassistant.components.climate import SCAN_INTERVAL
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
type AirTouch4ConfigEntry = ConfigEntry[AirtouchDataUpdateCoordinator]
|
||||||
|
|
||||||
|
|
||||||
class AirtouchDataUpdateCoordinator(DataUpdateCoordinator):
|
class AirtouchDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
"""Class to manage fetching Airtouch data."""
|
"""Class to manage fetching Airtouch data."""
|
||||||
|
|
||||||
def __init__(self, hass, airtouch):
|
def __init__(
|
||||||
|
self, hass: HomeAssistant, entry: AirTouch4ConfigEntry, airtouch: AirTouch
|
||||||
|
) -> None:
|
||||||
"""Initialize global Airtouch data updater."""
|
"""Initialize global Airtouch data updater."""
|
||||||
self.airtouch = airtouch
|
self.airtouch = airtouch
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=entry,
|
||||||
name=DOMAIN,
|
name=DOMAIN,
|
||||||
update_interval=SCAN_INTERVAL,
|
update_interval=SCAN_INTERVAL,
|
||||||
)
|
)
|
||||||
|
@@ -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,
|
||||||
@@ -17,9 +18,12 @@ from homeassistant.components.binary_sensor import (
|
|||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
import homeassistant.helpers.entity_registry as er
|
||||||
|
|
||||||
|
from .const import _LOGGER, DOMAIN
|
||||||
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 +35,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 = (
|
||||||
@@ -40,47 +45,52 @@ BINARY_SENSORS: Final = (
|
|||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
is_on_fn=lambda device, _: device.online,
|
is_on_fn=lambda device, _: device.online,
|
||||||
),
|
),
|
||||||
|
AmazonBinarySensorEntityDescription(
|
||||||
|
key="detectionState",
|
||||||
|
device_class=BinarySensorDeviceClass.MOTION,
|
||||||
|
is_on_fn=lambda device, key: bool(
|
||||||
|
device.sensors[key].value != SENSOR_STATE_OFF
|
||||||
|
),
|
||||||
|
is_supported=lambda device, key: device.sensors.get(key) is not None,
|
||||||
|
is_available_fn=lambda device, key: (
|
||||||
|
device.online
|
||||||
|
and (sensor := device.sensors.get(key)) is not None
|
||||||
|
and sensor.error is False
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
DEPRECATED_BINARY_SENSORS: Final = (
|
||||||
AmazonBinarySensorEntityDescription(
|
AmazonBinarySensorEntityDescription(
|
||||||
key="bluetooth",
|
key="bluetooth",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
translation_key="bluetooth",
|
translation_key="bluetooth",
|
||||||
is_on_fn=lambda device, _: device.bluetooth_state,
|
is_on_fn=lambda device, key: False,
|
||||||
),
|
),
|
||||||
AmazonBinarySensorEntityDescription(
|
AmazonBinarySensorEntityDescription(
|
||||||
key="babyCryDetectionState",
|
key="babyCryDetectionState",
|
||||||
translation_key="baby_cry_detection",
|
translation_key="baby_cry_detection",
|
||||||
is_on_fn=lambda device, key: (device.sensors[key].value != SENSOR_STATE_OFF),
|
is_on_fn=lambda device, key: False,
|
||||||
is_supported=lambda device, key: device.sensors.get(key) is not None,
|
|
||||||
),
|
),
|
||||||
AmazonBinarySensorEntityDescription(
|
AmazonBinarySensorEntityDescription(
|
||||||
key="beepingApplianceDetectionState",
|
key="beepingApplianceDetectionState",
|
||||||
translation_key="beeping_appliance_detection",
|
translation_key="beeping_appliance_detection",
|
||||||
is_on_fn=lambda device, key: (device.sensors[key].value != SENSOR_STATE_OFF),
|
is_on_fn=lambda device, key: False,
|
||||||
is_supported=lambda device, key: device.sensors.get(key) is not None,
|
|
||||||
),
|
),
|
||||||
AmazonBinarySensorEntityDescription(
|
AmazonBinarySensorEntityDescription(
|
||||||
key="coughDetectionState",
|
key="coughDetectionState",
|
||||||
translation_key="cough_detection",
|
translation_key="cough_detection",
|
||||||
is_on_fn=lambda device, key: (device.sensors[key].value != SENSOR_STATE_OFF),
|
is_on_fn=lambda device, key: False,
|
||||||
is_supported=lambda device, key: device.sensors.get(key) is not None,
|
|
||||||
),
|
),
|
||||||
AmazonBinarySensorEntityDescription(
|
AmazonBinarySensorEntityDescription(
|
||||||
key="dogBarkDetectionState",
|
key="dogBarkDetectionState",
|
||||||
translation_key="dog_bark_detection",
|
translation_key="dog_bark_detection",
|
||||||
is_on_fn=lambda device, key: (device.sensors[key].value != SENSOR_STATE_OFF),
|
is_on_fn=lambda device, key: False,
|
||||||
is_supported=lambda device, key: device.sensors.get(key) is not None,
|
|
||||||
),
|
|
||||||
AmazonBinarySensorEntityDescription(
|
|
||||||
key="humanPresenceDetectionState",
|
|
||||||
device_class=BinarySensorDeviceClass.MOTION,
|
|
||||||
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(
|
AmazonBinarySensorEntityDescription(
|
||||||
key="waterSoundsDetectionState",
|
key="waterSoundsDetectionState",
|
||||||
translation_key="water_sounds_detection",
|
translation_key="water_sounds_detection",
|
||||||
is_on_fn=lambda device, key: (device.sensors[key].value != SENSOR_STATE_OFF),
|
is_on_fn=lambda device, key: False,
|
||||||
is_supported=lambda device, key: device.sensors.get(key) is not None,
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -94,13 +104,46 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = entry.runtime_data
|
coordinator = entry.runtime_data
|
||||||
|
|
||||||
async_add_entities(
|
entity_registry = er.async_get(hass)
|
||||||
AmazonBinarySensorEntity(coordinator, serial_num, sensor_desc)
|
|
||||||
for sensor_desc in BINARY_SENSORS
|
# Replace unique id for "detectionState" binary sensor
|
||||||
for serial_num in coordinator.data
|
await async_update_unique_id(
|
||||||
if sensor_desc.is_supported(coordinator.data[serial_num], sensor_desc.key)
|
hass,
|
||||||
|
coordinator,
|
||||||
|
BINARY_SENSOR_DOMAIN,
|
||||||
|
"humanPresenceDetectionState",
|
||||||
|
"detectionState",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Clean up deprecated sensors
|
||||||
|
for sensor_desc in DEPRECATED_BINARY_SENSORS:
|
||||||
|
for serial_num in coordinator.data:
|
||||||
|
unique_id = f"{serial_num}-{sensor_desc.key}"
|
||||||
|
if entity_id := entity_registry.async_get_entity_id(
|
||||||
|
BINARY_SENSOR_DOMAIN, DOMAIN, unique_id
|
||||||
|
):
|
||||||
|
_LOGGER.debug("Removing deprecated entity %s", entity_id)
|
||||||
|
entity_registry.async_remove(entity_id)
|
||||||
|
|
||||||
|
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(
|
||||||
|
AmazonBinarySensorEntity(coordinator, serial_num, sensor_desc)
|
||||||
|
for sensor_desc in BINARY_SENSORS
|
||||||
|
for serial_num in new_devices
|
||||||
|
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):
|
||||||
"""Binary sensor device."""
|
"""Binary sensor device."""
|
||||||
@@ -113,3 +156,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.4.4"]
|
||||||
}
|
}
|
||||||
|
@@ -57,13 +57,23 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = entry.runtime_data
|
coordinator = entry.runtime_data
|
||||||
|
|
||||||
async_add_entities(
|
known_devices: set[str] = set()
|
||||||
AmazonNotifyEntity(coordinator, serial_num, sensor_desc)
|
|
||||||
for sensor_desc in NOTIFY
|
def _check_device() -> None:
|
||||||
for serial_num in coordinator.data
|
current_devices = set(coordinator.data)
|
||||||
if sensor_desc.subkey in coordinator.data[serial_num].capabilities
|
new_devices = current_devices - known_devices
|
||||||
and sensor_desc.is_supported(coordinator.data[serial_num])
|
if new_devices:
|
||||||
)
|
known_devices.update(new_devices)
|
||||||
|
async_add_entities(
|
||||||
|
AmazonNotifyEntity(coordinator, serial_num, sensor_desc)
|
||||||
|
for sensor_desc in NOTIFY
|
||||||
|
for serial_num in new_devices
|
||||||
|
if sensor_desc.subkey in coordinator.data[serial_num].capabilities
|
||||||
|
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):
|
||||||
|
@@ -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,15 +31,20 @@ 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 (sensor := device.sensors.get(key)) is not None
|
||||||
|
and sensor.error is False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
SENSORS: Final = (
|
SENSORS: Final = (
|
||||||
AmazonSensorEntityDescription(
|
AmazonSensorEntityDescription(
|
||||||
key="temperature",
|
key="temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement_fn=lambda device, _key: (
|
native_unit_of_measurement_fn=lambda device, key: (
|
||||||
UnitOfTemperature.CELSIUS
|
UnitOfTemperature.CELSIUS
|
||||||
if device.sensors[_key].scale == "CELSIUS"
|
if key in device.sensors and device.sensors[key].scale == "CELSIUS"
|
||||||
else UnitOfTemperature.FAHRENHEIT
|
else UnitOfTemperature.FAHRENHEIT
|
||||||
),
|
),
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
@@ -62,12 +67,22 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = entry.runtime_data
|
coordinator = entry.runtime_data
|
||||||
|
|
||||||
async_add_entities(
|
known_devices: set[str] = set()
|
||||||
AmazonSensorEntity(coordinator, serial_num, sensor_desc)
|
|
||||||
for sensor_desc in SENSORS
|
def _check_device() -> None:
|
||||||
for serial_num in coordinator.data
|
current_devices = set(coordinator.data)
|
||||||
if coordinator.data[serial_num].sensors.get(sensor_desc.key) is not None
|
new_devices = current_devices - known_devices
|
||||||
)
|
if new_devices:
|
||||||
|
known_devices.update(new_devices)
|
||||||
|
async_add_entities(
|
||||||
|
AmazonSensorEntity(coordinator, serial_num, sensor_desc)
|
||||||
|
for sensor_desc in SENSORS
|
||||||
|
for serial_num in new_devices
|
||||||
|
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):
|
||||||
@@ -89,3 +104,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,21 @@ 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_remove_dnd_from_virtual_group,
|
||||||
|
async_update_unique_id,
|
||||||
|
)
|
||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
|
|
||||||
@@ -24,16 +32,19 @@ 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 (sensor := device.sensors.get(key)) is not None
|
||||||
|
and sensor.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 +59,31 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = entry.runtime_data
|
coordinator = entry.runtime_data
|
||||||
|
|
||||||
async_add_entities(
|
# Replace unique id for "DND" switch and remove from Speaker Group
|
||||||
AmazonSwitchEntity(coordinator, serial_num, switch_desc)
|
await async_update_unique_id(
|
||||||
for switch_desc in SWITCHES
|
hass, coordinator, SWITCH_DOMAIN, "do_not_disturb", "dnd"
|
||||||
for serial_num in coordinator.data
|
|
||||||
if switch_desc.subkey in coordinator.data[serial_num].capabilities
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Remove DND switch from virtual groups
|
||||||
|
await async_remove_dnd_from_virtual_group(hass, coordinator)
|
||||||
|
|
||||||
|
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(
|
||||||
|
AmazonSwitchEntity(coordinator, serial_num, switch_desc)
|
||||||
|
for switch_desc in SWITCHES
|
||||||
|
for serial_num in new_devices
|
||||||
|
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 +113,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
|
||||||
|
)
|
||||||
|
@@ -4,11 +4,16 @@ from collections.abc import Awaitable, Callable, Coroutine
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
from typing import Any, Concatenate
|
from typing import Any, Concatenate
|
||||||
|
|
||||||
|
from aioamazondevices.const import SPEAKER_GROUP_FAMILY
|
||||||
from aioamazondevices.exceptions import CannotConnect, CannotRetrieveData
|
from aioamazondevices.exceptions import CannotConnect, CannotRetrieveData
|
||||||
|
|
||||||
|
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||||
|
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 +43,41 @@ 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)
|
||||||
|
|
||||||
|
|
||||||
|
async def async_remove_dnd_from_virtual_group(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
coordinator: AmazonDevicesCoordinator,
|
||||||
|
) -> None:
|
||||||
|
"""Remove entity DND from virtual group."""
|
||||||
|
entity_registry = er.async_get(hass)
|
||||||
|
|
||||||
|
for serial_num in coordinator.data:
|
||||||
|
unique_id = f"{serial_num}-do_not_disturb"
|
||||||
|
entity_id = entity_registry.async_get_entity_id(
|
||||||
|
DOMAIN, SWITCH_DOMAIN, unique_id
|
||||||
|
)
|
||||||
|
is_group = coordinator.data[serial_num].device_family == SPEAKER_GROUP_FAMILY
|
||||||
|
if entity_id and is_group:
|
||||||
|
entity_registry.async_remove(entity_id)
|
||||||
|
_LOGGER.debug("Removed DND switch from virtual group %s", entity_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,57 +676,40 @@ 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": (
|
||||||
if entity_state is not None
|
entity_state.attributes.get(ATTR_ASSUMED_STATE, False)
|
||||||
else None,
|
if entity_state is not None
|
||||||
"capabilities": entity_config.capabilities
|
else None
|
||||||
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 (
|
if (device_id_ := entity_entry.device_id) is not None:
|
||||||
((device_id_ := entity_entry.device_id) is not None)
|
if device_id_ in removed_devices:
|
||||||
and ((new_device_id := device_id_mapping.get(device_id_)) is not None)
|
# The device was removed, so we remove the entity too
|
||||||
and (new_device_id[0] == integration_domain)
|
continue
|
||||||
):
|
|
||||||
device_info = devices_info[new_device_id[1]]
|
|
||||||
device_info["entities"].append(entity_info)
|
|
||||||
else:
|
|
||||||
entities_info.append(entity_info)
|
|
||||||
|
|
||||||
integrations = {
|
if (
|
||||||
domain: integration
|
new_device_id := device_id_mapping.get(device_id_)
|
||||||
for domain, integration in (
|
) is not None and (new_device_id[0] == integration_domain):
|
||||||
await async_get_integrations(hass, integrations_info.keys())
|
device_info = devices_info[new_device_id[1]]
|
||||||
).items()
|
device_info["entities"].append(entity_info)
|
||||||
if isinstance(integration, Integration)
|
continue
|
||||||
}
|
|
||||||
|
|
||||||
for domain, integration_info in integrations_info.items():
|
entities_info.append(entity_info)
|
||||||
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",
|
||||||
|
@@ -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:
|
area_id: str | None = None
|
||||||
|
|
||||||
|
if (
|
||||||
|
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
|
||||||
|
|
||||||
if (entity_area_id := entity.area_id) is None:
|
device_entry = device_registry.async_get(device_id)
|
||||||
if (entity.device_id is None) or (
|
if device_entry is None:
|
||||||
(entity_device := device_registry.async_get(entity.device_id))
|
return False
|
||||||
is None
|
|
||||||
):
|
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
|
return False
|
||||||
|
|
||||||
entity_area_id = entity_device.area_id
|
target_device_entry = device_registry.async_get(
|
||||||
|
target_entity_entry.device_id
|
||||||
|
)
|
||||||
|
if target_device_entry is None:
|
||||||
|
return False
|
||||||
|
|
||||||
if entity_area_id != device.area_id:
|
target_area_id = target_device_entry.area_id
|
||||||
|
|
||||||
|
if target_area_id != area_id:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@@ -7,13 +7,13 @@ from collections import namedtuple
|
|||||||
from collections.abc import Awaitable, Callable, Coroutine
|
from collections.abc import Awaitable, Callable, Coroutine
|
||||||
import functools
|
import functools
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, cast
|
from typing import Any
|
||||||
|
|
||||||
from aioasuswrt.asuswrt import AsusWrt as AsusWrtLegacy
|
from aioasuswrt.asuswrt import AsusWrt as AsusWrtLegacy
|
||||||
from aiohttp import ClientSession
|
from aiohttp import ClientSession
|
||||||
from asusrouter import AsusRouter, AsusRouterError
|
from asusrouter import AsusRouter, AsusRouterError
|
||||||
from asusrouter.config import ARConfigKey
|
from asusrouter.config import ARConfigKey
|
||||||
from asusrouter.modules.client import AsusClient
|
from asusrouter.modules.client import AsusClient, ConnectionState
|
||||||
from asusrouter.modules.data import AsusData
|
from asusrouter.modules.data import AsusData
|
||||||
from asusrouter.modules.homeassistant import convert_to_ha_data, convert_to_ha_sensors
|
from asusrouter.modules.homeassistant import convert_to_ha_data, convert_to_ha_sensors
|
||||||
from asusrouter.tools.connection import get_cookie_jar
|
from asusrouter.tools.connection import get_cookie_jar
|
||||||
@@ -219,7 +219,7 @@ class AsusWrtLegacyBridge(AsusWrtBridge):
|
|||||||
@property
|
@property
|
||||||
def is_connected(self) -> bool:
|
def is_connected(self) -> bool:
|
||||||
"""Get connected status."""
|
"""Get connected status."""
|
||||||
return cast(bool, self._api.is_connected)
|
return self._api.is_connected
|
||||||
|
|
||||||
async def async_connect(self) -> None:
|
async def async_connect(self) -> None:
|
||||||
"""Connect to the device."""
|
"""Connect to the device."""
|
||||||
@@ -235,8 +235,7 @@ class AsusWrtLegacyBridge(AsusWrtBridge):
|
|||||||
|
|
||||||
async def async_disconnect(self) -> None:
|
async def async_disconnect(self) -> None:
|
||||||
"""Disconnect to the device."""
|
"""Disconnect to the device."""
|
||||||
if self._api is not None and self._protocol == PROTOCOL_TELNET:
|
await self._api.async_disconnect()
|
||||||
self._api.connection.disconnect()
|
|
||||||
|
|
||||||
async def async_get_connected_devices(self) -> dict[str, WrtDevice]:
|
async def async_get_connected_devices(self) -> dict[str, WrtDevice]:
|
||||||
"""Get list of connected devices."""
|
"""Get list of connected devices."""
|
||||||
@@ -437,6 +436,7 @@ class AsusWrtHttpBridge(AsusWrtBridge):
|
|||||||
if dev.connection is not None
|
if dev.connection is not None
|
||||||
and dev.description is not None
|
and dev.description is not None
|
||||||
and dev.connection.ip_address is not None
|
and dev.connection.ip_address is not None
|
||||||
|
and dev.state is ConnectionState.CONNECTED
|
||||||
}
|
}
|
||||||
|
|
||||||
async def async_get_available_sensors(self) -> dict[str, dict[str, Any]]:
|
async def async_get_available_sensors(self) -> dict[str, dict[str, Any]]:
|
||||||
|
@@ -7,5 +7,5 @@
|
|||||||
"integration_type": "hub",
|
"integration_type": "hub",
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"loggers": ["aioasuswrt", "asusrouter", "asyncssh"],
|
"loggers": ["aioasuswrt", "asusrouter", "asyncssh"],
|
||||||
"requirements": ["aioasuswrt==1.4.0", "asusrouter==1.21.0"]
|
"requirements": ["aioasuswrt==1.5.1", "asusrouter==1.21.0"]
|
||||||
}
|
}
|
||||||
|
@@ -36,11 +36,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: AugustConfigEntry) -> bo
|
|||||||
raise ConfigEntryAuthFailed("Migration to OAuth required")
|
raise ConfigEntryAuthFailed("Migration to OAuth required")
|
||||||
|
|
||||||
session = async_create_august_clientsession(hass)
|
session = async_create_august_clientsession(hass)
|
||||||
implementation = (
|
try:
|
||||||
await config_entry_oauth2_flow.async_get_config_entry_implementation(
|
implementation = (
|
||||||
hass, entry
|
await config_entry_oauth2_flow.async_get_config_entry_implementation(
|
||||||
|
hass, entry
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except ValueError as err:
|
||||||
|
raise ConfigEntryNotReady("OAuth implementation not available") from err
|
||||||
oauth_session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation)
|
oauth_session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation)
|
||||||
august_gateway = AugustGateway(Path(hass.config.config_dir), session, oauth_session)
|
august_gateway = AugustGateway(Path(hass.config.config_dir), session, oauth_session)
|
||||||
try:
|
try:
|
||||||
|
@@ -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
|
||||||
|
@@ -68,12 +68,17 @@ class IntegrationMatchHistory:
|
|||||||
manufacturer_data: bool
|
manufacturer_data: bool
|
||||||
service_data: set[str]
|
service_data: set[str]
|
||||||
service_uuids: set[str]
|
service_uuids: set[str]
|
||||||
|
name: str
|
||||||
|
|
||||||
|
|
||||||
def seen_all_fields(
|
def seen_all_fields(
|
||||||
previous_match: IntegrationMatchHistory, advertisement_data: AdvertisementData
|
previous_match: IntegrationMatchHistory,
|
||||||
|
advertisement_data: AdvertisementData,
|
||||||
|
name: str,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Return if we have seen all fields."""
|
"""Return if we have seen all fields."""
|
||||||
|
if previous_match.name != name:
|
||||||
|
return False
|
||||||
if not previous_match.manufacturer_data and advertisement_data.manufacturer_data:
|
if not previous_match.manufacturer_data and advertisement_data.manufacturer_data:
|
||||||
return False
|
return False
|
||||||
if advertisement_data.service_data and (
|
if advertisement_data.service_data and (
|
||||||
@@ -122,10 +127,11 @@ class IntegrationMatcher:
|
|||||||
device = service_info.device
|
device = service_info.device
|
||||||
advertisement_data = service_info.advertisement
|
advertisement_data = service_info.advertisement
|
||||||
connectable = service_info.connectable
|
connectable = service_info.connectable
|
||||||
|
name = service_info.name
|
||||||
matched = self._matched_connectable if connectable else self._matched
|
matched = self._matched_connectable if connectable else self._matched
|
||||||
matched_domains: set[str] = set()
|
matched_domains: set[str] = set()
|
||||||
if (previous_match := matched.get(device.address)) and seen_all_fields(
|
if (previous_match := matched.get(device.address)) and seen_all_fields(
|
||||||
previous_match, advertisement_data
|
previous_match, advertisement_data, name
|
||||||
):
|
):
|
||||||
# We have seen all fields so we can skip the rest of the matchers
|
# We have seen all fields so we can skip the rest of the matchers
|
||||||
return matched_domains
|
return matched_domains
|
||||||
@@ -140,11 +146,13 @@ class IntegrationMatcher:
|
|||||||
)
|
)
|
||||||
previous_match.service_data |= set(advertisement_data.service_data)
|
previous_match.service_data |= set(advertisement_data.service_data)
|
||||||
previous_match.service_uuids |= set(advertisement_data.service_uuids)
|
previous_match.service_uuids |= set(advertisement_data.service_uuids)
|
||||||
|
previous_match.name = name
|
||||||
else:
|
else:
|
||||||
matched[device.address] = IntegrationMatchHistory(
|
matched[device.address] = IntegrationMatchHistory(
|
||||||
manufacturer_data=bool(advertisement_data.manufacturer_data),
|
manufacturer_data=bool(advertisement_data.manufacturer_data),
|
||||||
service_data=set(advertisement_data.service_data),
|
service_data=set(advertisement_data.service_data),
|
||||||
service_uuids=set(advertisement_data.service_uuids),
|
service_uuids=set(advertisement_data.service_uuids),
|
||||||
|
name=name,
|
||||||
)
|
)
|
||||||
return matched_domains
|
return matched_domains
|
||||||
|
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
"integration_type": "device",
|
"integration_type": "device",
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"loggers": ["brother", "pyasn1", "pysmi", "pysnmp"],
|
"loggers": ["brother", "pyasn1", "pysmi", "pysnmp"],
|
||||||
"requirements": ["brother==5.1.0"],
|
"requirements": ["brother==5.1.1"],
|
||||||
"zeroconf": [
|
"zeroconf": [
|
||||||
{
|
{
|
||||||
"type": "_printer._tcp.local.",
|
"type": "_printer._tcp.local.",
|
||||||
|
@@ -38,6 +38,10 @@ TYPE_SPECIFY_COUNTRY = "specify_country_code"
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
DESCRIPTION_PLACEHOLDER = {
|
||||||
|
"register_link": "https://electricitymaps.com/free-tier",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class ElectricityMapsConfigFlow(ConfigFlow, domain=DOMAIN):
|
class ElectricityMapsConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Co2signal."""
|
"""Handle a config flow for Co2signal."""
|
||||||
@@ -70,6 +74,7 @@ class ElectricityMapsConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="user",
|
step_id="user",
|
||||||
data_schema=data_schema,
|
data_schema=data_schema,
|
||||||
|
description_placeholders=DESCRIPTION_PLACEHOLDER,
|
||||||
)
|
)
|
||||||
|
|
||||||
data = {CONF_API_KEY: user_input[CONF_API_KEY]}
|
data = {CONF_API_KEY: user_input[CONF_API_KEY]}
|
||||||
@@ -179,4 +184,5 @@ class ElectricityMapsConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
step_id=step_id,
|
step_id=step_id,
|
||||||
data_schema=data_schema,
|
data_schema=data_schema,
|
||||||
errors=errors,
|
errors=errors,
|
||||||
|
description_placeholders=DESCRIPTION_PLACEHOLDER,
|
||||||
)
|
)
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
"location": "[%key:common::config_flow::data::location%]",
|
"location": "[%key:common::config_flow::data::location%]",
|
||||||
"api_key": "[%key:common::config_flow::data::access_token%]"
|
"api_key": "[%key:common::config_flow::data::access_token%]"
|
||||||
},
|
},
|
||||||
"description": "Visit https://electricitymaps.com/free-tier to request a token."
|
"description": "Visit the [Electricity Maps page]({register_link}) to request a token."
|
||||||
},
|
},
|
||||||
"coordinates": {
|
"coordinates": {
|
||||||
"data": {
|
"data": {
|
||||||
|
@@ -166,6 +166,7 @@ class CoinbaseConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
data_schema=STEP_USER_DATA_SCHEMA,
|
data_schema=STEP_USER_DATA_SCHEMA,
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
"account_name": self.reauth_entry.title,
|
"account_name": self.reauth_entry.title,
|
||||||
|
"developer_url": "https://www.coinbase.com/developer-platform",
|
||||||
},
|
},
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
@@ -195,6 +196,7 @@ class CoinbaseConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
data_schema=STEP_USER_DATA_SCHEMA,
|
data_schema=STEP_USER_DATA_SCHEMA,
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
"account_name": self.reauth_entry.title,
|
"account_name": self.reauth_entry.title,
|
||||||
|
"developer_url": "https://www.coinbase.com/developer-platform",
|
||||||
},
|
},
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
"reauth_confirm": {
|
"reauth_confirm": {
|
||||||
"title": "Update Coinbase API credentials",
|
"title": "Update Coinbase API credentials",
|
||||||
"description": "Your current Coinbase API key appears to be for the deprecated v2 API. Please reconfigure with a new API key created for the v3 API. Visit https://www.coinbase.com/developer-platform to create new credentials for {account_name}.",
|
"description": "Your current Coinbase API key appears to be for the deprecated v2 API. Please reconfigure with a new API key created for the v3 API. Visit the [Developer Platform]({developer_url}) to create new credentials for {account_name}.",
|
||||||
"data": {
|
"data": {
|
||||||
"api_key": "[%key:common::config_flow::data::api_key%]",
|
"api_key": "[%key:common::config_flow::data::api_key%]",
|
||||||
"api_token": "API secret"
|
"api_token": "API secret"
|
||||||
|
@@ -29,10 +29,23 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = cast(ComelitVedoSystem, config_entry.runtime_data)
|
coordinator = cast(ComelitVedoSystem, config_entry.runtime_data)
|
||||||
|
|
||||||
async_add_entities(
|
known_devices: set[int] = set()
|
||||||
ComelitVedoBinarySensorEntity(coordinator, device, config_entry.entry_id)
|
|
||||||
for device in coordinator.data["alarm_zones"].values()
|
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(
|
||||||
|
ComelitVedoBinarySensorEntity(
|
||||||
|
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(
|
||||||
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from asyncio.exceptions import TimeoutError
|
from asyncio.exceptions import TimeoutError
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
|
import re
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aiocomelit import (
|
from aiocomelit import (
|
||||||
@@ -25,23 +26,22 @@ 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"
|
||||||
|
|
||||||
|
|
||||||
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.string,
|
||||||
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.string})
|
||||||
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.string,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -51,6 +51,9 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> dict[str,
|
|||||||
|
|
||||||
api: ComelitCommonApi
|
api: ComelitCommonApi
|
||||||
|
|
||||||
|
if not re.fullmatch(r"[0-9]{4,10}", data[CONF_PIN]):
|
||||||
|
raise InvalidPin
|
||||||
|
|
||||||
session = await async_client_session(hass)
|
session = await async_client_session(hass)
|
||||||
if data.get(CONF_TYPE, BRIDGE) == BRIDGE:
|
if data.get(CONF_TYPE, BRIDGE) == BRIDGE:
|
||||||
api = ComeliteSerialBridgeApi(
|
api = ComeliteSerialBridgeApi(
|
||||||
@@ -101,6 +104,8 @@ class ComelitConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except InvalidAuth:
|
except InvalidAuth:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
|
except InvalidPin:
|
||||||
|
errors["base"] = "invalid_pin"
|
||||||
except Exception: # noqa: BLE001
|
except Exception: # noqa: BLE001
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
@@ -142,6 +147,8 @@ class ComelitConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except InvalidAuth:
|
except InvalidAuth:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
|
except InvalidPin:
|
||||||
|
errors["base"] = "invalid_pin"
|
||||||
except Exception: # noqa: BLE001
|
except Exception: # noqa: BLE001
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
@@ -185,6 +192,8 @@ class ComelitConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except InvalidAuth:
|
except InvalidAuth:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
|
except InvalidPin:
|
||||||
|
errors["base"] = "invalid_pin"
|
||||||
except Exception: # noqa: BLE001
|
except Exception: # noqa: BLE001
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
@@ -206,3 +215,7 @@ class CannotConnect(HomeAssistantError):
|
|||||||
|
|
||||||
class InvalidAuth(HomeAssistantError):
|
class InvalidAuth(HomeAssistantError):
|
||||||
"""Error to indicate there is invalid auth."""
|
"""Error to indicate there is invalid auth."""
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidPin(HomeAssistantError):
|
||||||
|
"""Error to indicate an invalid pin."""
|
||||||
|
@@ -161,7 +161,7 @@ class ComelitSerialBridge(
|
|||||||
entry: ComelitConfigEntry,
|
entry: ComelitConfigEntry,
|
||||||
host: str,
|
host: str,
|
||||||
port: int,
|
port: int,
|
||||||
pin: int,
|
pin: str,
|
||||||
session: ClientSession,
|
session: ClientSession,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the scanner."""
|
"""Initialize the scanner."""
|
||||||
@@ -195,7 +195,7 @@ class ComelitVedoSystem(ComelitBaseCoordinator[AlarmDataObject]):
|
|||||||
entry: ComelitConfigEntry,
|
entry: ComelitConfigEntry,
|
||||||
host: str,
|
host: str,
|
||||||
port: int,
|
port: int,
|
||||||
pin: int,
|
pin: str,
|
||||||
session: ClientSession,
|
session: ClientSession,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the scanner."""
|
"""Initialize the scanner."""
|
||||||
|
@@ -7,7 +7,14 @@ from typing import Any, cast
|
|||||||
from aiocomelit import ComelitSerialBridgeObject
|
from aiocomelit import ComelitSerialBridgeObject
|
||||||
from aiocomelit.const import COVER, STATE_COVER, STATE_OFF, STATE_ON
|
from aiocomelit.const import COVER, STATE_COVER, STATE_OFF, STATE_ON
|
||||||
|
|
||||||
from homeassistant.components.cover import CoverDeviceClass, CoverEntity
|
from homeassistant.components.cover import (
|
||||||
|
STATE_CLOSED,
|
||||||
|
STATE_CLOSING,
|
||||||
|
STATE_OPEN,
|
||||||
|
STATE_OPENING,
|
||||||
|
CoverDeviceClass,
|
||||||
|
CoverEntity,
|
||||||
|
)
|
||||||
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 homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
@@ -29,10 +36,21 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = cast(ComelitSerialBridge, config_entry.runtime_data)
|
coordinator = cast(ComelitSerialBridge, config_entry.runtime_data)
|
||||||
|
|
||||||
async_add_entities(
|
known_devices: set[int] = set()
|
||||||
ComelitCoverEntity(coordinator, device, config_entry.entry_id)
|
|
||||||
for device in coordinator.data[COVER].values()
|
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(
|
||||||
|
ComelitCoverEntity(coordinator, device, config_entry.entry_id)
|
||||||
|
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):
|
||||||
@@ -51,7 +69,6 @@ class ComelitCoverEntity(ComelitBridgeBaseEntity, RestoreEntity, CoverEntity):
|
|||||||
super().__init__(coordinator, device, config_entry_entry_id)
|
super().__init__(coordinator, device, config_entry_entry_id)
|
||||||
# Device doesn't provide a status so we assume UNKNOWN at first startup
|
# Device doesn't provide a status so we assume UNKNOWN at first startup
|
||||||
self._last_action: int | None = None
|
self._last_action: int | None = None
|
||||||
self._last_state: str | None = None
|
|
||||||
|
|
||||||
def _current_action(self, action: str) -> bool:
|
def _current_action(self, action: str) -> bool:
|
||||||
"""Return the current cover action."""
|
"""Return the current cover action."""
|
||||||
@@ -87,7 +104,6 @@ class ComelitCoverEntity(ComelitBridgeBaseEntity, RestoreEntity, CoverEntity):
|
|||||||
@bridge_api_call
|
@bridge_api_call
|
||||||
async def _cover_set_state(self, action: int, state: int) -> None:
|
async def _cover_set_state(self, action: int, state: int) -> None:
|
||||||
"""Set desired cover state."""
|
"""Set desired cover state."""
|
||||||
self._last_state = self.state
|
|
||||||
await self.coordinator.api.set_device_status(COVER, self._device.index, action)
|
await self.coordinator.api.set_device_status(COVER, self._device.index, action)
|
||||||
self.coordinator.data[COVER][self._device.index].status = state
|
self.coordinator.data[COVER][self._device.index].status = state
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
@@ -113,5 +129,10 @@ class ComelitCoverEntity(ComelitBridgeBaseEntity, RestoreEntity, CoverEntity):
|
|||||||
|
|
||||||
await super().async_added_to_hass()
|
await super().async_added_to_hass()
|
||||||
|
|
||||||
if last_state := await self.async_get_last_state():
|
if (state := await self.async_get_last_state()) is not None:
|
||||||
self._last_state = last_state.state
|
if state.state == STATE_CLOSED:
|
||||||
|
self._last_action = STATE_COVER.index(STATE_CLOSING)
|
||||||
|
if state.state == STATE_OPEN:
|
||||||
|
self._last_action = STATE_COVER.index(STATE_OPENING)
|
||||||
|
|
||||||
|
self._attr_is_closed = state.state == STATE_CLOSED
|
||||||
|
@@ -27,10 +27,21 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = cast(ComelitSerialBridge, config_entry.runtime_data)
|
coordinator = cast(ComelitSerialBridge, config_entry.runtime_data)
|
||||||
|
|
||||||
async_add_entities(
|
known_devices: set[int] = set()
|
||||||
ComelitLightEntity(coordinator, device, config_entry.entry_id)
|
|
||||||
for device in coordinator.data[LIGHT].values()
|
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(
|
||||||
|
ComelitLightEntity(coordinator, device, config_entry.entry_id)
|
||||||
|
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):
|
||||||
|
@@ -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==1.1.2"]
|
||||||
}
|
}
|
||||||
|
@@ -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:
|
||||||
ComelitBridgeSensorEntity(
|
current_devices = set(coordinator.data[OTHER])
|
||||||
coordinator, device, config_entry.entry_id, sensor_desc
|
new_devices = current_devices - known_devices
|
||||||
|
if new_devices:
|
||||||
|
known_devices.update(new_devices)
|
||||||
|
async_add_entities(
|
||||||
|
ComelitBridgeSensorEntity(
|
||||||
|
coordinator, device, config_entry.entry_id, sensor_desc
|
||||||
|
)
|
||||||
|
for sensor_desc in SENSOR_BRIDGE_TYPES
|
||||||
|
for device in coordinator.data[OTHER].values()
|
||||||
|
if device.index in new_devices
|
||||||
)
|
)
|
||||||
for sensor_desc in SENSOR_BRIDGE_TYPES
|
|
||||||
)
|
_check_device()
|
||||||
async_add_entities(entities)
|
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:
|
||||||
ComelitVedoSensorEntity(
|
current_devices = set(coordinator.data["alarm_zones"])
|
||||||
coordinator, device, config_entry.entry_id, sensor_desc
|
new_devices = current_devices - known_devices
|
||||||
|
if new_devices:
|
||||||
|
known_devices.update(new_devices)
|
||||||
|
async_add_entities(
|
||||||
|
ComelitVedoSensorEntity(
|
||||||
|
coordinator, device, config_entry.entry_id, sensor_desc
|
||||||
|
)
|
||||||
|
for sensor_desc in SENSOR_VEDO_TYPES
|
||||||
|
for device in coordinator.data["alarm_zones"].values()
|
||||||
|
if device.index in new_devices
|
||||||
)
|
)
|
||||||
for sensor_desc in SENSOR_VEDO_TYPES
|
|
||||||
)
|
_check_device()
|
||||||
async_add_entities(entities)
|
config_entry.async_on_unload(coordinator.async_add_listener(_check_device))
|
||||||
|
|
||||||
|
|
||||||
class ComelitBridgeSensorEntity(ComelitBridgeBaseEntity, SensorEntity):
|
class ComelitBridgeSensorEntity(ComelitBridgeBaseEntity, SensorEntity):
|
||||||
|
@@ -43,11 +43,13 @@
|
|||||||
"reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]",
|
"reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]",
|
||||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||||
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
||||||
|
"invalid_pin": "The provided PIN is invalid. It must be a 4-10 digit number.",
|
||||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||||
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
||||||
|
"invalid_pin": "[%key:component::comelit::config::abort::invalid_pin%]",
|
||||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -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."""
|
||||||
|
@@ -514,7 +514,7 @@ class ChatLog:
|
|||||||
"""Set the LLM system prompt."""
|
"""Set the LLM system prompt."""
|
||||||
llm_api: llm.APIInstance | None = None
|
llm_api: llm.APIInstance | None = None
|
||||||
|
|
||||||
if user_llm_hass_api is None:
|
if not user_llm_hass_api:
|
||||||
pass
|
pass
|
||||||
elif isinstance(user_llm_hass_api, llm.API):
|
elif isinstance(user_llm_hass_api, llm.API):
|
||||||
llm_api = await user_llm_hass_api.async_get_api_instance(llm_context)
|
llm_api = await user_llm_hass_api.async_get_api_instance(llm_context)
|
||||||
|
@@ -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.1"]
|
||||||
|
}
|
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%]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -6,6 +6,6 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/daikin",
|
"documentation": "https://www.home-assistant.io/integrations/daikin",
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"loggers": ["pydaikin"],
|
"loggers": ["pydaikin"],
|
||||||
"requirements": ["pydaikin==2.16.0"],
|
"requirements": ["pydaikin==2.17.1"],
|
||||||
"zeroconf": ["_dkapi._tcp.local."]
|
"zeroconf": ["_dkapi._tcp.local."]
|
||||||
}
|
}
|
||||||
|
@@ -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:
|
||||||
response = await self.resolver.query(self.hostname, self.querytype)
|
async with asyncio.timeout(10):
|
||||||
|
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)
|
||||||
|
@@ -61,5 +61,8 @@ class EcobeeFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="authorize",
|
step_id="authorize",
|
||||||
errors=errors,
|
errors=errors,
|
||||||
description_placeholders={"pin": self._ecobee.pin},
|
description_placeholders={
|
||||||
|
"pin": self._ecobee.pin,
|
||||||
|
"auth_url": "https://www.ecobee.com/consumerportal/index.html",
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"authorize": {
|
"authorize": {
|
||||||
"description": "Please authorize this app at https://www.ecobee.com/consumerportal/index.html with PIN code:\n\n{pin}\n\nThen, select **Submit**."
|
"description": "Please authorize this app at {auth_url} with PIN code:\n\n{pin}\n\nThen, select **Submit**."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
@@ -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.1.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%]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -6,5 +6,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/environment_canada",
|
"documentation": "https://www.home-assistant.io/integrations/environment_canada",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["env_canada"],
|
"loggers": ["env_canada"],
|
||||||
"requirements": ["env-canada==0.11.2"]
|
"requirements": ["env-canada==0.11.3"]
|
||||||
}
|
}
|
||||||
|
@@ -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"
|
||||||
],
|
],
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user