With Domoticz you will have multiple devices that need to be aligned, for example your remote and your light bulb, especially if you use 433 MHz devices. I migrated from my Homewizard to Domoticz and I have a lot of 433 MHz switches and sensors which I have reused. I even still have my Homewizard (to get the data from the temperature and rain sensors and the solar panels, power and water usage. With a lot of my 433 MHz devices, they can respond to a number of codes (most I believe can accept 4) but in my Domoticz screens, I want to know the real status of for example a light bulb.
Let’s elaborate with an example. I have a lamp near my TV and my Homewizard can turn it on and off by sending a code. I have captured that code on my Domoticz and that same code is in my system for the status of the lamp. So far, so good. I also have a remote which I use to turn on this light. It has a different code and in my Domoticz it is logged as remote X, button 1-1 for example. If I press the button on the remote, in Domoticz I can see that button pressed but the light is not on according to Domoticz. This is where my script comes in. It’s a script that aligns devices, so in this case “Lamp TV” and “Remote X, 1-1”.
This is the LUA code and it’s triggered for every device change:
-- -- Match devices event -- -- Match the status of 2 devices. Match both directions or just left -- to right or right to left -- commandArray = {} function matchStatus (fromD, toD, dirD) for deviceName,deviceValue in pairs(devicechanged) do -- -- if the changed device is the left device and the direction -- is either B(oth) or L(eft only) then align them -- if (deviceName==fromD and (dirD=="B" or dirD=="L")) then -- -- Only change if the device value is different -- if (otherdevices[toD]~=deviceValue) then commandArray[toD] = deviceValue print("MATCH:"..fromD.." ("..deviceValue..") to "..toD) end -- -- if the changed device is the right device and the direction -- is either B(oth) or R(ight only) then align them -- elseif (deviceName==toD and (dirD=="B" or dirD=="R")) then -- -- Only change if the device value is different -- if (otherdevices[fromD]~=deviceValue) then commandArray[fromD] = deviceValue print("MATCH:"..toD.." ("..deviceValue..") to "..fromD) end end end end -- -- B both sides should match -- L left side copies to right side only -- R right side copies to left side only -- matchStatus("Lamp TV","Remote X, 1-1","B") return commandArray
It’s not rocket science but might fill the need for someone else. Feel free to use and adapt it. If you come up with a good addition, please let me know.