ZHA - add events for remote like devices#18493
ZHA - add events for remote like devices#18493dmulcahey wants to merge 17 commits intohome-assistant:devfrom
Conversation
| self._device_registry = collections.defaultdict(list) | ||
| self._events = [] | ||
| hass.data[DISCOVERY_KEY] = hass.data.get(DISCOVERY_KEY, {}) | ||
| import homeassistant.components.zha.const as zha_const |
There was a problem hiding this comment.
This can be imported at the top of the module.
There was a problem hiding this comment.
There is a design issue w/ the modules that causes circular imports. I have it corrected in another branch and can fix this in a subsequent PR if that is ok.
| async def async_device_initialized(self, device, join): | ||
| """Handle device joined and basic information discovered (async).""" | ||
| import zigpy.profiles | ||
| import homeassistant.components.zha.event as zha_event |
There was a problem hiding this comment.
There is a design issue w/ the modules that causes circular imports. I have it corrected in another branch and can fix this in a subsequent PR if that is ok.
| """Handle device joined and basic information discovered (async).""" | ||
| import zigpy.profiles | ||
| import homeassistant.components.zha.event as zha_event | ||
| import homeassistant.components.zha.const as zha_const |
There was a problem hiding this comment.
There is a design issue w/ the modules that causes circular imports. I have it corrected in another branch and can fix this in a subsequent PR if that is ok.
| _LOGGER.debug( | ||
| "remotes config path: %s Is path: %s", | ||
| remotes_config_path, | ||
| os.path.isfile(remotes_config_path) |
There was a problem hiding this comment.
This is doing I/O in an async context. That's not allowed.
There was a problem hiding this comment.
any suggestions on how to handle? Should I just load this at the top of the module and not in the function?
| {ZHA: {}, ZLL: {}} | ||
| ) | ||
|
|
||
| remote_devices = load_json(remotes_config_path) |
There was a problem hiding this comment.
What are we doing here and what does it have to do with events? Looks like another feature, so should not be part of this PR.
There was a problem hiding this comment.
without this nothing sends events. This is a registry so users can opt certain devices in to sending events. It is described in the PR description.
There was a problem hiding this comment.
Why does it need to be configurable?
There was a problem hiding this comment.
There are 100’s of zigbee devices and they don’t all follow defined specs. Also, there is no hard rule for what devices should use / need events. The alternative is a HA PR for every particular device that people want events from.
|
@MartinHjelmare Thanks a bunch for the help here and the comments. I think I have a much more elegant solution as a result that ditches the registration file. Closing this and I will open a new PR that references this one so that I can get your feedback. Thanks again! |
The original motivation for this came from comments in #14795. I then opened PR #14902 which I closed due to it getting stale and hard to rebase easily. There was good feedback in that PR and I believe I managed to address most of the comments. That being said, I have changed direction a bit. This PR adds support for events for remote like devices. It also avoids breaking changes by leaving the original entities intact and functional.
This is opt in only. There is a new config file
zha-remotes.jsonthat has this shape:This allows users to opt into this functionality without needing HA releases to "remap" devices.