Rules not working 20201227 and later

Moderators: grovkillen, Stuntteam, TD-er

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

Rules not working 20201227 and later

#1 Post by dynamicdave » 16 Oct 2021, 18:43

I'm probably doing something incorrectly, but I can't make a rule for a normal switch to work after release esp8266-normal-2020-1227
I have two switches named top and bottom. I can see the values changing if I look on the devices tab.
But the rule dosen't want to publish the value.
If I send an event 'sendSensorPosition' from Node-RED it will publish the values correctly.
Any ideas as to what I'm doing wrong would be appreciated.

Code: Select all

On sendSensorPosition Do
   event,publishReading
EndOn

On publishReading Do
   publish,garagedoor/sensors,'{"level":[top#level],"sensor":"top"}'
   publish,garagedoor/sensors,'{"level":[bottom#level],"sensor":"bottom"}'
endOn

On top#level Do
   event,publishReading
EndOn

On bottom#level Do
   event,publishReading
EndOn

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

Re: Rules not working 20201227 and later

#2 Post by TD-er » 16 Oct 2021, 19:07

Hmm at first sight, I don't see what may be wrong here.
Can you add some calls to logitem to help debugging?
For example, does it even enter On top#level Do
?

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rules not working 20201227 and later

#3 Post by ThomasB » 16 Oct 2021, 19:36

Along with that, check Tools->Advanced->RulesSettings and verify both RULES and OLD ENGINE are enabled.

Another cause of rule failure is due to the presence of an unprintable character in the rule text file. Hard to find these unless you copy/paste the entire text into an editor that shows such things. Notepad++ works well.

- Thomas

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

Re: Rules not working 20201227 and later

#4 Post by dynamicdave » 16 Oct 2021, 19:52

It's really strange - it works fine in mega-version ESP8266 20201227, but in later versions it doesn't.
I've spent too much time on it today, but will insert some debugs, as suggested, and see if it is entering... on top#level do
I'm actually using a Wemos D1 Mini fitted with a 4Mb chip and an ESP01-S to create a voice-operated garage-door controller.
Attachments
Schematic_Garage door controller_2021-10-13.png
Schematic_Garage door controller_2021-10-13.png (95.21 KiB) Viewed 7829 times

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rules not working 20201227 and later

#5 Post by ThomasB » 16 Oct 2021, 20:00

You didn't say if you've tried the very latest ESPEASY releases. But keep in mind that some 2020 releases had weird rule formatting quirks that were eventually resolved. The one that got me was reported here (not your issue, but this shows how fussy the rule syntax had been):
https://github.com/letscontrolit/ESPEasy/issues/2987

Long story short, go big and install the very latest.

- Thomas
Last edited by ThomasB on 16 Oct 2021, 20:22, edited 2 times in total.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rules not working 20201227 and later

#6 Post by ThomasB » 16 Oct 2021, 20:08

Looks like a fun project.

Be sure to disable internal pullups on D1 / D2.

- Thomas

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

Re: Rules not working 20201227 and later

#7 Post by dynamicdave » 16 Oct 2021, 20:21

Well it is developing into a fun project.
I'm using Alexa with some nodes in Node-RED, so I can say things like... "Alexa, open garage door" or "Alexa, close garage door"
I dropped one of the remote control key fobs the other day - broke the plastic case - BUT the electronics still works.
So rather than throwing it away I took it to pieces and found the place where the push-button switch joins to the PCB.
Soldered some wires, so if you touch them together for 3 or more seconds - the garage door is activated.
I'm using a relay on the ESP01-S to simulate the key-fob being pressed.
I installed a couple of microswitches at the top and bottom of the door's travel so I can detect where it is.
I've had the door (sort of) working today - but the rules aren't triggering the publish to MQTT.
key_fob_a.jpg
key_fob_a.jpg (150.45 KiB) Viewed 7813 times
Attachments
voice_operated_garage_door_B.jpg
voice_operated_garage_door_B.jpg (127.97 KiB) Viewed 7813 times
Last edited by dynamicdave on 16 Oct 2021, 20:50, edited 1 time in total.

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

Re: Rules not working 20201227 and later

#8 Post by dynamicdave » 16 Oct 2021, 20:42

I don't believe this - I couldn't wait until tomorrow, so I went and got all the kit and reflashed it with... ESP_Easy_mega_20211005_normal_ESP8266_4M1M
It appears to be publishing the switch states now via MQTT.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rules not working 20201227 and later

#9 Post by ThomasB » 16 Oct 2021, 21:08

That's good news.

I quickly looked at ESPEasy GitHub tickets and didn't see any reports about rule problems around the 20201227 time frame. Maybe @TD-er has an idea of what might have been the problem.

- Thomas

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

Re: Rules not working 20201227 and later

#10 Post by dynamicdave » 16 Oct 2021, 21:30

Thanks for all your help.
I have no idea what has changed from this morning.
I swear it wasn't working and none of the other versions would work until I got back to 2020127.
Now after reflashing (again) with 20211105 it has decided to behave itself!!!
Makes me out to be a fraud !!
Totally confused of the UK.
Last edited by dynamicdave on 17 Oct 2021, 09:02, edited 1 time in total.

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

Re: Rules not working 20201227 and later

#11 Post by TD-er » 16 Oct 2021, 22:36

What could have helped here is that maybe you did save the rules again using one of the later versions?
I remember that the JavaScript used to save the rules, also has some basic checks in it like proper (or at least consequent) line endings.
So it could have been something Thomas already suggested, that it was a misbehaving non-ASCII character in there?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 22 guests