howto program this logic ?

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
Thomas
Posts: 7
Joined: 25 Oct 2017 12:06

howto program this logic ?

Post by Thomas » 04 Oct 2018 21:22

Hello i have a raspberry 3 with the razberry 2 and a number of sensors, and it is all working well, but i have a problem programming for a special event.
Now the problem i have - it is simple logic, and i am not a programmer :-) .. but i can do some scrips if necessary.

I need a switch to turn on once for 5 seconds if a binary sensor goes on.
The "if then" can only turn on the switch, but not limit it to 5 seconds. I tried to look at several apps, but did not find any to do the trick.
The elaborate description :-) is that i have a ventilator in the toilet window, that i want to turn on every time the toilet door opens. The ventilator is working now with a string to pull, and has an adjustable timer set to 5 minutes.
So i need the event from the door sensor to switch on the switch in the fan as if someone pulled the string :-) The fan "likes" the string to stay pulled for about 5 seconds before starting the fan. You could argue i should have put a presence detector instead, but i do not like the idea of sensors in the toilet room :-)


My environment - i took the beta
Firmware version v3.0.0-rc16
to resolve a problem where 237 were crashing, and indeed v3 is not crashing.
Running on raspberry3, raspbian stretch with razberry 2

Eagle
Posts: 67
Joined: 18 Jun 2017 19:04

Re: howto program this logic ?

Post by Eagle » 05 Oct 2018 15:40

Hi Thomas,
1)open the app "automated switch off" and set your switch as device and the desired 5 seconds as timeout.
Now everytime you switch on your device, it will be switched off after 5 seconds. If you sometimes need the switch to stay longer than 5 seconds activated, create a dummy device and link it to your real switch (if dummy device on then switch on, if dummy device off then switch off). In this case, you need to use your dummy device in automated switch off. So your able to activate it long (when switching on the real device) and also your able to activate it with a 5 second timeout (when switching the dummy device)
If someday you need a longer timeout than a minute, for whatever reason, try the "automated late switch off" app. it uses cron

2) If you link that to your binary sensor, you will encouter that the device will switch on again every time it switches off while your binary sensor is on. Thats not what you want.
You got 2 options to solve this:
First of all create a scene and call it triggerToilet or something like that. Then create an if then or logical rule app and set: if binary sensor on then scene triggerToilet on. Then create another logical rule and set: if binary sensor on then device (your automatically of-switching fan-switch) on. while in the logical rule app scroll down an check advanced settings, uncheck "Check the rule for every change of state of a device listed under 'Conditions'" and add your triggerToilet scene to "Trigger the rule check on activation of the following scenes". Thats it!

Your other option is to use some of maros brilliant apps. Download condition switch and event watcher.
Open Condition switch and add a binary condition (your binary sensor on). Under switch you need your Switch Type set to Event, for your start event type something like triggerToilet and save the app. Now open Event watcher, add a Trigger event and type in the name of your start event (eg triggerToilet). Then add under actions, switch devices your automatically off-switching device. => Your done

Thomas
Posts: 7
Joined: 25 Oct 2017 12:06

Re: howto program this logic ?

Post by Thomas » 05 Oct 2018 23:01

wow thanks for the detailed answer, - i will try it out this weekend.

Thomas
Posts: 7
Joined: 25 Oct 2017 12:06

Re: howto program this logic ?

Post by Thomas » 06 Oct 2018 21:23

Well it was less complicated. Only the "automates switch off" did it in a normal "if then" app. But it took me a while to realize since i kept looking for the app "automated switch off" in the "if then" or "logical rule", when i simply still had to enter the usual switch. In the mean time i went through all your suggestions, and learned a lot - thank you :-) Working now. Apparently the if sensor on, only reacts, in the moment it turns on, though it stays on in the control center. So i only get 5 seconds "pull in the string", even if i leave the door open. All is good :-)

Eagle
Posts: 67
Joined: 18 Jun 2017 19:04

Re: howto program this logic ?

Post by Eagle » 06 Oct 2018 22:20

Im glad youre automation is working!
Yeah youre right, there is no trigger needed, as the if then, or logical rule app only check on condition changes and youre only condition is your binary sensor. I forgot that!

But maybe youll need that in your next, more complex automation! :D

Post Reply