Combining Domoticz and Homecenter 3 (Zwave, QuickApps, FibaroLink)
Posted: Friday 29 January 2021 17:18
Dear all,
Over time, my Z-wave network with domoticz became unstable, and finally caused my Z-wave configuration to crash (Aeotec Z-Stick Gen5 on Raspberry Pi 2 B). All nodes were gone, and I only managed to recover some of them after a week. Probably, as a consequence Domoticz became unstable, and crashed regularly as well.
As an (expensive) solution I bought a Homecenter 3 (HC3) from Fibaro, also anticipating future expansions to come. But more importantly, with the objective to make my curent system more robust (i.e. having a redundant Z-wave controller) and still make use of my LUA scripts in Domoticz as I did not fancy porting them to Fibaro.
I did not find a lot of information on how to do this, but what I have working now hopefully helps other. It is not overly complex, and I hope it might create further ideas on how to improve and better integrate the two systems. Thanks upfront, for any ideas you might have.
Summary of my Domoticz/HC3 setup:
1) Set-up Fibaro HC3
2) Prepare Domoticz
So,
A minute or so later, you should see the Domoticz Aeotec Z-wave stick controller popping up in Fibaro. Unfortunately in my case, the Z-wave device did not fully configure (additional verification in the diagnostics page in HC3 showed the same). In domoticz, I could not see the devices appearing either
Maybe there are other ways, but what worked for me was using the Simplicity Studio tool on my Windows laptop to fix the issue.
I have not yet found a fool-proof way to identify which Z-wave device is which in Z-wave device list. I have the impression not all decimal ID's match the HEX IDs in the node-list. So it was a bit of trial-and-error to get it right. Any tips on how to do this, appreciated!
Congratulations as the most challenging part is done here. You can control both your Z-wave devices from both Domoticz and Homecenter 3
3) Controlling HC3 devices from within Domoticz
Z-Wave is done now, but wouldn't it be nice, if other devices could communicate to HC3 as well. For this I used the FibaroLink option which is present in Domoticz. On different fora I read one can update a "global variable" in Homecenter, but it does not trigger a Scene in Fibaro. (Lite and HC2). I tested, and can confirm that for me it works in HC3. If I change a global variable with Domoticz, it can trigger a scene in HC3.
And in Fibaro, in the Scenes section, you can use this variable as a trigger:
That's it concerning linking Domoticz to Fibaro.
4) Controlling Domoticz devices from within HomeCenter 3
Last part, controlling Domoticz from HC3. For this I used the QuickApp functionality which is newly introduced in HC3. In the devices section in HC3, in 'other', you can add a QuickApp. I used the 'Binary Switch" for starters, but maybe something else is more suitable.
Also the functionality below is still very basic, and looking forward to other idea's this might give to you.
In the "Edit&Preview" section of your QuickApp. Click om Edit. This brings you the Builder. On the left hand side you can define the Buttons for your QuickApp (QA) on the right hand side the LUA Code having the objects for each button.
I created a button Called "Bark" and in domoticz this command plays an mp3 of a barking dog on my Sonos system. Make sure that in the button you call your function. In my case "barkOn" [no need for ()].
Copy / Paste the below LUA script into your QA:
Save your QA and it is now ready to be used in Scenes. Going forward I intend to add more buttons to the QuickApp, allowing only one Device to activate multiple device in Domoticz by using multiple buttons.
In a Scene you can activate the Button as follows:
As said in the beginning, I really hope this helps others, but most of all inspires to further ideas to improve.
On my wish-list today:
Over time, my Z-wave network with domoticz became unstable, and finally caused my Z-wave configuration to crash (Aeotec Z-Stick Gen5 on Raspberry Pi 2 B). All nodes were gone, and I only managed to recover some of them after a week. Probably, as a consequence Domoticz became unstable, and crashed regularly as well.
As an (expensive) solution I bought a Homecenter 3 (HC3) from Fibaro, also anticipating future expansions to come. But more importantly, with the objective to make my curent system more robust (i.e. having a redundant Z-wave controller) and still make use of my LUA scripts in Domoticz as I did not fancy porting them to Fibaro.
I did not find a lot of information on how to do this, but what I have working now hopefully helps other. It is not overly complex, and I hope it might create further ideas on how to improve and better integrate the two systems. Thanks upfront, for any ideas you might have.
Summary of my Domoticz/HC3 setup:
- Fibaro HC3 is the primary Zwave controller
- Domoticz with an Aeotec Z-wave Stick Gen5 works as a secondary controller
- Other devices share their status using FibaroLink through global variables in Fibaro
- A simple "QuickApp" is used to control Domoticz (non Z-wave) devices from within Fibaro
1) Set-up Fibaro HC3
- Set-up all the basic stuff in your HC3 configuration
- Add all Z-wave devices you want to include to the Devices / Z-wave section
- Test if all your Z-wave devices are working properly from HC3
2) Prepare Domoticz
- If you used your Z-wave stick outside the Raspberry Pi, time to put it back in domoticz, and activate the hardware
- Make a back-up just in case, always good practice
- In the hardware management page go to the settings of your Z-wave controller
- In the Node-management menu choose "Controller Hard reset" or whatever it is called in English
- This should bring back your Z-wave stick to it's factory settings
- Go to the Devices menu, filter on Z-Wave and delete ALL Z-wave devices you have
- Open a command shell window and stop domoticz from running (and monit first if you use it). [sudo service domoticz stop]
- Remove the open zwave cache file from the Config directory [sudo rm ~/domoticz/Config/ozwcache* ]
- Restart domoticz by rebooting or restarting the service
So,
- Set the Fibaro HC3 into learning mode (Devices / Zwave / Add devices with the + icon)
- In the Z-Wave settings page (Hardware section), in the Node management menu select: "Receive configuration from other controller"
A minute or so later, you should see the Domoticz Aeotec Z-wave stick controller popping up in Fibaro. Unfortunately in my case, the Z-wave device did not fully configure (additional verification in the diagnostics page in HC3 showed the same). In domoticz, I could not see the devices appearing either
Maybe there are other ways, but what worked for me was using the Simplicity Studio tool on my Windows laptop to fix the issue.
- Download the software, I found it through here: https://aeotec.freshdesk.com/support/so ... -download-
- De-activate Z-wave hardware in Domoticz, and move the stick to your Windows computer
- Start the Simplicity Studio 5 software, and in the Tools menu, you can find the "PC Z-wave controller" module. I found it difficult to find, in settings select the right COM port ofcourse.
- In this tool I could see that all my nodes where somehow present in the stick and that Domoticz was indeed a secondary controller. In the summary section, I saw the message 32 nodes.
- Next, in the Fibaro HC3, I selected "re-configure" device, whilst my stick was still in the lap-top
- This did the trick (I believe) and I got the green checkmarks, and "Z-wave fully configured" in the Diagnostics page.
- As a finishing touch, I added the Domoticz icon to my controller
- Time to move the stick back to Domoticz and activate the hardware again
- About 10 min. later I could see the node list in the Hardware section, and over a 100 Z-wave devices were added to the device list
I have not yet found a fool-proof way to identify which Z-wave device is which in Z-wave device list. I have the impression not all decimal ID's match the HEX IDs in the node-list. So it was a bit of trial-and-error to get it right. Any tips on how to do this, appreciated!
Congratulations as the most challenging part is done here. You can control both your Z-wave devices from both Domoticz and Homecenter 3
3) Controlling HC3 devices from within Domoticz
Z-Wave is done now, but wouldn't it be nice, if other devices could communicate to HC3 as well. For this I used the FibaroLink option which is present in Domoticz. On different fora I read one can update a "global variable" in Homecenter, but it does not trigger a Scene in Fibaro. (Lite and HC2). I tested, and can confirm that for me it works in HC3. If I change a global variable with Domoticz, it can trigger a scene in HC3.
- Create a "Global Variable" in Homecenter [General/variables]. I created the variable alarm_breached
- In Domoticz, link your Domoticz Device to this variable, see below:
And in Fibaro, in the Scenes section, you can use this variable as a trigger:
That's it concerning linking Domoticz to Fibaro.
4) Controlling Domoticz devices from within HomeCenter 3
Last part, controlling Domoticz from HC3. For this I used the QuickApp functionality which is newly introduced in HC3. In the devices section in HC3, in 'other', you can add a QuickApp. I used the 'Binary Switch" for starters, but maybe something else is more suitable.
Also the functionality below is still very basic, and looking forward to other idea's this might give to you.
In the "Edit&Preview" section of your QuickApp. Click om Edit. This brings you the Builder. On the left hand side you can define the Buttons for your QuickApp (QA) on the right hand side the LUA Code having the objects for each button.
I created a button Called "Bark" and in domoticz this command plays an mp3 of a barking dog on my Sonos system. Make sure that in the button you call your function. In my case "barkOn" [no need for ()].
Copy / Paste the below LUA script into your QA:
Code: Select all
--
-- Domoticz interface using buttons v1.1
-- This LUA code makes a call to a Domoticz button, triggering an action in Domoticz
-- 2021-01-25 : A first version, proof of principle experimenting with LUA
-- 2021-01-26 : Script clean-up
--
-- Binary switch type should handle actions turnOn, turnOff
-- To update binary switch state, update property "value" with boolean
local domoticz_ip = "192.168.178.55:8080"
local bark_idx = 601
function QuickApp:turnOn()
self:debug("Barking dog turned on")
self:updateProperty("value", true)
-- fibaro.call (self.id, "fcCommands", "On")
end
--
-- TurnOff not used in this script.
--
function QuickApp:turnOff()
self:debug("Barking dog turned off")
self:updateProperty("value", false)
-- fibaro.call (self.id, "fcCommands", "Off")
end
--
-- Function that corresponds to "Bark" button
--
function QuickApp:barkOn()
self:debug("Barking dog turned on in Domoticz")
self:updateProperty("value", true)
fibaro.call (self.id, "fcCommands", bark_idx, "On")
end
--
-- Concept of QuickApp use found here: https://forum.fibaro.com/topic/51076-url-commands-to-domoticz-hc3/
--
function QuickApp: fcCommands(idx, cmd)
--
-- URL To be used: http://192.168.178.55:8080/json.htm?type=command¶m=switchlight&idx=601&switchcmd=On&level=0&passcode=
--
local address = "http://" ..domoticz_ip.. "/json.htm?type=command¶m=switchlight&idx=" ..idx.. "&switchcmd=" ..cmd .."&level=0&passcode="
self:debug("Calling http request")
self.http:request(address, {
options={
headers = {
Accept = "application/json"
},
checkCertificate = true,
method = 'GET'
},
success = function(response)
self:debug("response status:", response.status)
self:debug("headers:", response.headers["Content-Type"])
local data = json.decode(response.data)
end,
error = function(error)
self:debug('error: ' .. json.encode(error))
end
})
end
function QuickApp:onInit()
self:debug("onInit")
self.http = net.HTTPClient({timeout=3000})
end
-- This is QuickApp initial method. It is called right after your QuickApp starts (after each save or on gateway startup).
-- Here you can set some default values, setup http connection or get QuickApp variables.
-- To learn more, please visit:
-- * https://manuals.fibaro.com/home-center-3/
-- * https://manuals.fibaro.com/home-center-3-quick-apps/
In a Scene you can activate the Button as follows:
As said in the beginning, I really hope this helps others, but most of all inspires to further ideas to improve.
On my wish-list today:
- Keep on using Domoticz for all my scripts and timers, as it has better random and sunset/rise functions. However, if for whatever reason Domoticz crashes, let Fibaro take over. For this I want to use the Profile feature. e.g. Create a profile "Domoticz down" which turns on a number of Scenes in Fibaro.