Add in-home chime support to CLI by briangoldstein · Pull Request #427 · python-ring-doorbell/python-ring-doorbell · GitHub
Skip to content

Add in-home chime support to CLI#427

Merged
sdb9696 merged 9 commits intopython-ring-doorbell:masterfrom
briangoldstein:cli-existing-doorbell
Sep 19, 2024
Merged

Add in-home chime support to CLI#427
sdb9696 merged 9 commits intopython-ring-doorbell:masterfrom
briangoldstein:cli-existing-doorbell

Conversation

@briangoldstein
Copy link
Copy Markdown
Contributor

Added a command in-home-chime which supports viewing the current in-home chime settings for a device as well as changing any of the available settings using multiple arguments.

Sample output of ring-doorbell in-home-chime --device-name "Front Door"

Name: Front Door
ID: 987652
Type: Digital
Enabled: True
Duration: 5

Output of ring-doorbell in-home-chime --help

Usage: ring-doorbell in-home-chime [OPTIONS]

View and manage the Doorbell in-home chime. To see the current in-home chime
status of a device, only pass the device name.

Options:
-dn, --device-name TEXT Name of the ring device [required]
-t, --type [Mechanical|Digital|Not Present] Set the in-home chime type.
-e, --enabled [True|False] Enable or disable the in-home chime.
-d, --duration [0|1|2|3|4|5|6|7|8|9|10] Set the in-home chime duration, in seconds.
--help Show this message and exit.

@coveralls
Copy link
Copy Markdown

coveralls commented Sep 3, 2024

Copy link
Copy Markdown
Member

@sdb9696 sdb9696 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great PR, thanks for the effort!

I would suggest that this would be better implemented as a group of related commands rather than options (also using the click.BOOL and click.IntRange types as per the comments. This way the cli would look like:

ring-doorbell --device "Front Door" in-home-chime show # Shows all the settings
ring-doorbell --device "Front Door" in-home-chime # Defaults to show the settings
ring-doorbell --device "Front Door" in-home-chime enabled # Shows the enable state
ring-doorbell --device "Front Door" in-home-chime enabled y # Enables/Disables (from the docs: The string values “1”, “true”, “t”, “yes”, “y”, and “on” convert to True. “0”, “false”, “f”, “no”, “n”, and “off” convert to False.)
ring-doorbell --device "Front Door" in-home-chime duration # Shows the duration
ring-doorbell --device "Front Door" in-home-chime duration 5 # Sets the duration
ring-doorbell --device "Front Door" in-home-chime type # Shows the type
ring-doorbell --device "Front Door" in-home-chime duration Mechanical # Sets the type

You can set the device on the context in the main group command and pass_dev to the sub commands.

Comment thread ring_doorbell/cli.py Outdated
Comment thread ring_doorbell/cli.py Outdated
Comment thread ring_doorbell/cli.py Outdated
Comment thread ring_doorbell/cli.py Outdated
Comment thread ring_doorbell/cli.py Outdated
@sdb9696
Copy link
Copy Markdown
Member

sdb9696 commented Sep 5, 2024

Hey just a heads up that I’ve converted the project to use uv instead of poetry. If you merge with master you’ll need to pipx install uv and run things with uv run instead of poetry run but other that shouldn’t be much impact.

@briangoldstein
Copy link
Copy Markdown
Contributor Author

@sdb9696 thank you! My concern with moving them from options to arguments is that it causes the help output to not be as helpful. Great call on moving duration to inter. However for enabled, I like keeping it locked to a True/False choice type so that it also displays in the help.

Help w/ options:
Screenshot 2024-09-08 at 12 18 32 PM

Help w/ arguments:
Screenshot 2024-09-08 at 12 16 47 PM

@sdb9696
Copy link
Copy Markdown
Member

sdb9696 commented Sep 12, 2024

@sdb9696 thank you! My concern with moving them from options to arguments is that it causes the help output to not be as helpful. Great call on moving duration to inter. However for enabled, I like keeping it locked to a True/False choice type so that it also displays in the help.

Hey @briangoldstein, apologies for the delay in coming back to you. I've pushed a commit to your branch that hopefully explains what I'm trying to achieve. Essentially I'd like to keep the use of options as light as possible and stick to arguments for the most important part of a command. The help can go in the docstring and I think it looks ok.

Some of the other commands like motion_detection aren't currently doing this but they will be moved over eventually.

The downside is you can't set multiple in-home-chime settings in one go but I think that's ok.

There's also some other clean up in there, let me know your thoughts.

@sdb9696
Copy link
Copy Markdown
Member

sdb9696 commented Sep 18, 2024

@sdb9696 sdb9696 merged commit 22d6e68 into python-ring-doorbell:master Sep 19, 2024
sdb9696 pushed a commit that referenced this pull request Sep 19, 2024
@sdb9696 sdb9696 added this to the 0.9.5 milestone Sep 19, 2024
@sdb9696 sdb9696 mentioned this pull request Sep 19, 2024
sdb9696 added a commit that referenced this pull request Sep 19, 2024
## [0.9.5](https://github.com/python-ring-doorbell/python-ring-doorbell/tree/0.9.5) (2024-09-19)

[Full Changelog](0.9.4...0.9.5)

**Release highlights:**

- New CLI commands
- Enhancement to the experimental WebRTC stream feature

**Implemented enhancements:**

- Enable multiple webrtc sessions per device [\#440](#440) (@sdb9696)
- Add cli command to open door on intercom [\#438](#438) (@sdb9696)
- Add in-home chime support to CLI [\#427](#427) (@briangoldstein)

**Fixed bugs:**

- Fix max. volume of Ring Chime device. [\#439](#439) (@daniel-k)
- Fix cli listen command on windows [\#437](#437) (@sdb9696)

**Project maintenance:**

- Fix testpypi publish workflow to skip duplicates [\#441](#441) (@sdb9696)
- Tweak the CI to use variables for project names [\#435](#435) (@sdb9696)
- Fix publish workflow action [\#434](#434) (@sdb9696)
- Upgrade artifact upload/download github actions [\#433](#433) (@sdb9696)

**Closed issues:**

- pyproject include = \["LICENSE", "CONTRIBUTING.rst"...\] [\#324](#324)
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants