Best way to handle push buttons

Moderator: leecollings

Post Reply
napo7
Posts: 20
Joined: Monday 06 February 2017 8:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Best way to handle push buttons

Post 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 ?
User avatar
Jimbolaya
Posts: 12
Joined: Thursday 18 February 2016 21:28
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11207
Location: New York, USA
Contact:

Re: Best way to handle push buttons

Post 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
Jim
napo7
Posts: 20
Joined: Monday 06 February 2017 8:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Best way to handle push buttons

Post 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 ?
User avatar
Jimbolaya
Posts: 12
Joined: Thursday 18 February 2016 21:28
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11207
Location: New York, USA
Contact:

Re: Best way to handle push buttons

Post by Jimbolaya »

Sounds like a Domoticz selector type switch will do the trick.

https://forum.mysensors.org/topic/4933/ ... z-tutorial
Jim
napo7
Posts: 20
Joined: Monday 06 February 2017 8:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Best way to handle push buttons

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests