-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically add Airzone entities #121891
Dynamically add Airzone entities #121891
Conversation
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
Why don't we dynamically add devices? |
Honestly because I don't know how to do it... |
I recently implemented this in Mealie todo list. Also knocki's event has this. |
This reverts commit 3ecc084.
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
Thanks @joostlek, |
I dont exactly know how much work goes into one of them, but i dont think it would be that big of a deal to put them into one |
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
@joostlek many thanks for your help :) Let me know if it's too much for a single PR and I will split it into separate PRs. |
async_add_entities( | ||
AirzoneSystemBinarySensor( | ||
coordinator, | ||
description, | ||
entry, | ||
system_zone_id, | ||
systems_data.get(system_zone_id), | ||
) | ||
for system_zone_id in new_systems | ||
for description in SYSTEM_BINARY_SENSOR_TYPES | ||
if description.key in systems_data.get(system_zone_id) | ||
) | ||
added_systems.update(new_systems) | ||
|
||
zones_data = coordinator.data.get(AZD_ZONES, {}) | ||
received_zones = set(zones_data) | ||
new_zones = received_zones - added_zones | ||
if new_zones: | ||
async_add_entities( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we combine the call? Async_add_entities is quite expensive iirc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in f9c4dbb
assert state is None | ||
|
||
mock_hvac.return_value = HVAC_MOCK | ||
async_fire_time_changed(hass, utcnow() + SCAN_INTERVAL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the freezer as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 4b66f35
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh and please wrap all the coordinator.add_listeners
in entry.async_on_unload
to avoid having listeners alive after the integration is unloaded
entry, | ||
added_hotwater = True | ||
|
||
if not added_webserver and AZD_WEBSERVER in coordinator.data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be added on runtime? Or is this something that is there by default?
You could also make separate listeners for these and if the webserver is already set up, we don't attach the listener
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually you're right, so on a second thought I've removed the webserver and water heater from the listeners since those can't be dynamically added.
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also look at dynamically deleting them in the future to keep HA in sync with the device and improve the user experience even more :)
Commit c044417 incorrecly renamed system_id to system_zone_id. Fixes: c044417 ("Dynamically add Airzone entities (home-assistant#121891)") Signed-off-by: Álvaro Fernández Rojas <[email protected]>
Proposed change
Reload Airzone config entry on new devices in order to expose new devices and entities.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: