Page 1 of 1

Rules If statment String

Posted: 30 Aug 2023, 10:05
by Sjuul
Hello,

I'am busy to connect my airco to ESP-Easy receiving data string works great.
The mode of the airco is transferred in a string like "FAN"
Now I try to make in the rules of ESP-Easy an if statement with this string see the code below

Code: Select all

If [Airco2#mode] = 'FAN'
 SendToHTTP 192.168.1.100,8080,/json.htm?type=command&param=switchlight&idx=384&switchcmd=Set%20Level&level=10
Endif
This doesn't work,

Has someone any suggestions to send the HTTP command when the "Fan" string is received?

Re: Rules If statment String

Posted: 30 Aug 2023, 10:11
by Ath
ESPEasy does not support processing string values in rules like that at this time.

How are you receiving those values?
Can they be replaced by numerical values on the sending side? As those can be handled by ESPEasy.

Re: Rules If statment String

Posted: 30 Aug 2023, 11:57
by Sjuul
Below the string i recieved.

Airco2#settings=`{'roomTemperature':19.0,'wideVane':'<<','power':'OFF','mode':'FAN','fan':'1','vane':'1','iSee'

As you can see there are some numbers but not for everthing.

Re: Rules If statment String

Posted: 30 Aug 2023, 12:09
by TD-er
How do you receive this string?
Via MQTT?

Re: Rules If statment String

Posted: 30 Aug 2023, 13:09
by Sjuul
It comes from "HwSerial port 0" Port to GPIO1 and GPIO3

I use this plugin https://espeasy.readthedocs.io/en/lates ... /P093.html

Re: Rules If statment String

Posted: 30 Aug 2023, 14:46
by Ath
Well, you can use the substring function (docs) and indexof function (just below the substring function in the docs) to find and extract the value, into another indexof to find some known values, and use that for comparisons, something like this:
(Be prepared that this isn't very efficient, of well designed yet, just dumping my brainfart :lol:)

Code: Select all

on airco2#settings=* do // use the asterisk to allow non-numeric 1st argument
  let,1,{indexof:mode:"%eventvalue1%"} // Start position of word: mode
  let,2,{indexof:FAN:{substring:%v1%+8:%v1%+11:%eventvalue1%}} // TODO: Check offsets
  if %v2%>-1
    SendToHTTP 192.168.1.100,8080,/json.htm?type=command&param=switchlight&idx=384&switchcmd=Set%20Level&level=10
  endif
endon
Disclaimer: Air code, untested
Edit: Fix some typos

Re: Rules If statment String

Posted: 30 Aug 2023, 16:08
by Sjuul
Thanks Ath,

This gives me an eye opener.
The plugin 0092 can give also sort value [Airco2#mode] returns only FAN
Just after the position you mentioned in the online help I found the function {equals:<string1>:<string2>}

Code: Select all

 If {equals:[Airco2#mode]:FAN} = 1
  SendToHTTP 192.168.1.100,8080,/json.htm?type=command&param=switchlight&idx=384&switchcmd=Set%20Level&level=10 //10 = Ventileren in Domoticz
 endif

Re: Rules If statment String

Posted: 30 Aug 2023, 16:51
by Ath
Ah, yes, that's much easier. Don't have any experience with this plugin :? though I have added that feature to get all values, and wrote the documentation (here). :lol: