Page 1 of 1

Rule help

Posted: 31 Jul 2018, 00:23
by trumee
Hello,

I am using MQTT import plugin to read a topic and display its value on OLED. The import works fine but displaying the value of the variable doesnt work,

Code: Select all

on motor#ONOFFSTATE do

  if [motor#ONOFFSTATE]>0
     OLEDCMD,on
     OLED,3,1,Motor ON
     OLED,4,1,Motor [motor#ONOFFSTATE]  //DOESNT WORK
  else
     OLED,3,1,Motor OFF
     OLED,4,1,Motor [motor#ONOFFSTATE]  //DOESNT WORK
  endif
     OLED,1,1, %systm_hm_am%
endon
What is the right way of display MQTT topic in a rule?

Thanks

Re: Rule help

Posted: 01 Aug 2018, 22:04
by TD-er
You could try setting it in quotes, like this:
OLED,4,1,"Motor [motor#ONOFFSTATE]"

Problem with rules parsing is that the space is also a parameter separator.

N.B. this quotes feature is added very recently. Not sure if it will work like this, but you could try.

Re: Rule help

Posted: 05 Aug 2018, 00:39
by trumee
Unfortunately, that did not work. The error was , Command unknown ". The quotes was not accepted. I am running ESP_Easy_mega-20180804_normal_ESP8266_4096.bin

Re: Rule help

Posted: 05 Aug 2018, 09:16
by grovkillen
Show us the exact command you tried.

Re: Rule help

Posted: 12 Aug 2018, 16:28
by trumee
I am using the following rule,

Code: Select all

On System#Boot do    //When the ESP boots, do
OLEDCMD,clear
endon

on motor#ONOFFSTATE do

  if [motor#ONOFFSTATE]>0
     OLEDCMD,on
     OLED,2,1,"Motor ON"
     OLED,3,1,"Motor [motor#ONOFFSTATE]"
     
  else
     OLED,2,1,"Motor OFF"
     OLED,3,1,"Motor [motor#ONOFFSTATE]"

  endif

endon
On switching on the nodemcu I get a single message "MOTOR OFF", I dont get the second line which should say, "MOTOR 0".

Re: Rule help

Posted: 12 Aug 2018, 17:10
by grovkillen

Code: Select all

On System#Boot do    //When the ESP boots, do
OLEDCMD,clear
endon

on motor#ONOFFSTATE do
  if [motor#ONOFFSTATE]>0
     OLEDCMD,on
     OLEDCMD,2,1,"Motor ON"
     OLEDCMD,3,1,"Motor [motor#ONOFFSTATE]"
  else
     OLEDCMD,2,1,"Motor OFF"
     OLEDCMD,3,1,"Motor [motor#ONOFFSTATE]"
  endif
endon

Re: Rule help

Posted: 14 Aug 2018, 00:35
by trumee
With your rule i get an error in the log,

Code: Select all

6799: EVENT: MQTT#Connected
7154: IMPT : [motor#ONOFFSTATE] : 1.00
7156: EVENT: motor#ONOFFSTATE=1.00
7172: ACT : OLEDCMD,on
7181: ACT : OLEDCMD,2,1,'Motor ON'
7190: ACT : OLEDCMD,3,1,'Motor 1.00'
7208: Command: oledcmd
7208: Command unknown: 'oledcmd'
7355: IMPT : [motor#PRESSURE] : 0.00
7356: EVENT: motor#PRESSURE=0.00
7654: IMPT : [motor#OLEDSTATE] : 1.00
7655: EVENT: motor#OLEDSTATE=1.00
Looking at this page, OLEDCMD only accepts 1 arguement.

Re: Rule help

Posted: 14 Aug 2018, 07:13
by grovkillen
Ah, sorry.

I will do some testing once I get my own OLED test unit set up.

Re: Rule help

Posted: 18 Aug 2018, 04:20
by trumee
@grovkillen, any luck?

Re: Rule help

Posted: 18 Aug 2018, 11:59
by grovkillen
trumee wrote: 18 Aug 2018, 04:20 @grovkillen, any luck?
Haven't gotten around to test it just yet... sorry! Will try to find time next week.

Re: Rule help

Posted: 25 Aug 2018, 15:28
by trumee
@grovkillen ok, looking forward to it.

Re: Rule help

Posted: 01 Sep 2018, 17:20
by trumee
Anybody willing to help?