Home / Community / Blog / Domoticz - two switches, one actuator

Domoticz - two switches, one actuator

I had a problem with Domoticz and switches.

I've ESP8266 module (with ESP Easy v.120) and relay (SSR) - it's very simple to get it work using web interface.

I would like to have some kind of switch not to have use phone to turn on the light. My solution it's not so simple I think it can be done better.

My ESPEasy module has address 192.168.1.7, SSR is connected to GPIO12 and touch sensot is connected to GPIO14. It has configured "Protocol" as "Domoticz HTTP". The "touch" switch is defined in ESPEasy as:

  • Device: "Switch input"
  • IDX / Var: 10 (Idx from Domoticz)
  • 1st GPIO: GPIO14
  • Type: "Switch"
  • Switch Button Type: "Normal switch"
  • Send Data: On

I didn't define relay connected to GPIO12 - it is set directly from domoticz as described below.

My domoticz has address 192.168.1.8. I defined "dummy" hardware with two "switches":

  1. "light" - it has defined "On action": http://192.168.1.7/tools?cmd=GPIO%2C12%2C0 and "Off action": http://192.168.1.7/tools?cmd=GPIO%2C12%2C1
  2. "touch" - without any settings

Next I've defined new "Event" ("Lua", "Device"):

commandArray = {}

if (devicechanged['touch']=='Off') then
    if (otherdevices['light']=='Off') then
--        print ("wlaczam");
        commandArray['light']='On'
    else
--        print ("wylaczam");
        commandArray['light']='Off'
    end
end

return commandArray

Remember to set "Event active" checkbox.

Now I can use both web interface and physical switch to turn on/off the light.

Comments

Log in or create a user account to comment.

Just my blog...

Mon Tue Wed Thu Fri Sat Sun
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31