Open g-kiss opened 4 years ago
Tried this on a Shelly dimmer (first model, firmware 1.8) with a momentary switch, but I get no shelly_click
events in HA when pressing either of the 2 buttons. Anything I can add in the code to make this work?
@gerard33 Yes, RTFM ;-) -> Sensors in https://github.com/StyraHem/ShellyForHASS#sensor-global-and-per-device
Or add
shelly:
sensors:
- all #show all sensors
#or
- switch #show only switch actions
I searched also a lot ;-), happy to help...
@thecem I meant if I can add anything in the .py code as addition to this PR as it doesn't work for Shelly dimmers 😉
My config contains the part you are mentioning
shelly:
sensors:
- switch
The shellyforhass.click
event is showing data for my Shelly dimmer, but always as a single press.
And this PR should make double press etc. possible again.
Oh this would be nice!
Do you receive only the shellyforhass.click
or also the shelly_switch_click
, in HA 0.115.0 I´m not able to search with wildcard like *shelly*
.
So I only receive for shelly 2.5 on double click a message for cnt with shelly_switch_click
and the one shellyforhass.click
I tested it with HA 115.0, Shelly Dimmer and momentary_button: true
in yaml. It works. I get these events:
{
"event_type": "shelly_click",
"data": {
"entity_id": "binary_sensor.lampa_furdoszoba_mennyezet_switch",
"click_count": 0,
"click_events": "S"
},
"origin": "LOCAL",
"time_fired": "2020-09-18T08:51:53.561663+00:00",
"context": {
"id": "330f9255f98c11eab1ac3320c994fda4",
"parent_id": null,
"user_id": null
}
}
{
"event_type": "shelly_click",
"data": {
"entity_id": "binary_sensor.lampa_furdoszoba_mennyezet_switch",
"click_count": 0,
"click_events": "L"
},
"origin": "LOCAL",
"time_fired": "2020-09-18T08:51:52.304406+00:00",
"context": {
"id": "324fbb07f98c11ea8f43cb6a68433bdb",
"parent_id": null,
"user_id": null
}
}
Undocumented feature: momentary_button: true
?
I get also the info without this config in HA 115 but I have exactly to search for shelly_switch_click
and shellyforhass.click
, but not a shelly_click
, maybe there should be a detailed explanation...
@gerard33, @thecem This PR needs the (https://github.com/StyraHem/pyShelly/pull/42) PR too.
Ah that makes sense 👍
@g-kiss
I have added your pyShelly PR and tested it with my Shelly dimmer on fw1.8 and I get the click_count.
I have set the following in configuration_schema.py as I have only momentary switches with the Shelly devices ->
vol.Optional(CONF_MOMENTARY_BUTTON, default=True): cv.boolean
so would have expected the click_events.
But for me this is working fine like this as well. Will do some more testing, but it seems really reliable and get's up to 5-clicks 👍
Below an example for a triple click.
{
"event_type": "shelly_click",
"data": {
"entity_id": "binary_sensor.shelly_kantoor_2_switch",
"click_count": 6,
"click_events": ""
},
"origin": "LOCAL",
"time_fired": "2020-09-18T20:29:23.558574+00:00",
"context": {
"id": "a39a5039f9ed11ea8286f382ca21a762",
"parent_id": null,
"user_id": null
}
}
@gerard33 My yaml is like this:
devices:
- id: "xxxxxxxx"
name: Fürdőszoba mennyezet
entity_id: lampa_furdoszoba_mennyezet
light_switch: true
momentary_button: true
and gives click_events
:
{
"event_type": "shelly_click",
"data": {
"entity_id": "binary_sensor.lampa_furdoszoba_mennyezet_switch",
"click_count": 0,
"click_events": "LS"
},
"origin": "LOCAL",
"time_fired": "2020-09-18T20:56:48.610026+00:00",
"context": {
"id": "782140e9f9f111ea98aa79d2c3fe8fd7",
"parent_id": null,
"user_id": null
}
}
Is it possible to set the variable global in yaml? I have only momentary switches.
@g-kiss
I have added momentary_button: true
for the device I am testing with and then it shows S
etc. indeed.
I didn't have that device_id in the devices:
list and apparently it needs to be in or otherwise it wont get the momentary_button
value, even not if it's set to default = true
(changed that locally).
@gerard33 The button type (momentary or toggle) is the property of device. It must be assigned to device, because for example I have about 10 Shellys with momentary button and about 15 Shellys with toggle button.
Hi, there is any estimation date when it will be merged to the master?
Thanks in advance
@gerard33 My yaml is like this:
devices: - id: "xxxxxxxx" name: Fürdőszoba mennyezet entity_id: lampa_furdoszoba_mennyezet light_switch: true momentary_button: true
and gives
click_events
:{ "event_type": "shelly_click", "data": { "entity_id": "binary_sensor.lampa_furdoszoba_mennyezet_switch", "click_count": 0, "click_events": "LS" }, "origin": "LOCAL", "time_fired": "2020-09-18T20:56:48.610026+00:00", "context": { "id": "782140e9f9f111ea98aa79d2c3fe8fd7", "parent_id": null, "user_id": null } }
Where can I look for the events when they are fired? In some log file?
@jacobhallgren You can see it on "developer tools" / "events" page of HA web interface.
@hakana Please add this to master
are single, long and double clicks already supported? Seeing this now https://github.com/StyraHem/ShellyForHASS#events
@hakana Do you have any plan with this PR?
I have tried this but it is not stable when testing. So I need to investigate more around this.
I have tried this but it is not stable when testing. So I need to investigate more around this.
Works great for me, use it every day for 2 months. No problems.
For what it's worth, it's working fine for me for several months as well. Double and triple clicks for all Shelly devices easily available now.
Hi @hakana, did you had a chance of looking into this a bit more? I would love to use this.
@g-kiss, are you planning on adding this functionality to the Shelly Home Assistant native integration as well? I can imagine more people would really like to use it.
Hi @wauswaus, I will thinking about it
Would be awesome to have this on master!
@g-kiss I would like to be part of the testing...how can I install your change?
Hi @wauswaus, I will thinking about it
What's the outcome? I'm running the native integration nowadays . Would be nice to have your nice work in there as well
Hi @wauswaus, see this PR: https://github.com/home-assistant/core/pull/58436
@g-kiss Have migrated to the native HA integration since a couple of weeks and added your code and that works like a charm! Thanks for sharing it 👍🏻 Hopefully it will be added to the native HA integration or library soon.
Overwiev
I created a new event to handle complex events on fw 1.8.x and above. I tested it on Shelly1, Shelly2.5, Shelly dimmer and Shelly dimmer2. With a new "momentary_button" yaml parameter defines which button is connected to Shelly. If the clicking speed is slow or fast or very fast this event works very well (its accurate is 100%).
These events allows to:
See the examples below.
This PR needs the (StyraHem/pyShelly#42) PR too.
1. Momentary button
1.1 If a momentary button is attached to Shelly, then the
momentary_button
parameter in yaml must be set to true.click_events
contains a complex event, like this:This event will be send after last release of button.
1.2 In case of long push, it also sends another event, when the long push starting (LSTART) or stopping (LSTOP), like this:
"LSTART" and "LSTOP" can be used when the long push is the last action. With "LSTART" event can start executing the action before releasing the long push.
1.3 The time diagram of events
2. Toggle button
If a toggle button is attached to Shelly, then the
momentary_button
parameter in yaml must be false (this is the default) and in shelly settings (web interfacae) thelong push time
must be set to 10 ms. In this case theclick_count
contains number of clicks, like this:3. Examples
3.1 Shelly1 with momentary, detached button:
Toggle ceiling lamp (this is the main function of the button):
Toggle night lamp:
Turn off all lights of room:
Close the shutter:
Open the shutter:
3.2 Shelly dimmmer with momentary, detached button:
Toggle lamp:
Dim up and down:
Dim stop:
Toggle another lamp with the dimmer switch:
3.3 Control Shelly dimmmer with a switch of Shelly1
Toggle lamp of Shelly1 (this is the main function of the button):
Toggle the dimmer's lamp:
Dim up and down:
Dim stop: