Help with Rule. Dummy device update

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
makon
New user
Posts: 4
Joined: 04 Sep 2018, 16:08

Help with Rule. Dummy device update

#1 Post by makon » 04 Sep 2018, 16:29

Hello. I have a rule:
on Sensor4#State do
TaskValueSet 5,1,[Sensor1#State]+[Sensor2#State]+[Sensor3#State]+[Sensor4#State]
endon

On MessageSize#Size do
if [MessageSize#Size]=0
gpio,2,1
else
gpio,2,0
endif
endon

And the Dummy device (MessageSize task 5) update interval is 600.

Why does not the second event start immediately when the first event is triggered? This happens only after the expiration of the next interval of 600 seconds.

If at the end of the first event I add the following line: Publish /%sysname%/MessageSize/Size,[MessageSize#Size], the previous value will be sent to the MQTT broker rather than calculated in the first line.

I will try to explain in more detail:
Step 1. MessageSize#Size = 1
Step 2. the value of Sensor4#State changes
Step 3. Running TaskValueSet 5,1,[Sensor1#State]+[Sensor2#State]+[Sensor3#State]+[Sensor4#State] // (MessageSize#Size = 2
Step 4. Running Publish /%sysname%/MessageSize/Size,[MessageSize#Size]
Step 5. the value 1 is sent to the MQTT broker! In this case, the new calculated value 2 will be sent only after the interval of 600 seconds has elapsed

What i am doing wrong?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Help with Rule. Dummy device update

#2 Post by grovkillen » 04 Sep 2018, 17:36

You could trigger the event with the task run command.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

makon
New user
Posts: 4
Joined: 04 Sep 2018, 16:08

Re: Help with Rule. Dummy device update

#3 Post by makon » 04 Sep 2018, 17:55

Thank you.

on Sensor4#State do
//MessageSize#Size = 1
TaskValueSet 5,1,[Sensor1#State]+[Sensor2#State]+[Sensor3#State]+[Sensor4#State] //MessageSize#Size = 2
TaskRun,5
Publish /%sysname%/MessageSize/Size,[MessageSize#Size] //it send 1 to broker!!!
endon

LOG:
ACT : Publish /Entrance/MessageSize/Size,0
26901515: Command: taskvalueset
26901517: Command: taskrun
26901522: Dummy: value 1: 1.00
26901522: Dummy: value 2: 0.00
26901522: Dummy: value 3: 0.00
26901522: Dummy: value 4: 0.00
26901525: EVENT: MessageSize#Size=1.00
26901570: ACT : gpio,2,0
26901572: SW : GPIO 2 Set to 0
26901576: EVENT: MessageSize#=0.00
26901603: EVENT: MessageSize#=0.00
26901629: EVENT: MessageSize#=0.00
26901703: Command: publish

Why it send 1 to MQTT broker???

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Help with Rule. Dummy device update

#4 Post by grovkillen » 04 Sep 2018, 18:19

I think maybe the task run is executed before the task value is set. You should really bump the log level and test it all.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

makon
New user
Posts: 4
Joined: 04 Sep 2018, 16:08

Re: Help with Rule. Dummy device update

#5 Post by makon » 05 Sep 2018, 10:18

I dont understand anything...

Log level INFO:
SW : Switch state 0 Output value 1
142801: EVENT: Sensor1#State=1.00
142833: ACT : TaskValueSet 5,1,1+0+0+0
142847: ACT : TaskRun,5
142875: ACT : Publish /Entrance/MessageSize/Size,0
142954: Command: taskvalueset
142956: Command: taskrun
142960: Dummy: value 1: 1.00
142960: Dummy: value 2: 0.00
142961: Dummy: value 3: 0.00
142961: Dummy: value 4: 0.00
142963: EVENT: MessageSize#Size=1.00
143013: ACT : gpio,2,0
143016: SW : GPIO 2 Set to 0
143021: EVENT: MessageSize#=0.00
143048: EVENT: MessageSize#=0.00
143074: EVENT: MessageSize#=0.00
143141: Command: publish

Log level DEBUG More:
221499: EVENT: MessageSize#Size=1.00
221537: [if 1=0]=false
221540: else = true
221542: ACT : gpio,2,0
221544: SW : GPIO 2 Set to 0
221548: EVENT: MessageSize#Size=1.00 Processing time:49 milliSeconds
221549: EVENT: MessageSize#=0.00
221575: EVENT: MessageSize#=0.00 Processing time:26 milliSeconds
221576: EVENT: MessageSize#=0.00
221604: EVENT: MessageSize#=0.00 Processing time:28 milliSeconds
221605: EVENT: MessageSize#=0.00
221631: EVENT: MessageSize#=0.00 Processing time:26 milliSeconds
221656: MQTT : /Entrance/MessageSize/Size 1
221672: Command: publish

The subscriber gets the value 0!

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Help with Rule. Dummy device update

#6 Post by grovkillen » 05 Sep 2018, 10:28

Must be some bug. Please report your finding to our GitHub issue tracker and also refer to this forum topic.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

makon
New user
Posts: 4
Joined: 04 Sep 2018, 16:08

Re: Help with Rule. Dummy device update

#7 Post by makon » 05 Sep 2018, 11:41


Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests