Skip to content
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

Cache supported commands for each WyzeCamera #922

Closed
wants to merge 1 commit into from

Conversation

jhansche
Copy link
Contributor

This loads the device_config.json and caches the list of supported commands for each camera. As of today this list is checked only in respond_to_ioctrl_10001 for command 10008:

    if supports(product_model, protocol, 10008):
        response: TutkWyzeProtocolMessage = K10008ConnectUserAuth(
            challenge_response, phone_id, open_userid, open_audio=enable_audio
        )
    else:
        response = K10002ConnectAuth(challenge_response, mac, open_audio=enable_audio)

Once this list is loaded for the current camera, it can then be queried later by checking:

if cam.supports_command(11018):
  # has PTZ support

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.

@mrlt8
Copy link
Owner

mrlt8 commented Jul 17, 2023

Thank you! Will need to look into this as I haven't really maintained device_config.json since porting it over from the original kroo/wyzecam library, and it may need to be updated. However, I'm not too sure how reliable it would be to use it to check for support since some cams will show "support" for a command but not actually do anything (e.g. RTSP 10600).

@jhansche
Copy link
Contributor Author

So would your preference be that things like PTZ commands check for "PAN" in the model string?

@mrlt8
Copy link
Owner

mrlt8 commented Jul 17, 2023

Potentially, as most of the PTZ cams will still "work" if you send them to a non-pan cam.

@jhansche
Copy link
Contributor Author

Right, this wasn't about avoiding the potential for command errors. It's more about not presenting entities during discovery if they aren't relevant to the device. The user could always choose to hide or disable one of the discovered entities, so if you're not that concerned about it, maybe it's unnecessary to go this far?

mrlt8 added a commit that referenced this pull request Jul 17, 2023
@jhansche jhansche closed this Jul 17, 2023
@jhansche jhansche deleted the pr/commands-db branch July 17, 2023 15:01
@jhansche
Copy link
Contributor Author

Super fast as always 👍

@mrlt8
Copy link
Owner

mrlt8 commented Jul 17, 2023

I believe I may have copied over the commands from the older Pan cam when updating the device_config.json file to add support for the newer Pans.

I just had a look at the DeviceConfig.plist file from the iOS app, and it seems like several of the PTZ commands are only listed under WYZECP1_JEF so it seems as if wyze may have stopped updating that list with all the supported commands.

mrlt8 added a commit that referenced this pull request Jul 20, 2023
* cache build

* Catch and disable MQTT on name resolution error

* Doorbell quick response

* Set camera time zone #916

* Set timezone on camera #916

* OSD toggle for logo/timestamp

* Add K10006 auth #742

* Fix /time_zone/get and return offset #916

* convert TZ offset to hours #916

* custom video filter #919

* Resend discovery message on HA online #907 #920

* Revert K10006 for WYZEDB3 #742

* Add more MQTT entities #921 #922

* Return json response/value for commands #835

* Fix threading issue on restart #902

* Fix SET cruise_points over MQTT

* SET cruise_point #835

* split into multiple jobs

* changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants