I have a bit of complicated setup that consists of 4 different systems.
I want Domoticz to be the master system.
IHC Controller (part of the integrated electrical system of the house)
This system is the one that actually turns of/on lamps, plugs etc. via relays
IHC Captain (software running on RPi)
This software senses changes in the IHC Controller and when lights are turned on/off using physical switches sends an on or off command to update status in Domoticz via JSON ie. wget -qO- 'http://192.168.10.11:8080/json.htm?type ... itchcmd=On' &> /dev/null
OpenHAB (software running on Windows)
This software is used to manipulate the 'IHC Controller' as it has an IHC binding, when turning on/off lights in Domoticz.
Domoticz has the general overview - also used with RFXtrex433 for Somfy blinds.
I have made e LUA scripts that via os.execute calls an REST API on openHAB that again turns on the light in the IHC Controller.
What happens in some cases is it all goes in a loop and the light keeps turning on and off until i disable the LUA script.
The scripts
Code: Select all
commandArray = {}
openHAB_URL = 'http://192.168.10.4:8080/rest/items/'
openHAB_Devicename = 'Light_WalkIn_Loftlampe'
Domoticz_Devicename = 'Walk-in | Loftlampe'
if (devicechanged[''..Domoticz_Devicename..''] == 'On') then
os.execute('curl --header "Content-Type: text/plain" --request POST --data "ON" '..openHAB_URL..''..openHAB_Devicename..' ')
elseif (devicechanged[''..Domoticz_Devicename..''] == 'Off') then
os.execute('curl --header "Content-Type: text/plain" --request POST --data "OFF" '..openHAB_URL..''..openHAB_Devicename..' ')
end
return commandArray
Via the REST I can get a state if the lamps is on or off:
http://192.168.10.4:8080/rest/items/Lig ... ampe/state
I would like to use this state when i turn on/off in Domoticz - if the lamps is off exectue the os.execute command - of the lamps is already on do nothing.
I cannot get my head wrapped around to do this - I'm not a programmer
I've been trying with, but have not had any luck.
Code: Select all
f = assert (io.popen ("curl http://192.168.10.4:8080/rest/items/Light_WalkIn_Loftlampe/state"))
for line in f:lines() do
print(line)
end -- for loop
f:close()
Thanks.
BR Søren