If button pressed more than 7 seconds do something else
Moderator: leecollings
If button pressed more than 7 seconds do something else
Hello! I want code the button for doorbell. If I pressed the button for more than 7 seconds the gate will open. And than i pressed the button less than 7 seconds doorbell was ring. Can you help me?
BTW. Sorry for my english 
-
mvzut
- Posts: 443
- Joined: Thursday 12 November 2015 10:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
If button pressed more than 7 seconds do something else
Hi Saffal, welcome to the forum!
This sounds easier than it is. Most (pulse) switches using wireless communication (either Z-wave, 433 MHz ,...) work with single events: if you press them they send a message. They don't send a message when you stop pressing them, at least not for Z-wave or the 433 MHz protocols that I'm aware of. So there's no way to determine how long you pressed them.
The only feasible options I see are:
-Connecting your doorbell switch directly to your Domoticz system (e.g. on a GPIO input assuming it's a Raspberry Pi). You can then create some kind of script that runs in the background, which constantly polls the status, and sends the required commands to Domoticz.
-Programming this functionality into an ESP-8266 (e.g. Nodemcu) connected to your doorbell switch, which then wirelessly sends the required commands to Domoticz via the JSON interface.
Anyhow, I think it's not going to be a plug-and-play solution, unless I'm missing some clever alternative solution myself.
This sounds easier than it is. Most (pulse) switches using wireless communication (either Z-wave, 433 MHz ,...) work with single events: if you press them they send a message. They don't send a message when you stop pressing them, at least not for Z-wave or the 433 MHz protocols that I'm aware of. So there's no way to determine how long you pressed them.
The only feasible options I see are:
-Connecting your doorbell switch directly to your Domoticz system (e.g. on a GPIO input assuming it's a Raspberry Pi). You can then create some kind of script that runs in the background, which constantly polls the status, and sends the required commands to Domoticz.
-Programming this functionality into an ESP-8266 (e.g. Nodemcu) connected to your doorbell switch, which then wirelessly sends the required commands to Domoticz via the JSON interface.
Anyhow, I think it's not going to be a plug-and-play solution, unless I'm missing some clever alternative solution myself.
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: If button pressed more than 7 seconds do something else
If the button is connected as extra input of a Qubino Dimmer, or a Fibaro binary sensor, or... It would stay on as long as the button is pressed.
But then, how to detect that the button is pressed for 2 seconds? Events are triggered upon start of something. Then you should retrieve the history of the switch after 7 seconds to determine if it was continuesly pushed.
Must be possible, but not easy to do.
Also, you want your gate opened like this?
But then, how to detect that the button is pressed for 2 seconds? Events are triggered upon start of something. Then you should retrieve the history of the switch after 7 seconds to determine if it was continuesly pushed.
Must be possible, but not easy to do.
Also, you want your gate opened like this?
-
booster
- Posts: 34
- Joined: Wednesday 10 December 2014 20:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Rijssen, The Netherlands
- Contact:
Re: If button pressed more than 7 seconds do something else
That last part might work with a virtual switch:Egregius wrote:If the button is connected as extra input of a Qubino Dimmer, or a Fibaro binary sensor, or... It would stay on as long as the button is pressed.
But then, how to detect that the button is pressed for 2 seconds? Events are triggered upon start of something. Then you should retrieve the history of the switch after 7 seconds to determine if it was continuesly pushed.
Must be possible, but not easy to do.
Also, you want your gate opened like this?
if doorbell is pressed, switch on virtual switch on for 7 seconds
when virtual switch switches off, and doorbell is on, open your gate.
if doorbell is off, switch virtual switch off
(I know..it only checks of doorbell status is on after precisely 7 seconds, so pressing again exactly after 7 seconds could be considered unwanted;))
Connected to:
-Pi3; Aeon Labs Z-Stick; Fibaro Switches, Roller Shutter and Motion Sensors; Qubino Dimmers; P1 Port + Youless, MiLight; HUE Bridge; Forest shuttle Z-Wave; RFLink + KAKU; Voltcraft CO20; Everspring floodsensors; GreenWave PN-6; NEO Sensors
-Pi3; Aeon Labs Z-Stick; Fibaro Switches, Roller Shutter and Motion Sensors; Qubino Dimmers; P1 Port + Youless, MiLight; HUE Bridge; Forest shuttle Z-Wave; RFLink + KAKU; Voltcraft CO20; Everspring floodsensors; GreenWave PN-6; NEO Sensors
-
mvzut
- Posts: 443
- Joined: Thursday 12 November 2015 10:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: If button pressed more than 7 seconds do something else
Nice idea, although I believe that in the ['Virtual switch '] = "On FOR x" statement in Lua, x is measured in minutes. But I also remember that in ['Virtual switch '] = "Off AFTER x", the x is measured in seconds. So you could build it up from an "On" plus an "Off AFTER 7" command.booster wrote: That last part might work with a virtual switch:
if doorbell is pressed, switch on virtual switch on for 7 seconds
when virtual switch switches off, and doorbell is on, open your gate.
if doorbell is off, switch virtual switch off
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
Who is online
Users browsing this forum: No registered users and 1 guest