Hi everyone!
Almost a brand new user of HA here and I’ve absolutely loved setting my home up the past week.
I use a Raspberry Pi 3B booting from an external SSD together with a bluetooth adapter, an Aoetec Z-stick Gen5+, a Conbee II. So far I have about 7 different environment sensors, a few smart plugs and a very low number of Flair ViYu RGB LED lamps. All devices are running zigbee and the majority of the equipment I have is Aqara used via the deCONZ-addon. Everything has been working really good so far and I’ve had zero hardware issues or problems connecting new stuff. All devices has been added through the Phoscon web-gui and I’ve just started deCONZ to look at it but haven’t touched a thing there.
But, what I’m trying to accomplish is controlling a RGB-LED via a 2-button rocker Aqara switch (model:.WXKG02LM) in the following way
Short press Left button = on
Short press Right button = off
Long press Left button = start slow (30s) transition from current state to 1% brightness (dim down) (done via brightness_pct and transition)
Long press Right button = start slow (30s) transition from current state to 95% brightness (“dim up”)
So far so good, that’s working a-ok already.
What I do want to implement is that after doing a long press on either button I want to be able to short press either button to stop the dimming no matter if it’s getting brighter or darker and here is where I seem to have gotten completely stuck.
My idea was to try to read from the system when the last long press was made on a certain switch and if that was less than, let’s say, 5 seconds when doing the next short press then the brightness transition would halt.
I found quite a bit of information of that “deconz_event” should provide that info. After going into the DevTools in HA and setting up a listener for the same and I instantly saw the reported info when pressing the button and I was pleased to see the following:
Event 28 fired 7:09 AM:
{
"event_type": "deconz_event",
"data": {
"id": "living_room_switch",
"unique_id": "00:15:8d:00:02:83:dd:6b",
"event": 2002,
"device_id": "5f2374ebe26a47e9f2d8881331d163db"
},
"origin": "LOCAL",
"time_fired": "2021-02-20T06:09:53.937958+00:00",
"context": {
"id": "d4c610fdea1b537a971ec6a2981b6e09",
"parent_id": null,
"user_id": null
}
}
After many hours of trying and testing and googling, I realize I have no idea how to via a template grab “time_fired” and use that in the templates’ condition. Everything I’ve tried just reports “None” or “unknown” and after about 6 hours straight I’d thought I come here to ask people with more experience
I’ve tried so many iterations I’m just assuming it’s gotten worse and worse after each try, but what I was hoping to do is something similar to this as a secondary condition on the automation along with a simple check if the light is turned on as the first condition:
condition: template
value_template: >
{{ as_timestamp(now()) -
as_timestamp(state_attr('deconz_event.living_room_switch', 'time_fired')) |
int(0) > 5 }}
I can’t take any credit for this attempt, it’s mostly bits and pieces from other threads here on the forums. Even if I roughly understand what it’s supposed to be doing I’m quite unsure on the syntax and primarily where to collect the state from if that’s even the correct way of doing it.
Am I going about this all wrong? Am I close and just need a nudge in the right direction?
Any help would be appreciated and I hope my first post is informative enough. I think I covered most things but if I can provide more info to make it easier to help, please let me know.
Thanks!