Wednesday, April 11, 2018

Use Homekit to control Fibaro HCL Z-Wave Dimmer



Home Automation Flow

Siri > Homebridge > Domoticz (LUA) > Fibaro HCL > Aeotec Nano Dimmer

Assume that Homebridge, Domoticz and Fibaro is already setup. The homebridge config.json file should have a room reference to avoid Homekit showing all devices

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:21:3E:E4:DE:33",
        "port": 51826,
        "pin": "031-45-154"
    },
    "description": "Configuration file for (e)xtended Domoticz platform.",
    "platforms": [
        {
            "platform": "eDomoticz",
            "name": "eDomoticz",
            "server": "127.0.0.1",
            "port": "8080",
            "ssl": 0,
            "roomid": 2,
            "mqtt": 1
        }
    ],
    "accessories": [
    ]
}



Step 1. Create a new domoticz virtual device example name "My_Dimmer"

Step 2. Add the virtual device to the Homebridge assigned Room "roomid" that is assigned for devices that Homekit will control.

Step 3: Create a new lua script file with the device name in this folder

/home/pi/domoticz/scripts/lua

The script name is important. For the device with the name "My_Dimmer". create the script "script_device_My_Dimmer.lua"

The whole path is as such.

/home/pi/domoticz/scripts/lua/script_device_My_Dimmer.lua

Insert the following to the script file, replacing user:password and device IDs. Script as follows:


commandArray = {}

DEV='My_Dimmer'

if otherdevices[DEV] == 'Off' then
        os.execute('curl "http://:@:80/api/callAction?deviceID=&name=turnOff"')
else
        Level = otherdevices_svalues[DEV]
=        os.execute('curl "http://user:password@:80/api/callAction?deviceID=&name=setValue&arg1="'..Level)
end

return commandArray



Important Note: name your dimmer My_Dimmer so that the name is consistent in the device and in the script for it to work.


No comments:

Splitting the home network

Who wouldn't want to separate the traffic at home for security reasons. The more common ones include wireless guest and wireless users. ...