Publish not working anymore

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Rampler
Normal user
Posts: 92
Joined: 31 Dec 2016, 07:13

Publish not working anymore

#1 Post by Rampler » 30 Oct 2019, 10:06

Hi,
i am using ESP_Easy_mega-20191028_normal_ESP8266_4M1M.bin.
Publish command is not working !
The command "publish /HMUART3/Taster,1" publishes nothing.

Debug Messages from Broker:
Client mosqsub|12301-Raspberry received PUBLISH (d0, q0, r0, m0, '/Gartenhaus/Count_Wind', ... (1 bytes))
/Gartenhaus/Count_Wind 2
Client mosqsub|12301-Raspberry received PUBLISH (d0, q0, r0, m0, 'Publish', ... (15 bytes))
Publish /HMUART3/Taster
Seems to be a parsing problem.
Back to ESP_Easy_mega-20180506_normal_ESP8266_4096.bin, all is working fine.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#2 Post by TD-er » 30 Oct 2019, 10:12

Have you also tried a version from let's say 20190928 (1 month ago) ?

Rampler
Normal user
Posts: 92
Joined: 31 Dec 2016, 07:13

Re: Publish not working anymore

#3 Post by Rampler » 30 Oct 2019, 10:21

Have you also tried a version from let's say 20190928 (1 month ago) ?
Version 20190928 is working, see debug log:

Code: Select all

Client mosqsub|12488-Raspberry received PUBLISH (d0, q0, r0, m0, '/HMUART3/Taster', ... (1 bytes))
/HMUART3/Taster 1

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#4 Post by TD-er » 30 Oct 2019, 11:16

I hope to have a test build ready later today.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#5 Post by TD-er » 30 Oct 2019, 12:01

Found the bug.
It is the same issue as this one: https://github.com/letscontrolit/ESPEasy/issues/2662

I just started a test build, which will be ready in less than an hour.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#6 Post by TD-er » 30 Oct 2019, 13:13

Can you try this test build: https://www.dropbox.com/s/7cbfjvg5ytlqc ... 8.zip?dl=0
Please let me know if it does work and it would be great if you could do some more thorough testing so I can merge it for tomorrow's build.

Rampler
Normal user
Posts: 92
Joined: 31 Dec 2016, 07:13

Re: Publish not working anymore

#7 Post by Rampler » 30 Oct 2019, 14:22

Publish again working with the test build.
Congratulations !!!

I cannot see any other errors....

waspie
Normal user
Posts: 127
Joined: 09 Feb 2017, 19:35

Re: Publish not working anymore

#8 Post by waspie » 30 Oct 2019, 14:59

thank you for resolving this TD-er

Rampler
Normal user
Posts: 92
Joined: 31 Dec 2016, 07:13

Re: Publish not working anymore

#9 Post by Rampler » 01 Nov 2019, 10:37

TD-er wrote: 30 Oct 2019, 13:13 Can you try this test build: https://www.dropbox.com/s/7cbfjvg5ytlqc ... 8.zip?dl=0
Please let me know if it does work and it would be great if you could do some more thorough testing so I can merge it for tomorrow's build.
Good morning, did you forget that?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#10 Post by TD-er » 01 Nov 2019, 13:51

Rampler wrote: 01 Nov 2019, 10:37 [...]

Good morning, did you forget that?
What did I forget?

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Publish not working anymore

#11 Post by dynamicdave » 01 Nov 2019, 14:38

I tried the version you mentioned and it does NOT work for me when I try to publish via a rule.

Note:
This is using a rule-set that works fine in a previous release (mega-20191003)

Rampler
Normal user
Posts: 92
Joined: 31 Dec 2016, 07:13

Re: Publish not working anymore

#12 Post by Rampler » 01 Nov 2019, 14:47

TD-er wrote: 01 Nov 2019, 13:51
Rampler wrote: 01 Nov 2019, 10:37 [...]

Good morning, did you forget that?
What did I forget?
.... so I can merge it for tomorrow's build. I thought we get a new build...

waspie
Normal user
Posts: 127
Joined: 09 Feb 2017, 19:35

Re: Publish not working anymore

#13 Post by waspie » 01 Nov 2019, 15:45

TD-er wrote: 30 Oct 2019, 13:13 Can you try this test build: https://www.dropbox.com/s/7cbfjvg5ytlqc ... 8.zip?dl=0
Please let me know if it does work and it would be great if you could do some more thorough testing so I can merge it for tomorrow's build.
As a side note:
Whatever has changed since 9/28 has also made my two main nodes *much* more reliable. My uptimes were generally sub 6 hours and neither one has rebooted since I updated with this pre-release
One is at 50 hours and the other 19 (didn't update it until much later)

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Publish not working anymore

#14 Post by dynamicdave » 01 Nov 2019, 16:10

I've just tried again with release... ESP_Easy_mega-20191028-21-PR_2698_normal_ESP8266_4M1M.bin

I have a publish command in a rule-set to publish a 'json' string.

It would seem if the payload is just a single item, then it works.
Publish,node24/ir_detector,{"ssid":"%ssid%"}

If it's more than one item, then is fails with "Failed to parse JSON string" appearing in Node-RED.
Publish,node24/ir_detector,{"ssid":"%ssid%","node_number":"node%unit%"}

Hope this helps to narrow-down the issue.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#15 Post by TD-er » 01 Nov 2019, 17:47

dynamicdave wrote: 01 Nov 2019, 16:10 [...]
If it's more than one item, then is fails with "Failed to parse JSON string" appearing in Node-RED.
Publish,node24/ir_detector,{"ssid":"%ssid%","node_number":"node%unit%"}
[...]
Like I posted in the other topic

Code: Select all

Publish,node24/ir_detector,'{"ssid":"%ssid%","node_number":"node%unit%"}'
Try this one.

To explain it, I check for quotes (single or double) to wrap an argument, which does allow to use the "other" quotes in a parameter, or a comma.
I think your comma was considered as a parameter separator.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#16 Post by TD-er » 01 Nov 2019, 17:52

Rampler wrote: 01 Nov 2019, 14:47
TD-er wrote: 01 Nov 2019, 13:51
Rampler wrote: 01 Nov 2019, 10:37 [...]

Good morning, did you forget that?
What did I forget?
.... so I can merge it for tomorrow's build. I thought we get a new build...
Well yesterday was way too hectic for me, and I did find some other small issues I also wanted to include in the new build.
So I did not want to rush a merge while also occupied with a lot of other things happening.
On top of that, I do want to have a proper look at some other report (also with the test build) where it does seem some rules parsing of multiple " and " or " or " in a line is not working like before.

I really don't like it what happened to the last (2) nightly builds, where I had people test the testbuilds and there appeared to be a number of other bugs I introduced in the last (huge) refactoring of rules code.
So better have an extra check here.

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Publish not working anymore

#17 Post by dynamicdave » 01 Nov 2019, 18:37

Thanks for pointing out that I should have surrounded the json string (in the Publish command) with single quote marks.

I can confirm that the json string publishes correctly in this release ( ESP_Easy_mega-20191028-21-PR_2698_normal_ESP8266_4M1M.bin ).

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#18 Post by TD-er » 01 Nov 2019, 20:56

Great!
So I should also have a look at the documentation regarding rules argument parsing to make it clear how the argument parsing is done.
One of the changes in the publish command is also that it does only read the publish arguments as single arguments.

Code: Select all

Publish,<topic>,<value>
In older builds it only parsed the <topic> argument and the rest was considered the <value>
Now the <value> parameter is parsed as a single argument, meaning it does allow later to add more parameters if we like.
But most importantly it will now yield a predictable result where older implementations could give different results depending on whether you had a single/double qoute or a square bracket at the end of the parameter. Also trailing space or comment could have an effect on how the argument would have been parsed.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#19 Post by TD-er » 02 Nov 2019, 22:59

Rampler wrote: 01 Nov 2019, 14:47
TD-er wrote: 01 Nov 2019, 13:51
Rampler wrote: 01 Nov 2019, 10:37 [...]

Good morning, did you forget that?
What did I forget?
.... so I can merge it for tomorrow's build. I thought we get a new build...
It has been merged.

User avatar
Sasch600xt
Normal user
Posts: 164
Joined: 10 Sep 2018, 16:37

Re: Publish not working anymore

#20 Post by Sasch600xt » 07 Nov 2019, 18:16

Sorry to bring it up again but it is still not working for me.

Clean install of ESPEasy mormal buld 1M4M 04112019 and this:

Code: Select all

on System#Boot do
timerSet,2,10
endon


On Rules#Timer=2 do
Publish,%sysname%/status/Build_date, "%sysbuild_date%"
Publish,%sysname%/status/Ip_Adresse, %ip%
timerSet,2,10
endon
is not working.

older version from 27082019 and this:

Code: Select all

on System#Boot do
timerSet,2,10
endon


On Rules#Timer=2 do
Publish,%sysname%/status/Build_date, %sysbuild_date%
Publish,%sysname%/status/Ip_Adresse, %ip%
timerSet,2,10
endon
is working perfect
"the flat earth society has members all around the globe"

Rampler
Normal user
Posts: 92
Joined: 31 Dec 2016, 07:13

Re: Publish not working anymore

#21 Post by Rampler » 08 Nov 2019, 11:19

Hi,
this is working on my side, new and old releases..

Code: Select all

on Taster#Taster do
 if [Dummy#Buttonpress] = 0   //Erster Tastendruck
    oledcmd,on
    TaskValueSet 5,1,1 
    timerSet,1,20
 else
    publish /HMUART3/Taster,1
 endif
endon

User avatar
Sasch600xt
Normal user
Posts: 164
Joined: 10 Sep 2018, 16:37

Re: Publish not working anymore

#22 Post by Sasch600xt » 08 Nov 2019, 14:58

Hello,

i guess i found the problem which brings me into trouble right now.

i try to explain.

i have spaces in my sysname (Kompressor Raum 1)

So this works now for also newer firmwares:

Code: Select all

On Rules#Timer=2 do
publish,"%sysname%"/status/Build_date, "%sysbuild_date%"
publish,"%sysname%"/status/Ip_Adresse, %ip%
timerSet,2,3600
endon
as you see i had also to add quotes to the sysname.

but the different to the "%sysbuild_date%" is that the quoutes not disapear after ariving in my open hub controller.

so before with older firmware i had a variable in my Open hub controller like this: Kompressor Raum 1
Now i have: "Kompressor Raum 1"
But at the same time "%sysbuild_date%" is working and shows me the build date without quotes.

This quotes are an issue because for my controller they are a totally new variable.

i can´t change the sysname because then i have totally new devices in my open hub controller which is much more worst.

So at the moment i have something about 200 publish messages from 5 ESPEasy devices.

Would be hell if all would be new variables for me in the open hub controller.


I hope you guys can help out here.

Thank you very much and have a great day
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#23 Post by TD-er » 08 Nov 2019, 20:28

Use quotes to separate a parameter if it is ambiguous.

Code: Select all

On Rules#Timer=2 do
publish,"%sysname%/status/Build_date","%sysbuild_date%"
publish,"%sysname%/status/Ip_Adresse",%ip%
timerSet,2,3600
endon
Also try not to use spaces between parameters.
So use the same quote " or ' at the begin and end of a parameter to make sure it is not split into multiple parameters.
In JSON you need ", so then you should wrap the argument in single quotes.

User avatar
Sasch600xt
Normal user
Posts: 164
Joined: 10 Sep 2018, 16:37

Re: Publish not working anymore

#24 Post by Sasch600xt » 08 Nov 2019, 22:21

dear TD-er,

i am sooooooo sorry :(
i feel a little stupid now
You are totally right and now all works again.

i am really so sorry to waste your time always :(
I am not that deep into programming.

You are always very kind and answere all my (sometimes stupid) questions within minutes or hours.

Thank you so much for your help
Have a great day

(let me know when you wanna make vacations, so i will not type questions then :))
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#25 Post by TD-er » 09 Nov 2019, 01:02

Sasch600xt wrote: 08 Nov 2019, 22:21 [...]
(let me know when you wanna make vacations, so i will not type questions then :))
Well, if you don't mind, I would like to go to bed right now ;)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#26 Post by TD-er » 09 Nov 2019, 23:31

Just as a reference, I added an issue to explain these changed in rules parameter parsing: https://github.com/letscontrolit/ESPEasy/issues/2724

flemingp
New user
Posts: 4
Joined: 04 Mar 2019, 11:02

Re: Publish not working anymore

#27 Post by flemingp » 28 Nov 2019, 10:05

I migrated a rules script to a new device (D1 Mini), with build 20104 - Mega, complied on platformio.

In this version I am unable to get the publish command to do anything

In the original script I had:

on virtualSwitch#switchStatus=1.00 do
Publish,heating,1 // publish message to set the slider switch to on
gpio,4,1 // Turn Light On
timerSet,1,5 // duration in second's
gpio,15,0 // ensure reset button can activate
endon

The publish command does not show up in the logging window, nor in a terminal window monitoring MQTT messages.

The same publish command does nothing if executed in the Command box of the Tools menu.

However, if I modify the command to: Publish /heating,5 it is received by the MQTT monitoring terminal and in the logging window of ESP Easy.

If I put that same publish command into the rules text there is no output.

I have tried many variations including:

publish,"%sysname%/status/Build_date","%sysbuild_date%"
publish,"%sysname%/status/Ip_Adresse",%ip%

I simply cannot get the publish command to working in a rules script.

I know the script is being processed as the state of the gpio changes.

In summary I can execute a publish command in command box of the tools menu, but cannot get a publish command to execute in a rules script.

Any help welcome.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#28 Post by TD-er » 28 Nov 2019, 14:22

Just a few base checks:
Publish uses the configuration of the first active MQTT controller. Those are correct and enabled?
Make sure to use quotes ( ' , " or `) to wrap each parameter when not entirely sure it doesn't contain special characters in the parameter.

Add a line with "logentry" in the same scope as your publish is used to log exactly the same as you try to publish.

For example:

Code: Select all

on virtualSwitch#switchStatus=1.00 do
  LogEntry,"Publish,heating,1"
  Publish,heating,1 // publish message to set the slider switch to on
  ...
About the quotes:

Code: Select all

  LogEntry,"heating,1"  // Quotes per parameter
  Publish,"heating","1"  // Quotes per parameter
With the logentry you can check if the rule is actually executed.
publish,"%sysname%/status/Build_date","%sysbuild_date%"
publish,"%sysname%/status/Ip_Adresse",%ip%
To be honest, I don't see immediately why this should not work.
PLease also add here a logentry line, to help debugging.
Just to be sure, check if the sysname contains a space, for example with

Code: Select all

LogEntry,"Sysname _%sysname%_"
This has the underscore directly wrapping the system variable, so you should see no other character between them.
You can also check the sysinfo page to see the values of the variables and maybe try other variables as well.

Make sure your log level is at least set to info.

flemingp
New user
Posts: 4
Joined: 04 Mar 2019, 11:02

Re: Publish not working anymore

#29 Post by flemingp » 28 Nov 2019, 17:10

Ty - I need to do some more work on this, and I will report back when I have understood what I have actually done.

dampa
Normal user
Posts: 87
Joined: 19 Jul 2018, 01:48

Re: Publish not working anymore

#30 Post by dampa » 08 Mar 2020, 21:49

In release mega-20200305 this is not working as I would expect. I have this rule set for testing:
on testMQTT do
publish node10/debug,"well look at that, it does work"
publish node10/debug,'{msg0}'
publish node10/debug,'{"msg1":"well look at that","msg2":"it does work"}'
publish node10/debug,{"msg3":"well look at that","msg4":"it does work"}
endon

and here is what shows up in the log:

120721: EVENT: testmqtt
120726: ACT : publish node10/debug,'well look at that, it does work'
120728: Command: publish
120732: ACT : publish node10/debug,''
120734: Command: publish
120738: ACT : publish node10/debug,''
120739: Command: publish
120744: ACT : publish node10/debug,
120745: Command: publish
122456: WD : Uptime 2 ConnectFailures 0 FreeMem 19808 WiFiStatus 3

In node-red, the only msg that gets thru is the first one. It has something to due with the open bracket '{' at the start - if I change the third line to:
publish node10/debug,'("msg1":"well-look-at-that","msg2":"it-does-work")'
the log shows:
252135: EVENT: testmqtt
252168: ACT : publish node10/debug,'well look at that, it does work'
252170: Command: publish
252174: ACT : publish node10/debug,''
252175: Command: publish
252178: ACT : publish node10/debug,'('msg1':'well-look-at-that','msg2':'it-does-work')'
252180: Command: publish
252185: ACT : publish node10/debug,
252186: Command: publish

If I start it with a close bracket '}' it works so something is looking at that open bracket and having an issue....

dampa
Normal user
Posts: 87
Joined: 19 Jul 2018, 01:48

Re: Publish not working anymore

#31 Post by dampa » 08 Mar 2020, 22:10

Ahh sure AFTER I test and write it up, I find out 'TD-er' is all over this (see https://github.com/letscontrolit/ESPEas ... 8d7c84588f)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Publish not working anymore

#32 Post by TD-er » 08 Mar 2020, 22:29

dampa wrote: 08 Mar 2020, 22:10 Ahh sure AFTER I test and write it up, I find out 'TD-er' is all over this (see https://github.com/letscontrolit/ESPEas ... 8d7c84588f)
Haha, good to see I fixed it in time before most people hit the same problem :)

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests