Events: How to do something AFTER something

Moderator: leecollings

Post Reply
JarekP
Posts: 15
Joined: Monday 16 May 2016 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Events: How to do something AFTER something

Post by JarekP »

Hello,

I'm a newbie in Domoticz and trying to do automatic watering for my garden. Generally it works already, but I have some ideas how to do it better and can't implement it. Maybe you can help :)

1) I have two sections of watering. First section is started after filling some conditions at sunrise:

Image

conditions are set for tests, also time of watering =5min doesn't make a sense, it is for tests only, but doesn't matter. I'd like to add enabling of second section AFTER first will finish (they can't be opened in parallel at the same time). How to do that?

2) with this puzzle I can set time = sunrise/sunset or time = fixed hour. How to set a time = sunrise+30min?

3) and additional question, maybe it is possible to do not by "events", but other way: for safety purpose I'd like to add kind of supervision about watering, something able to control, how long valve is open (or how long water is flow - I'm planning to add flow sensor). If it takes too long -> alarm "overflow" will be generated, valves will be off, etc. How to do it?
Last edited by JarekP on Tuesday 17 May 2016 14:40, edited 1 time in total.
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Events: How to do something AFTER something

Post by StanHD »

2. How about use a Dummy Switch as a timer. Set the "Timers" entry to:-

Type:- "After Sunrise"
Time:- "00:10" (Or whatever delay you want)

Then use this switch in Blockly "If Timer Switch = On" Statement.

To set off a second process after the first then use the set after block ?
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
JarekP
Posts: 15
Joined: Monday 16 May 2016 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Events: How to do something AFTER something

Post by JarekP »

Using dummy switch as a timer - great, thanks :)

Second process after first - do you mean something just as writing to log in my example? If yes - I also expected it, but with this log I see that this second process is run immediately, not after finishing this set time (5min). In my log I have my message stored with time=sunrise, not 5 min later.
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Events: How to do something AFTER something

Post by StanHD »

You could create a User Variable - Type Integer, and do something like this?

Image
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
JarekP
Posts: 15
Joined: Monday 16 May 2016 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Events: How to do something AFTER something

Post by JarekP »

ok, it looks real, thanks for help!
JarekP
Posts: 15
Joined: Monday 16 May 2016 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Events: How to do something AFTER something

Post by JarekP »

Something is wrong. Or it is not as easy as we think :)
First I built something similar to your suggestion:
Domoticz_-_Google_Chrome_2016-05-18_14-16-10.png
Domoticz_-_Google_Chrome_2016-05-18_14-16-10.png (65.88 KiB) Viewed 4195 times
First section is enabling on fixed time (for tests, after I will put "sunrise" here), with some other conditions. Second section is enabling with less conditions.
Results: first section ("prawa strona") was enabled on time, after 5 min variable "kontrolka procesu" was set to 1 and... nothing else. Second section not started, also in log there was nothing from this part of procedure, variable was still =1, also longer time than 5 min after finishing.

So I tried to do it with different method: by dividing it to two sepparate events. First, only for section "Prawa":
Domoticz_-_Google_Chrome_2016-05-18_14-17-23.png
Domoticz_-_Google_Chrome_2016-05-18_14-17-23.png (34.39 KiB) Viewed 4195 times
And it working fine and set variable to 1 at the end. So I though that only as I need is to detect this state by separate event:
Domoticz_-_Google_Chrome_2016-05-18_14-17-34.png
Domoticz_-_Google_Chrome_2016-05-18_14-17-34.png (25.68 KiB) Viewed 4195 times
But it doesn't work. After finishing of first section variable is set to 1 but this second event doesn't react for it, also in log I have only info from first event and nothing from this second one. Of course this event is active, switch "podlewanie automatyczne" is set to on all the time.
JarekP
Posts: 15
Joined: Monday 16 May 2016 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Events: How to do something AFTER something

Post by JarekP »

As an update: I made this second event more simple by deleting condition with switch "podlewanie automatyczne", now it is only "if variable = 1 then do...". And I noticed that this event is working fine when I'm manually changing value of my variable. When this value is set by other event - nothing happens.
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Events: How to do something AFTER something

Post by StanHD »

It looks as though you may be using an earlier version of Domoticz / Blockly? I am on V3.5097.
As long as the variable is an integer and the events are both enabled I can't think what else is wrong. :(
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
JarekP
Posts: 15
Joined: Monday 16 May 2016 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Events: How to do something AFTER something

Post by JarekP »

V3.5097 ??
I have 3.4834, according to this forum it is the last stable version. Are you using beta?
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Events: How to do something AFTER something

Post by StanHD »

JarekP wrote:V3.5097 ??
I have 3.4834, according to this forum it is the last stable version. Are you using beta?
Yes :)
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
JarekP
Posts: 15
Joined: Monday 16 May 2016 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Events: How to do something AFTER something

Post by JarekP »

Unfortunately, upgrade (now I have 3.5143) also didn't help. My variable is of course integer, both events are active, first is set as "all", second I tried configured as "all" or as "UserVariable", also I tried to delete event and configure again from the beginning, behavior is still the same: first event is working fine and sets variable to 1, but second event doesn't react for it. The same event is working fine when I manually set variable to 1, so generally it works, only can't react for variables changed by other events, I think :(
JarekP
Posts: 15
Joined: Monday 16 May 2016 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Events: How to do something AFTER something

Post by JarekP »

I tried to test only reaction for variables, made a simplest test. Two events:

Master:
Domoticz_-_Google_Chrome_2016-05-20_09-36-57.png
Domoticz_-_Google_Chrome_2016-05-20_09-36-57.png (17.94 KiB) Viewed 4092 times
and slave:
Domoticz_-_Google_Chrome_2016-05-20_09-37-27.png
Domoticz_-_Google_Chrome_2016-05-20_09-37-27.png (23.68 KiB) Viewed 4092 times
and it doesn't work also. On time event "master" is changing variable to 1, but "slave" doesn't react for it. However, when I manually set variable to 1, "slave" is working.Could you (or somebody) test it?
JarekP
Posts: 15
Joined: Monday 16 May 2016 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Events: How to do something AFTER something

Post by JarekP »

Problem solved. I used dummy switch instead of variable and now it is working. For me it is ok, but something has to be wrong with using variables, it should work also.
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Events: How to do something AFTER something

Post by StanHD »

Glad you got it going, sorry I couldn't help more.
Have a look at this thread it seems related:- viewtopic.php?f=15&t=5488

Also, this works perfectly using a variable:-

Image
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: Events: How to do something AFTER something

Post by woody4165 »

Hi

I have something similar to do, related to an irrigation system with four zones.
I need that the four zones activates ione after the other with a timing (something around 10 minutes) that can be variable, based on schedules.
I'm trying to understand how to activate one after the other with uservariables or switch, but everytime I start thinking something wrong appears.
Do you have any suggestions?

In the mean time, I have created four uservariables where I can put the irrigation minutes for each zone.
Then I have created an uservarialble (it can be also a switch) that tells me if this is an irrigation for all the zones or a single zone irrigation.
But then, I get confused on how to manage.
I need some help,please

Thanks
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Events: How to do something AFTER something

Post by StanHD »

Something like this might work:-

Make the following switches:- Start, Z1, Z2, Z3, Z4
Make an Integer Variable:- VZ (set to initial value of 0)

Blockly (just for 2 Zones, but you get the gist):-

If Start = On And VZ=0
Set Z1 = On
Set VZ = 1 After 600 Seconds

Else If Start = On And VZ = 1
Set Z1 = Off
Set Z2 = On
Set VZ = 2 After 600 Seconds

Else If Start = On And VZ = 2
Set Z2 = Off
Set Start = Off
Set VZ = 0

Probably needs a bit more refinement and maybe a Selector Switch would be a nicer presentation.
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: Events: How to do something AFTER something

Post by woody4165 »

After a lot of testing with devicechanged and uservariablechanged, reading wiki, it cannot be checked in the same script (inside Domoticz) a device and an uservariable if one or both of them change.

So I went, as your suggestion, for a Selector Switch and in this way all is working fine.

Thanks!!
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest