gurumitts / pylutron-caseta

Apache License 2.0
153 stars 98 forks source link

Feature Request: Add support for all button events #86

Open nukefrenzy opened 2 years ago

nukefrenzy commented 2 years ago

Pull request #81 added support for Pico button events. This allows Home Assistant to use Pico buttons as triggers, which is great for turning these into general purpose remotes for home automation. I would like to see this same functionality added to hardwired switches/dimmers/fan controls as well. There are many use cases for this. Here are a few examples:

Double-tapping OFF on a switch near a door will turn off all lights inside the house.
Double-tapping ON at the garage entry door will turn on all lights leading into the kitchen.
Tapping ON when a light is already on will turn on the rest of the lights in the area.

Is this info available through the Smart Bridge Pro and able to be added?

thenewwazoo commented 2 years ago

Hi! Friendly developer of homebridge-lutron-caseta-leap here. I'm not actually part of this project, but I obviously take inspiration from it. :)

My feeling about this is slightly complicated. The LEAP protocol has some kind of quasi-support for long press events, because I have been able to induce the hub to emit the following message:

{"MessageBodyType":"OneButtonStatusEvent","StatusCode":"200 OK","Url":"/button/105/status/event","ClientTag":"135b371c-072d-4f10-90c4-1632690bf13e"},"Body":{"ButtonStatus":{"Button":{"href":"/button/105"},"ButtonEvent":{"EventType":"LongHold"}}}}

Buuuuuuut. That was caused by a short tap of the up/down buttons in the Lutron iOS app. I cannot induce that message with a physical remote by holding the button down, and I cannot find any evidence of LongHold in any published LEAP library. I also cannot find any evidence of LEAP-native support for multi-press events.

So, LEAP might support long presses, and probably doesn't support multi-press events. That means any other press logic would need to be done on the library side. I personally feel (and I'm not a maintainer here) that this is better handled at the point at which the raw messages are interpreted by the automation system.

nukefrenzy commented 2 years ago

For home assistant, I already have double-press events working using automations, but that's only for Pico Remotes. Long press should be possible too by timing the delay between press and release.

However, this feature request is asking for the hardwired switches to have their press and release events passed to home assistant. Right now there is no way to add them as an automation trigger.

As a developer of a similar project, is this info sent in a similar way as the pico remotes?

thenewwazoo commented 2 years ago

Ohhhh, I see! Sorry, I was confused, and now I feel kinda dumb. :D

I'm not aware of a way to expose button press events for non-Pico devices, as they don't have an associated button group.

seanbeach commented 1 year ago

Stumbled onto this 10 month old thread after switching from Hubitat to HomeAssistant, as I had the same behavior @nukefrenzy is mentioning back in Hubitat and most of my wife approved automations are now broken.

There is certainly some exposure of button events on switches as Hubitat supports it via their telnet integration.

vincegre commented 1 year ago

Stumbled onto this 10 month old thread after switching from Hubitat to HomeAssistant, as I had the same behavior @nukefrenzy is mentioning back in Hubitat and most of my wife approved automations are now broken.

There is certainly some exposure of button events on switches as Hubitat supports it via their telnet integration.

If you just need to know when a scene is active, you can do it through state of keyboard led ;)

seanbeach commented 1 year ago

If you just need to know when a scene is active, you can do it through state of keyboard led ;)

Both the OP and I were using the button press events on switches (not scene controllers) to change behavior based on the state of the connected load:

Unfortunately watching for indicator led states or load changes doesn't help us as those states don't change on redundant presses.

After poking through this repo it seems to be a LEAP vs Telnet integration difference, but I'm not around my site to experiment for a while.

jerrm commented 1 year ago

I'd also love to see this if there is any way possible.

I have a couple of switches mounted up in the light fixture with Picos on the wall just to have this kind of functionality.

danaues commented 1 year ago

Hey Guys,

It would be great to have. I'd love it too, but the LEAP interface simply doesn't expose any (button) events from the Switches and Dimmers. Only from the Keypads and Picos.

It's possible that there is some undiscovered subscription within the api, but at this time there is no way to implement. Lutron does not provide us any api documentation unfortunately.

nukefrenzy commented 1 year ago

Out of curiosity, why is LEAP used instead of telnet if telnet has more functionality? Is it to cover the most devices because some don't support telnet anymore? I wonder why Hubitat uses telnet then? Just thinking out loud here, this functionality would be next level for my home setup.

danaues commented 1 year ago

Telnet is no longer supported on any of the new lutron products. Specifically RadioRA3 and Homeworks QSX, RA2 Select.
But this library is for LEAP support. There are other libraries that use telnet to interface with the older lutron bridges.

nukefrenzy commented 1 year ago

So technically we would tie another library into the HA Integration and provide support for both? I realize I'm asking a lot here since I do not know Python, but wondering what is possible.

Added a WTH to the HA forums here just to see interest on this: https://community.home-assistant.io/t/wth-cant-the-lutron-caseta-integration-detect-button-presses-on-all-switches/480944

vincegre commented 1 year ago

Unfortunately watching for indicator led states or load changes doesn't help us as those states don't change on redundant presses.

If your LED is coded in Lutron HWKS software as linked at a scene it'll mimic state of scene recalled on button ;)

califa commented 1 year ago

Has anyone figured this out since this conversation?

carrel-gr commented 1 year ago

This would be really nice! I've always thought that Lutron should implement this natively (using their hub and app). But if HA can do it, that would be even more useful. Being able to use button presses on Caseta switches as triggers, would really be great. Can telnet and LEAP both coexist?

Of course, one does then have to consider security. Telnet is the definition of insecure. How does this telnet interface work? is it read-only?

FlyingDiver commented 10 months ago

Can telnet and LEAP both coexist?

Only on devices which support both. Which is limited to Caseta (with Smart Bridge Pro) and RRa2 Select, as far as I know. Not RRa2 or RRa3 or Homeworks.

vincegre commented 10 months ago

Not RRa2 or RRa3 or Homeworks.

Yeah no more possible on recent generations of Homeworks processors unhappy :(only leap

jhemak commented 8 months ago

+1 for this capability

Entropy512 commented 3 months ago

However, this feature request is asking for the hardwired switches to have their press and release events passed to home assistant. Right now there is no way to add them as an automation trigger.

As a developer of a similar project, is this info sent in a similar way as the pico remotes?

At least for a PD-3PCL lamp unit, this information would not be available because the lamp unit simply does not send button presses over the air. Instead, the unit broadcasts its ending state when the button is released.

https://github.com/Entropy512/lutron_hacks/blob/main/CC1101_captures/lampunit_buttons.txt

Lamp units do not respond with status after receiving a Pico command, at least not with direct pairing. It looks like I may have to give in and buy a bridge to continue my project, I guess I can just sell the thing once my project is complete. At least (it was a pleasant surprise) it looks like non-Pro bridges can be used with HA, I previously thought local control required telnet and hence was exclusive to the Pros but I guess I was wwrong.