Support for multiple Fibaro gateways#19705
Conversation
Added multiple gateway support Reworked parameter flow to platforms to enable multiple controllers Breaking change to config, now a list of gateways is expected instead of a single config
Added new location of fibaro component
|
ok to merge when comments addressed |
Addressed issues raised by code review Added extended debug logging to get better reports from users if the device type mapping is not perfect
| hass.data[FIBARO_DEVICES] = controller.fibaro_devices | ||
| for controller in hass.data[FIBARO_CONTROLLERS].values(): | ||
| controller.disable_state_handler() | ||
| hass.data[FIBARO_CONTROLLERS] = {} |
There was a problem hiding this comment.
If we don't need this key anymore we should pop it or delete it from the dict.
There was a problem hiding this comment.
Wouldn't that be a less efficient algorithm, tho?
I know it's highly theoretical either way, since it's usually a single element list and it's probably equally readable either way, but this seems like a more appropriate solution on an embedded device. I could be wrong, I'm new here. Of course if you insist, I'll modify it.
There was a problem hiding this comment.
I don't think we should worry about speed here, but clean up remaining references.
There was a problem hiding this comment.
For now though we don't really need to clean up anything, since this is only done when home assistant shuts down. So we can remove this line completely. Clean up will be relevant if moving this component to use config entries.
There was a problem hiding this comment.
Ok, I'll keep in mind.
There was a problem hiding this comment.
Please remove this line.
There was a problem hiding this comment.
Ok, I removed it. Just for my education, what was wrong with that line? I'm new to python but as far as I understand it did remove the reference to all items in the map and by that freeing up the memory. I understand your suggestion that you'd prefer enumerate + pop, but coming from decades of embedded c programming and knowing how enumerate and pop works, that's really a very wasteful way of solving the problem. Afaik, enumerate iterates through the list an extra time, creates a new index, and pop unlinks items one-by-one from the list. I could be totally wrong on my assumptions, but in general this construct feels like something to discourage on an embedded platform. I could be totally not pythonic in thinking this.
Anyhow, I'd love to learn. Thanks in advance.
Changes to how configuration is read and schemas Fix to device type mapping logic
| hass.data[FIBARO_DEVICES] = controller.fibaro_devices | ||
| for controller in hass.data[FIBARO_CONTROLLERS].values(): | ||
| controller.disable_state_handler() | ||
| hass.data[FIBARO_CONTROLLERS] = {} |
There was a problem hiding this comment.
For now though we don't really need to clean up anything, since this is only done when home assistant shuts down. So we can remove this line completely. Clean up will be relevant if moving this component to use config entries.
changes based on code review
|
Can be merged when docs PR is linked in the PR description. |
Documentation change based on home-assistant/core#19705
|
Updated documentation, added link to PR |
* Updated based on changes Documentation change based on home-assistant/core#19705 * Update fibaro.markdown
Description:
Fibaro component now supports multiple Fibaro HC gateways.
Breaking change:
A list of gateways is expected instead of a single config.
Related issue (if applicable): fixes #
Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#<home-assistant.io PR number goes here>
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.