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

Webcam: Added a uuid/id to the webcams to make it easier to use the API #714

Closed
wants to merge 1 commit into from

Conversation

Clon1998
Copy link
Contributor

@Clon1998 Clon1998 commented Sep 21, 2023

Hey, in #713, I suggested that we should use ID/UUID when addressing webcams instead of their names. I went ahead and implemented that. The implementation also still supports the addressing of webcams via names rather than the id.

I tested everything and updated the docs, so let me know if you spot any issues I missed. 🚀

Signed-off-by: Patrick Schmidt [email protected]

@Arksine
Copy link
Owner

Arksine commented Sep 22, 2023

Thanks. I recall this discussion and did look into it, concluding that exposing the UUID is not the best approach at this time. I looked into an implementation similar to yours, however there are challenges in doing so:

  1. Changing the self.webcams dict to key off of the ID instead of the name will break other components that depend on the webcam component. Specifically the simplyprint component in Moonraker depends on webcam. Additionally I think timelapse does externally. It isnt worth the refactor in these components to make this change.

  2. The changes as implemented would allow for webcams with duplicate names. This could result in unexpected behavior when attempting to lookup a webcam by name. Webcam names must be unique as it isn't feasible to configure a UUID for webcams added to moonraker.conf.

  3. The UUID was kept for compatibility with legacy frontends. It was the best option for Mainsail to reliably generate unique keys, however a UUID is not the best option when ID assignment can be managed by Moonraker. That said, I'm not sure we should risk breaking legacy clients at this time to change it.

IIRC the primary issue was renaming a webcam, as it requires two API calls. I have a local branch that has resolved that particular problem, I haven't gotten around to fully testing it but I'll try to do so asap.

@Clon1998
Copy link
Contributor Author

Thanks. I recall this discussion and did look into it, concluding that exposing the UUID is not the best approach at this time. I looked into an implementation similar to yours, however there are challenges in doing so:

  1. Changing the self.webcams dict to key off of the ID instead of the name will break other components that depend on the webcam component. Specifically the simplyprint component in Moonraker depends on webcam. Additionally I think timelapse does externally. It isnt worth the refactor in these components to make this change.

  2. The changes as implemented would allow for webcams with duplicate names. This could result in unexpected behavior when attempting to lookup a webcam by name. Webcam names must be unique as it isn't feasible to configure a UUID for webcams added to moonraker.conf.

  3. The UUID was kept for compatibility with legacy frontends. It was the best option for Mainsail to reliably generate unique keys, however a UUID is not the best option when ID assignment can be managed by Moonraker. That said, I'm not sure we should risk breaking legacy clients at this time to change it.

IIRC the primary issue was renaming a webcam, as it requires two API calls. I have a local branch that has resolved that particular problem, I haven't gotten around to fully testing it but I'll try to do so asap.

Sure! I was unaware about the dependencies.

@Arksine
Copy link
Owner

Arksine commented Oct 5, 2023

After some further thought and review I came up with a solution to add uid support without breaking local components. I chose uid over uuid as I wanted the parameter/field to be more generic in the event that I want to move away from uuids in the future.

The change was made in commit a232260. Feel free to give it a try and let me know if there are any issues or regressions. Thanks.

@Arksine Arksine closed this Oct 5, 2023
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