Espeasy does always send the "Off" command to Domoticz

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
namxcap
Normal user
Posts: 14
Joined: 06 May 2021, 23:57

Espeasy does always send the "Off" command to Domoticz

#1 Post by namxcap » 02 Dec 2021, 17:55

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 6372 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 6372 times
I cannot solve this
:twisted: :twisted: :twisted:

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

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

#2 Post by TD-er » 02 Dec 2021, 18:12

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

namxcap
Normal user
Posts: 14
Joined: 06 May 2021, 23:57

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

#3 Post by namxcap » 02 Dec 2021, 18:26

Not working, i get everytime the "Off" signal

:cry:

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

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

#4 Post by TD-er » 02 Dec 2021, 18:30

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

namxcap
Normal user
Posts: 14
Joined: 06 May 2021, 23:57

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

#5 Post by namxcap » 02 Dec 2021, 18:45

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

namxcap
Normal user
Posts: 14
Joined: 06 May 2021, 23:57

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

#6 Post by namxcap » 02 Dec 2021, 21:06

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 ?

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

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

#7 Post by TD-er » 02 Dec 2021, 21:32

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

namxcap
Normal user
Posts: 14
Joined: 06 May 2021, 23:57

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

#8 Post by namxcap » 03 Dec 2021, 07:32

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' }'

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

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

#9 Post by Ath » 03 Dec 2021, 07:54

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'.
/Ton (PayPal.me)

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

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

#10 Post by TD-er » 03 Dec 2021, 10:17

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"

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

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

#11 Post by Ath » 03 Dec 2021, 11:14

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' ;)
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 31 guests