Make Domoticz read a GPIO pin

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Collector
Normal user
Posts: 2
Joined: 24 Jul 2021, 18:23

Make Domoticz read a GPIO pin

#1 Post by Collector » 24 Jul 2021, 21:30

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.

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

Re: Make Domoticz read a GPIO pin

#2 Post by TD-er » 24 Jul 2021, 21:57

Can you use the Domoticz MQTT controller?
Then please have a look at this here: https://espeasy.readthedocs.io/en/lates ... #p029-page

Collector
Normal user
Posts: 2
Joined: 24 Jul 2021, 18:23

Re: Make Domoticz read a GPIO pin

#3 Post by Collector » 29 Jul 2021, 22:26

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?

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

Re: Make Domoticz read a GPIO pin

#4 Post by TD-er » 29 Jul 2021, 22:34

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.

kimot
Normal user
Posts: 184
Joined: 12 Oct 2017, 20:46

Re: Make Domoticz read a GPIO pin

#5 Post by kimot » 19 Aug 2021, 23:14

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 591 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

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests