Page 1 of 1

Espeasy does always send the "Off" command to Domoticz

Posted: 02 Dec 2021, 17:55
by namxcap
Hi all, my wemos D1 mini is connected to a Nextion display. The display can change the idx and the value of the espeasy device (so it works), this is the log .....
device.JPG
device.JPG (24.05 KiB) Viewed 6843 times
but this rule:

Code: Select all

on exDisplay#value do
 if [exDisplay#value]="1"
  publish domoticz/in,'{"command": "switchlight", "idx": 17, "switchcmd": "1" }'
 else [exDisplay#value]="0"
  publish domoticz/in,'{"command": "switchlight", "idx": 17, "switchcmd": "0" }'
 endif
endon
sends always the "Off" if the value changes from 1 to 0 and from 0 to 1 too, and this is the Domoticz log......
device1.JPG
device1.JPG (42.22 KiB) Viewed 6843 times
I cannot solve this
:twisted: :twisted: :twisted:

Re: Espeasy does always send the "Off" command to Domoticz

Posted: 02 Dec 2021, 18:12
by TD-er
You should use %eventvalue1% instead of [exDisplay#value]
And don't use quotes wrapped around the 0 and 1

So something like this will work probably:

Code: Select all

on exDisplay#value do
  if %eventvalue1% = 0 or %eventvalue1% = 1
    publish domoticz/in,'{"command": "switchlight", "idx": 17, "switchcmd": "%eventvalue1%" }'
  endif
endon

Re: Espeasy does always send the "Off" command to Domoticz

Posted: 02 Dec 2021, 18:26
by namxcap
Not working, i get everytime the "Off" signal

:cry:

Re: Espeasy does always send the "Off" command to Domoticz

Posted: 02 Dec 2021, 18:30
by TD-er
Does the unit itself also act on the switching via the MQTT broker?
If so, then you may want to have a look at the documentation of the Domoticz Helper plugin: https://espeasy.readthedocs.io/en/lates ... #p029-page

Re: Espeasy does always send the "Off" command to Domoticz

Posted: 02 Dec 2021, 18:45
by namxcap
No, it only should sends a command. The device is only connected to the display
Is it possible to send a http command like this ?

Code: Select all

http://192.168.0.13:8841/json.htm?type=command&param=switchlight&idx=20&switchcmd=On
with this line i can obtain the light On

Re: Espeasy does always send the "Off" command to Domoticz

Posted: 02 Dec 2021, 21:06
by namxcap
I'm trying different way to solve the problem but it seems rules does not have effects anyway, is like rules are disabled ..... is it possible ?

Re: Espeasy does always send the "Off" command to Domoticz

Posted: 02 Dec 2021, 21:32
by TD-er
One simple way of debugging rules is to add logentry commands in the rules.
See: https://espeasy.readthedocs.io/en/lates ... l-commands

For example:

Code: Select all

on exDisplay#value do
  logentry,'exDisplay: %eventvalue1%'
  if %eventvalue1% = 0 or %eventvalue1% = 1
    publish domoticz/in,'{"command": "switchlight", "idx": 17, "switchcmd": "%eventvalue1%" }'
  endif
endon
This will add log lines (at loglevel info) showing the event value, starting with the string: "exDisplay:"

You can also call sendToHttp, to call the http URL you mention.
See: https://espeasy.readthedocs.io/en/lates ... l-commands

Re: Espeasy does always send the "Off" command to Domoticz

Posted: 03 Dec 2021, 07:32
by namxcap
Thankyou TD-er, i have this log, so now (reflashed espeasy to another device) the rule works. there is only the problem that Domoticz receive everytime the "Off" signal

Code: Select all

36867684: EVENT: exDisplay#idx=77
36867778: EVENT: exDisplay#value=1
36867785: ACT : logentry,'exDisplay: 1'
36867789: exDisplay: 1
36867799: ACT : publish domoticz/in,'{'command': 'switchlight', 'idx': 17, 'switchcmd': '1' }'
36868784: EVENT: exDisplay#idx=88
36868878: EVENT: exDisplay#value=0
36868884: ACT : logentry,'exDisplay: 0'
36868889: exDisplay: 0
36868900: ACT : publish domoticz/in,'{'command': 'switchlight', 'idx': 17, 'switchcmd': '0' }'

Re: Espeasy does always send the "Off" command to Domoticz

Posted: 03 Dec 2021, 07:54
by Ath
Starting with this:
namxcap wrote: 02 Dec 2021, 18:45

Code: Select all

http://192.168.0.13:8841/json.htm?type=command&param=switchlight&idx=20&switchcmd=On
with this line i can obtain the light On
I think you need to send On or Off to Domoticz, like below:

Code: Select all

on exDisplay#value do
  logentry,'exDisplay: %eventvalue1%'
  let,1,%eventvalue1%
  if %eventvalue1% = 0 or %eventvalue1% = 1
    publish domoticz/in,'{"command": "switchlight", "idx": 17, "switchcmd": "[var#1#o#c]" }'
  endif
endon
That uses transformation 'o' to go from 0 -> OFF or 1-> ON, and justification 'c' to have first upper Off or On, as Domoticz expects it (AFAIK) (and the quotes are required to have valid Json).
Transformations can't be applied to %% variables, so first have to assign it to a variable using 'let'.

Re: Espeasy does always send the "Off" command to Domoticz

Posted: 03 Dec 2021, 10:17
by TD-er
Just for completeness, see this explanation: https://espeasy.readthedocs.io/en/lates ... red-values
I am not sure if Domoticz checks these parmeters case insensitive.
If it doesn't, then you might want to use the if statement to select different string values "On" and "Off"

Re: Espeasy does always send the "Off" command to Domoticz

Posted: 03 Dec 2021, 11:14
by Ath
Domoticz seems rather picky on these arguments, that's why it is treating anything not being "On" as an "Off" value :x
I've only been able to get that working properly by using these On (and Off) values, that why I suggest to use these formatting and justification options 'o' and 'c' ;)