Cache supported commands for each WyzeCamera #922
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This loads the
device_config.json
and caches the list of supported commands for each camera. As of today this list is checked only inrespond_to_ioctrl_10001
for command10008
:Once this list is loaded for the current camera, it can then be queried later by checking:
A possible enhancement could be made if memory consumption is a concern, that would only keep track of a smaller list of high-value commands (like PTZ commands in this example), rather than the full list of commands from
device_config.json
. Since most functionality that would need to check this would only be checking for a relatively small list of commands.This relates to #921 (comment) as a prerequisite to publishing optional entities during discovery, such as the "Pan Cruise" switch, which should be published only if the camera supports it.
NOTE: I do not know what your typical dev environment looks like, or the best way to test changes before submitting a PR. I use the bridge as a HA add-on, so I don't know the best way to spin up a test instance outside of HA just for testing. I also did not see a .github workflow that runs any kind of code style checks, unit tests, or simple "does it work at all" checks. I'm happy to run some sanity checks on my own if you have any documentation for best practices for PRs.