Page 1 of 1

Best way to handle push buttons

Posted: Wednesday 08 February 2017 11:07
by napo7
Hi !

I'm planning to drive lights with my MySensors devices :

I have a Mysensors device with 8 light outputs,
and I have a Mysensors device with 8 push button inputs.

I'm used to have 3 functions on the same button with my previous home automation system :
I have the "short press" event, "long press begining" event, and the "long press release" event.
Using these events, I usually set different actions on short press events and on long press begin events.
This allows me , i.e., to drive 2 differents lights with the same button, or to set a dim level with a long press, and an ON/OFF command on a short press.

What would be the best way to handle those kind of events in Domoticz ? How should I define my Mysensors devices to return the short press/long press/release events , that can be handled by domoticz ?

By the way, how can a short press toggle a light in domoticz ?

Re: Best way to handle push buttons

Posted: Wednesday 08 February 2017 23:18
by Jimbolaya
Have the arduino handle the short and long button press decoding. Take a look here:
https://forum.mysensors.org/topic/2001/ ... with-video

Re: Best way to handle push buttons

Posted: Thursday 09 February 2017 15:11
by napo7
Hi,

I saw this post, and already can manage the arduino to get and send 3 states to mysensors (PULSE, HOLD, RELEASE).

My main concern is "how to handle those events in domoticz" :

For a small example, with my custom-made home automation system, I actually have the following script :
IF button_state="PULSE" THEN
Toggle_light("Bedroom")
END IF

IF button_state="HOLD" THEN
Increment_Dimmer("Bedroom")
END IF

Or something similar.

I suppose I'll have to do something like this with lua in domoticz : an event on "state" change ?

Re: Best way to handle push buttons

Posted: Friday 10 February 2017 22:26
by Jimbolaya
Sounds like a Domoticz selector type switch will do the trick.

https://forum.mysensors.org/topic/4933/ ... z-tutorial

Re: Best way to handle push buttons

Posted: Monday 20 March 2017 16:32
by napo7
I completely changed my way of doing things :
Instead of coding (most) simple actions in domoticz, each button node is setup to send an "action" command to its assigned light.

Only advanced actions are passed to domoticz for event scripts.