Page 1 of 1

Make Domoticz read a GPIO pin

Posted: 24 Jul 2021, 21:30
by Collector
Hello,

I need some help writing a correct statement in Rules to make sure that a virtual switch in Domoticz follows a GPIO, or PCFGPIO, defined by some rules, e.g. Toggle, using json.
I tried the SendToHTTP command, but I can't find the correct json syntax to send the status of that GPIO to the Domoticz IP.
I want to do this to allow ESP8266 to make some autonomous GPIO decisions, simply then notifying them to Domoticz.

I hope I have explained.

Thank you.

Re: Make Domoticz read a GPIO pin

Posted: 24 Jul 2021, 21:57
by TD-er
Can you use the Domoticz MQTT controller?
Then please have a look at this here: https://espeasy.readthedocs.io/en/lates ... #p029-page

Re: Make Domoticz read a GPIO pin

Posted: 29 Jul 2021, 22:26
by Collector
Thanks for the hint.
I was wondering if it were possible using a variable that follows the GPIO state in rules, then I sendtoHTTP the value of this variable to Domoticz.
If yes, which could be the correct syntax?

Re: Make Domoticz read a GPIO pin

Posted: 29 Jul 2021, 22:34
by TD-er
See the "monitor" command: https://espeasy.readthedocs.io/en/lates ... ernal-gpio

This will send an event as soon as the pin state changes, on which you can act in the rules.

Re: Make Domoticz read a GPIO pin

Posted: 19 Aug 2021, 23:14
by kimot
I am using some Sonnofs like relays, which can be triggered by local push button, other ESP or from Domoticz and reports its actual status to Domoticz.
GPIO-0 local push button
GPIO-12 relay




2021-08-19-230307_1920x1080_scrot.png
2021-08-19-230307_1920x1080_scrot.png (113.11 KiB) Viewed 4976 times

Code: Select all

On System#Boot do
 gpio,12,0 
 TaskValueSet,3,1,1
endon

on Tlacitko#State do
  if [Pom#State]=0
    event, change
  else
    TaskValueSet,3,1,0
    SendToHTTP 192.168.1.253,8080,/json.htm?type=command&param=switchlight&idx=163&switchcmd=Off
  endif
endon

on change  do
  if  [Relay#State]=0
    gpio,12,1
    SendToHTTP 192.168.1.253,8080,/json.htm?type=command&param=switchlight&idx=163&switchcmd=On
  else
    gpio,12,0
    SendToHTTP 192.168.1.253,8080,/json.htm?type=command&param=switchlight&idx=163&switchcmd=Off
  endif
endon

From Domoticz it is switched with:

Code: Select all

http://192.168.1.119/control?cmd=gpio,12,1
http://192.168.1.119/control?cmd=gpio,12,0