mqtt rule - help needed
Moderators: grovkillen, Stuntteam, TD-er
mqtt rule - help needed
Hi All
I presume i am doing something stupid...
I am subscribed to mqtt and i can see my status, analog value and i can control GPIO over mqtt.
I am trying to use a rule to send the IP address every 30 seconds as per the example under the rules, but i never see it triggered in the log or any info in my mqtt using mqtt explorer
on MQTT#Connected do
Publish,%sysname%/%unit%/IP,%ip%
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
endon
Any pointers will be helpfull
I presume i am doing something stupid...
I am subscribed to mqtt and i can see my status, analog value and i can control GPIO over mqtt.
I am trying to use a rule to send the IP address every 30 seconds as per the example under the rules, but i never see it triggered in the log or any info in my mqtt using mqtt explorer
on MQTT#Connected do
Publish,%sysname%/%unit%/IP,%ip%
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
endon
Any pointers will be helpfull
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: mqtt rule - help needed
Code: Select all
On Rules#Timer=1 Do
....
EndOn
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: mqtt rule - help needed
Hi grovkillen
As i said, i am doing something stupid...
On Rules#Timer=1 Do
Publish,%sysname%/%unit%/IP,%ip%
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
Still not working???
As i said, i am doing something stupid...
On Rules#Timer=1 Do
Publish,%sysname%/%unit%/IP,%ip%
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
Still not working???
Re: mqtt rule - help needed
But are you (also) starting the timer in the on mqtt#connected rule? It doesn't start by itself...
/Ton (PayPal.me)
Re: mqtt rule - help needed
Hi Ath
Sorry, i did not post the complete rule
----
On MQTT#Connected Do
Publish,%sysname%/%unit%/IP,%ip%
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
On Rules#Timer=1 Do
Publish,%sysname%/%unit%/IP,%ip%
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
----
The only thing i saw in the log file is that it intentional reconnect to the mqtt, but i do not see the IP address getting pushed to the mqtt broker.
Sorry, i did not post the complete rule
----
On MQTT#Connected Do
Publish,%sysname%/%unit%/IP,%ip%
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
On Rules#Timer=1 Do
Publish,%sysname%/%unit%/IP,%ip%
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
----
The only thing i saw in the log file is that it intentional reconnect to the mqtt, but i do not see the IP address getting pushed to the mqtt broker.
Re: mqtt rule - help needed
Does MQTT#connected ever fire?
You can try to trigger an LED, write a logentry in the rules, etc. to test.
Does the sysname have a space in it?
Maybe best to wrap the parameters with quotes, just to be sure.
You can try to trigger an LED, write a logentry in the rules, etc. to test.
Does the sysname have a space in it?
Maybe best to wrap the parameters with quotes, just to be sure.
Code: Select all
Publish,"%sysname%/%unit%/IP","%ip%"
Re: mqtt rule - help needed
Hi TD-er
No spaces in sysname, sysname is only 4 alpha chars - Nuco
Wrapping them in quotes also did make any change.
I shall see if i can get some diagnostics going, but i suspect that the rule is not firing...
No spaces in sysname, sysname is only 4 alpha chars - Nuco
Wrapping them in quotes also did make any change.
I shall see if i can get some diagnostics going, but i suspect that the rule is not firing...
Re: mqtt rule - help needed
So i change the rule to switch on the "Blue" LED on mqtt connect, it didn't, so it seems that rules are not firing - but check in lower in log.
On MQTT#Connected Do
Publish,"%sysname%/%unit%/IP","%ip%"
GPIO,2,0
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
On Rules#Timer=1 Do
Publish,"%sysname%/%unit%/IP","%ip%"
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
Here is the log file: - I press the Reset on my board
619: EVENT: System#Boot
1659: WIFI : Connected! AP: Zodiac01 (bla:bla:bal:bal:bla:bla) Ch: 4 Duration: 1033 ms
1661: WIFI : DHCP IP: 192.168.xxx.yyy (Nuco) GW: 192.168.xxx.yyy SN: 255.255.255.0 duration: 15 ms
1679: ADC : Analog value: 8 = 8.000
1692: SW : State 0.00
1701: EVENT: Time#Initialized
2767: EVENT: Clock#Time=Sat,23:34
2822: firstLoopConnectionsEstablished
2827: EVENT: WiFi#Connected
2861: WD : Uptime 0 ConnectFailures 0 FreeMem 19128 WiFiStatus WL_CONNECTED
2907: MQTT : Intentional reconnect
2958: MQTT : Connected to broker with client ID: Nuco/1
2962: Subscribed to: Nuco/1/#
2970: EVENT: Power#Analog=8.00
3027: EVENT: Activate#Activate=0.00
3129: ADC : Analog value: 8 = 8.000
3139: EVENT: MQTT#Connected - Here mqtt event fire, but blue LED does not come on???
3178: SW : State 0.00
3227: EVENT: Power#Analog=8.00
3327: EVENT: Activate#Activate=0.00
13105: ADC : Analog value: 15 = 15.000
13129: EVENT: Power#Analog=15.00
23101: ADC : Analog value: 8 = 8.000
23127: EVENT: Power#Analog=8.00
31984: WD : Uptime 1 ConnectFailures 0 FreeMem 15048 WiFiStatus WL_CONNECTED
33105: ADC : Analog value: 8 = 8.000
33129: EVENT: Power#Analog=8.00
43101: ADC : Analog value: 8 = 8.000
43127: EVENT: Power#Analog=8.00
53101: ADC : Analog value: 8 = 8.000
53129: EVENT: Power#Analog=8.00
60434: EVENT: Clock#Time=Sat,23:35
On MQTT#Connected Do
Publish,"%sysname%/%unit%/IP","%ip%"
GPIO,2,0
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
On Rules#Timer=1 Do
Publish,"%sysname%/%unit%/IP","%ip%"
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
Here is the log file: - I press the Reset on my board
619: EVENT: System#Boot
1659: WIFI : Connected! AP: Zodiac01 (bla:bla:bal:bal:bla:bla) Ch: 4 Duration: 1033 ms
1661: WIFI : DHCP IP: 192.168.xxx.yyy (Nuco) GW: 192.168.xxx.yyy SN: 255.255.255.0 duration: 15 ms
1679: ADC : Analog value: 8 = 8.000
1692: SW : State 0.00
1701: EVENT: Time#Initialized
2767: EVENT: Clock#Time=Sat,23:34
2822: firstLoopConnectionsEstablished
2827: EVENT: WiFi#Connected
2861: WD : Uptime 0 ConnectFailures 0 FreeMem 19128 WiFiStatus WL_CONNECTED
2907: MQTT : Intentional reconnect
2958: MQTT : Connected to broker with client ID: Nuco/1
2962: Subscribed to: Nuco/1/#
2970: EVENT: Power#Analog=8.00
3027: EVENT: Activate#Activate=0.00
3129: ADC : Analog value: 8 = 8.000
3139: EVENT: MQTT#Connected - Here mqtt event fire, but blue LED does not come on???
3178: SW : State 0.00
3227: EVENT: Power#Analog=8.00
3327: EVENT: Activate#Activate=0.00
13105: ADC : Analog value: 15 = 15.000
13129: EVENT: Power#Analog=15.00
23101: ADC : Analog value: 8 = 8.000
23127: EVENT: Power#Analog=8.00
31984: WD : Uptime 1 ConnectFailures 0 FreeMem 15048 WiFiStatus WL_CONNECTED
33105: ADC : Analog value: 8 = 8.000
33129: EVENT: Power#Analog=8.00
43101: ADC : Analog value: 8 = 8.000
43127: EVENT: Power#Analog=8.00
53101: ADC : Analog value: 8 = 8.000
53129: EVENT: Power#Analog=8.00
60434: EVENT: Clock#Time=Sat,23:35
Re: mqtt rule - help needed
1. Sometimes a rule event won't fire because of corruption in the rule file. For example, an unprintable character may be hiding in it. This evil situation can cause very strange behavior. I suggest deleting ALL the rule files and hand typing the rules again. Don't copy and paste since the source text might have the problem in it.
2. Visit Tools->Advanced->RuleSettings. Confirm "Rules" and "Old Engine" check boxes are both enabled.
3. Old versions of ESPEasy do not support MQTT#Connected. But that isn't the issue here since the event appears in the logs. But even so, try a different recent release.
@all: BTW, it is a good idea to mention your ESPEasy version number and hardware (board) when you post a problem in the forum.
- Thomas
2. Visit Tools->Advanced->RuleSettings. Confirm "Rules" and "Old Engine" check boxes are both enabled.
3. Old versions of ESPEasy do not support MQTT#Connected. But that isn't the issue here since the event appears in the logs. But even so, try a different recent release.
@all: BTW, it is a good idea to mention your ESPEasy version number and hardware (board) when you post a problem in the forum.
- Thomas
Re: mqtt rule - help needed
As an addition to Thomas suggestion (which I didn't think of).
You can copy the text to a program like Notepad++, which allows to highlight special characters.
If you find any, please let me know, so I can perhaps add a check for such characters in the parser.
You can copy the text to a program like Notepad++, which allows to highlight special characters.
If you find any, please let me know, so I can perhaps add a check for such characters in the parser.
Re: mqtt rule - help needed
Adding an 'eventlog' line in the script is often quite helpful:
Code: Select all
On Rules#Timer=1 Do
EventLog,"%sysname%/%unit%/IP,%ip%" // removed some quotes!
Publish,"%sysname%/%unit%/IP","%ip%"
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
/Ton (PayPal.me)
Re: mqtt rule - help needed
Hi All
Thank you for the assistance thus far. - Just for FYI, "Old Engine" was NOT enabled before.
So i started from scratch, wipe, re-programme - ESP_Easy_mega_20200703_normal_ESP8266_4M1M, board is from Electrodragon ESP8266 R3.
Setup everything like it was before. Update Rules Set 1 and confirmed that there is no spaces or "funny" characters.
Set log to Debug, but still nothing in my mqtt broker. I then decided to push the "Reset" button and check the log and i saw the following, but still nothing in my broker.
ACT : Publish,'Nuco/1/IP,192.168.2.195'
Command: Publish
Publish: Nuco/1/IP,192.168.2.195
I then removed all the quotation marks, and - it is working, see log below:
ACT : Publish,Nuco/1/IP,192.168.2.195
Command: Publish
Publish: Nuco/1/IP192.168.2.195
So my working rule now looks like this with no quotations: and i use the "Old Engine:"
On MQTT#Connected Do
Publish,%sysname%/%unit%/IP,%ip%
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
On Rules#Timer=1 Do
Publish,%sysname%/%unit%/IP,%ip%
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
It seems that after making changes to "Rules", a Re-Boot is the best as it seems that the rules don't always fire correctly after changes.
Thank you to everyone that assisted.
Thank you for the assistance thus far. - Just for FYI, "Old Engine" was NOT enabled before.
So i started from scratch, wipe, re-programme - ESP_Easy_mega_20200703_normal_ESP8266_4M1M, board is from Electrodragon ESP8266 R3.
Setup everything like it was before. Update Rules Set 1 and confirmed that there is no spaces or "funny" characters.
Set log to Debug, but still nothing in my mqtt broker. I then decided to push the "Reset" button and check the log and i saw the following, but still nothing in my broker.
ACT : Publish,'Nuco/1/IP,192.168.2.195'
Command: Publish
Publish: Nuco/1/IP,192.168.2.195
I then removed all the quotation marks, and - it is working, see log below:
ACT : Publish,Nuco/1/IP,192.168.2.195
Command: Publish
Publish: Nuco/1/IP192.168.2.195
So my working rule now looks like this with no quotations: and i use the "Old Engine:"
On MQTT#Connected Do
Publish,%sysname%/%unit%/IP,%ip%
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
On Rules#Timer=1 Do
Publish,%sysname%/%unit%/IP,%ip%
timerSet,1,30 //Resets the Timer 1 for another 30 seconds
EndOn
It seems that after making changes to "Rules", a Re-Boot is the best as it seems that the rules don't always fire correctly after changes.
Thank you to everyone that assisted.
Re: mqtt rule - help needed
Using the 'old engine' is the best indeed.
I think I rename the new one to "experimental", as it is way harder to use.
I think I rename the new one to "experimental", as it is way harder to use.
Re: mqtt rule - help needed
Glad you solved the problem.
= Thomas
In your setup the reboot was needed because of the MQTT#Connected rule. Typically this rule trigger occurs soon after reboot when WiFi is established and the MQTT broker is found. That is to say, the edits to the rules were late to the party and the Connect rule needs the MQTT broker to change states (move from disconnect state to connect state). A reboot is one way to do this.It seems that after making changes to "Rules", a Re-Boot is the best as it seems that the rules don't always fire correctly after changes.
= Thomas
Re: mqtt rule - help needed
Just to let you know.
You can trigger those events as mentioned by Thomas.
Just enter the command
in the "command" field on the Tools page of the web interface.
You can trigger those events as mentioned by Thomas.
Just enter the command
Code: Select all
event,MQTT#Connected
-
- Normal user
- Posts: 21
- Joined: 05 Aug 2020, 17:54
Re: mqtt rule - help needed
Hi!
How about sending your ip every minute. If every minute would be enough, sending the ip would be as simple as
How about sending your ip every minute. If every minute would be enough, sending the ip would be as simple as
Code: Select all
on Clock#Time=all,**:** do
Publish,%sysname%/%unit%/IP,%ip%
endon
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests