Rules MQTT

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Barb232
Normal user
Posts: 40
Joined: 12 Mar 2016, 16:40
Location: Earth
Contact:

Rules MQTT

#1 Post by Barb232 » 11 Apr 2018, 14:02

I have a problem to send the IP from the following example

Code: Select all

On System#Boot do    //When the ESP boots, do
 Publish %sysname%/co2Sensor/IP,%ip%
endon

On Rules#Timer=1 do  //When Timer1 expires, do
 Publish %sysname%/co2Sensor/IP,%ip%
  timerSet,1,30       //Resets the Timer 1 for another 30 seconds
endon
Log

Code: Select all

4632 : EVENT: WiFi#ChangedAccesspoint
6338 : WIFI : DHCP IP: 192.168.178.52 (co2Sensor-18) GW: 192.168.178.1 SN: 255.255.255.0 duration: 1707 ms
6338 : EVENT: WiFi#Connected
6438 : MQTT : Intentional reconnect
6824 : MQTT : Connected to broker with client ID: ESPClient_B4:E6:2D:17:FB:AD
6832 : Subscribed to: /co2Sensor/#
6838 : EVENT: MQTT#Connected
15899 : MHZ19: Read error: checksum = 8 / 255 bytes read => 255/255/254/255/255/255/255/255/255/
15901 : MHZ19: Shifted 2 bytes to attempt to fix buffer alignment
31708 : WD : Uptime 1 ConnectFailures 0 FreeMem 16160
61875 : WD : Uptime 1 ConnectFailures 0 FreeMem 16160
76724 : MHZ19: Read error: checksum = 151 / 0 bytes read => 255/255/134/1/154/73/0/0/0/
76725 : MHZ19: Shifted 2 bytes to attempt to fix buffer alignment
91876 : WD : Uptime 2 ConnectFailures 0 FreeMem 16160
121876 : WD : Uptime 2 ConnectFailures 0 FreeMem 16160
136845 : MHZ19: PPM value: 588 Temp/S/U values: 33/0/0.00
136847 : EVENT: co2sensor#PPM=588.00
136856 : EVENT: co2sensor#Temperature=33.00
136863 : EVENT: co2sensor#U=0.00
151876 : WD : Uptime 3 ConnectFailures 0 FreeMem 16144
checkbox rules is enabled
using Release mega-20180410

/robin

wim16
Normal user
Posts: 77
Joined: 01 May 2017, 20:35

Re: Rules MQTT

#2 Post by wim16 » 11 Apr 2018, 14:57

I notice 2 things in your rules, not sure if they cause the problem.
1. You do not set timer1 on boot so the second rule will never fire.
2. Maybe there must be a comma after ' publish' instead of the space.

Barb232
Normal user
Posts: 40
Joined: 12 Mar 2016, 16:40
Location: Earth
Contact:

Re: Rules MQTT

#3 Post by Barb232 » 11 Apr 2018, 15:43

i think there is a problem with rules


i did this

Code: Select all

On co2sensor#PPM >100 do
Gpio,16,1
Endif


and the log says

Code: Select all

6707 : MHZ19: PPM value: 410 Temp/S/U values: 32/0/0.00
76709 : EVENT: co2sensor#PPM=410.00
76720 : EVENT: co2sensor#PPM=410.00 Processing time:11 milliSeconds
76721 : EVENT: co2sensor#Temperature=32.00
76730 : EVENT: co2sensor#Temperature=32.00 Processing time:10 milliSeconds
76731 : EVENT: co2sensor#U=0.00
76740 : EVENT: co2sensor#U=0.00 Processing time:9 milliSeconds
76801 : MQTT : /co2Sensor/co2sensor/PPM 410.00
76808 : MQTT : /co2Sensor/co2sensor/Temperature 32.00
76812 : MQTT : /co2Sensor/co2sensor/U 0.00
76814 : MQTT : Topic: /co2Sensor/co2sensor/PPM
76814 : MQTT : Payload: 410.00
76820 : MQTT : Topic: /co2Sensor/co2sensor/Temperature
76820 : MQTT : Payload: 32.00
76821 : MQTT : Topic: /co2Sensor/co2se
so it never runs into the rules

yes, i checked the rules option button...

AndrewJ
Normal user
Posts: 229
Joined: 14 Feb 2017, 12:38

Re: Rules MQTT

#4 Post by AndrewJ » 11 Apr 2018, 15:47

Barb232 wrote:
11 Apr 2018, 15:43
i think there is a problem with rules

i did this

Code: Select all

On co2sensor#PPM >100 do
Gpio,16,1
Endif


and the log says
snipped

so it never runs into the rules

yes, i checked the rules option button...
Hi, have a look at the Wiki on rules, it will guide you to the answer. ;)
Post again if you are still stuck.
Good luck!

Barb232
Normal user
Posts: 40
Joined: 12 Mar 2016, 16:40
Location: Earth
Contact:

Re: Rules MQTT (solved)

#5 Post by Barb232 » 11 Apr 2018, 16:06

it works now

Code: Select all

339563 : EVENT: Rules#Timer=1
339574 : ACT : Publish co2Sensor/co2Sensor/IP,192.168.178.52
339639 : ACT : timerSet,1,30

Code: Select all

On System#Boot do    //When the ESP boots, do
 Publish %sysname%/co2Sensor/IP,%ip%
  timerSet,1,30      //Set Timer 1 for the next event in 30 seconds
endon

On Rules#Timer=1 do  //When Timer1 expires, do
 Publish %sysname%/co2Sensor/IP,%ip%
  timerSet,1,30       //Resets the Timer 1 for another 30 seconds
endon
Solution: I made a factory reset

Post Reply

Who is online

Users browsing this forum: ajkbcd and 22 guests