python-ring-doorbell
python-ring-doorbell copied to clipboard
How to toggle light?
Hi, I am trying to control the light of a Ring Spotlight Cam Pro. I have created the group using the Ring app and I can see the group with ring-doorbell.
`root@er:/home/pi/ring# ring-doorbell groups
Ring CLI (Pretty format coming soon, if you want json consistently from this command provide the --json flag) "57d6f08a-070f-4af3-a5e7-207b1113c9c2" `
Now I'm lost: how do I toggle the light status? I can't find a cli command so I tried creating a script using the example in the docs, but I get errors...
Any hint please?
Thanks Riccardo
Hi, this is the script I tried to do
'#!/usr/bin/python
-- coding: utf-8 --
import re import sys
from ring_doorbell import AuthenticationError, Requires2FAError, Ring, Auth from ring_doorbell.cli import ( cli, devices_command, list_command, listen, groups, motion_detection, show, videos, )
def main():
ring = Ring(auth)
groups = Ring.groups()
group = groups['my_group_as_taken_from_cli']
print(group.lights)
Prints True if lights are on, False if off
Turn on lights indefinitely
group.lights = True
Turn off lights
#group.lights = False
Turn on lights for 30 seconds
#group.lights = (True, 30)
if name == "main": main() '
but I still get error
./lighton.py Traceback (most recent call last): File "/home/pi/ring/./lighton.py", line 39, in <module> main() File "/home/pi/ring/./lighton.py", line 22, in main groups = Ring.groups() TypeError: groups() missing 1 required positional argument: 'self'
Any hint of what I should fix?
Thanks! Riccardo
Hi Riccardo, the cli doesn't currently support changing the states, just returning information. The best way to do what you want to do would be to fork the repository and submit a PR with the change you want. I'd suggest adding two options to the groups command in cli.py
, --group-name
and --toggle-lights
. If group-name is supplied get your group with ring.groups_data[group_name]
and then if toggle-lights is supplied then set .lights
to the opposite of what it currently is.
Hi, I did create a fork but then when I go to PullRequest it doesn't let me create a new one... sorry I'm not familiar with this process. Can you please let me know how I should do this?
Thanks R
You create a PR by using git to push changes to a branch in your fork. Once your fork has new commits pushed it to then GitHub will show you an option to create a pull request.
There hasn't been any activity on this issue recently. This issue has been automatically marked as stale because of that. It will be closed if no further activity occurs. Please make sure to update to the latest ring_doorbell version and check if that solves the issue. Thank you for your contributions.