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

add support for pico button events #81

Merged
merged 6 commits into from
Nov 29, 2021

Conversation

johninaustin
Copy link
Contributor

This code adds the ability to subscribe to Pico button events using LEAP.

A ReadRequest to /device will have some Pico devices. Each Pico will have a ButtonGroups tag with a buttongroup href and ID.

A ReadRequest to /button will return a series of Buttons tag linked to the above button group. Each of these is a button on the Pico.

As an example, a Pico device can have buttongroup 2, and that buttongroup can have buttons 103-107.

To subscribe to event notifications, send a SubscribeRequest for each button ID. For 103, for example, you’d send the SubscribeRequest with the URL /button/103/status/event

Whenever you press or release that Pico button, you’ll get a ButtonStatus body with a ButtonEvent, and the EventType of “Press” or “Release”.

This code finds any devices with buttongroups, gets the list of buttons, and subscribes to events from those buttons. Some new objects are added to retrieve buttons, subscribe to events from those buttons, and to handle response messages.

Copy link
Collaborator

@mdonoughe mdonoughe left a comment

Choose a reason for hiding this comment

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

Some minor comments here, and I notice Black complains that a couple lines are too long. The continuous integration service on this repository doesn't seem to be working anymore, but if you can open the code in Visual Studio Code with the development container option and run tox it should give the same results.

Can you update the tests? The existing tests are failing because Bridge._accept_connection in test_smartbridge.py expects a certain sequence of requests. If you update it to expect requests related to buttons and return some basic button information then the existing tests should start passing again. There should be a test that verifies when a button press event is received the event handler gets called.

pylutron_caseta/smartbridge.py Outdated Show resolved Hide resolved
pylutron_caseta/smartbridge.py Outdated Show resolved Hide resolved
pylutron_caseta/smartbridge.py Outdated Show resolved Hide resolved
pylutron_caseta/smartbridge.py Outdated Show resolved Hide resolved
pylutron_caseta/smartbridge.py Outdated Show resolved Hide resolved
johninaustin and others added 3 commits November 28, 2021 09:43
Co-authored-by: Matthew Donoughe <mdonoughe@gmail.com>
Co-authored-by: Matthew Donoughe <mdonoughe@gmail.com>
Co-authored-by: Matthew Donoughe <mdonoughe@gmail.com>
@johninaustin
Copy link
Contributor Author

I'll setup VS Code & run tox / work on the tests.
Thanks for the review

@johninaustin
Copy link
Contributor Author

I've made the requested changes. Can you please review?

Copy link
Collaborator

@mdonoughe mdonoughe left a comment

Choose a reason for hiding this comment

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

LGTM

@mdonoughe mdonoughe merged commit 601aad2 into gurumitts:dev Nov 29, 2021
@bdraco
Copy link
Contributor

bdraco commented Dec 4, 2021

Awesome! As soon as this gets released we can update Home Assistant to support picos without a pro bridge 👍

bdraco added a commit to bdraco/home-assistant that referenced this pull request Dec 5, 2021
- Button presses are now monitored via LEAP

- Telnet support is no longer required and
  lip usage has been removed

- Requires gurumitts/pylutron-caseta#81

- Changelog: gurumitts/pylutron-caseta@v0.11.0...v0.12.0
@bdraco
Copy link
Contributor

bdraco commented Dec 5, 2021

Tested this with home-assistant/core#61032 and it works great

@mdonoughe Would you mind pushing a new release ?

Thanks!

@mdonoughe
Copy link
Collaborator

I was already making the commit. :) https://pypi.org/project/pylutron-caseta/0.12.0/

bdraco added a commit to bdraco/home-assistant that referenced this pull request Dec 5, 2021
- Button presses are now monitored via LEAP

- Telnet support is no longer required and
  lip usage has been removed

- Requires gurumitts/pylutron-caseta#81

- Changelog: gurumitts/pylutron-caseta@v0.11.0...v0.12.0
bdraco added a commit to bdraco/home-assistant that referenced this pull request Dec 6, 2021
- Button presses are now monitored via LEAP

- Telnet support is no longer required and
  lip usage has been removed

- Requires gurumitts/pylutron-caseta#81

- Changelog: gurumitts/pylutron-caseta@v0.11.0...v0.12.0
bdraco added a commit to bdraco/home-assistant that referenced this pull request Dec 19, 2021
- Button presses are now monitored via LEAP

- Telnet support is no longer required and
  lip usage has been removed

- Requires gurumitts/pylutron-caseta#81

- Changelog: gurumitts/pylutron-caseta@v0.11.0...v0.12.0
@swails
Copy link
Contributor

swails commented Feb 6, 2022

Oh super cool. I wonder when they added this feature to the bridge.

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.

4 participants