Skip to content

Latest commit

 

History

History
71 lines (51 loc) · 29.9 KB

HomeAssistant.md

File metadata and controls

71 lines (51 loc) · 29.9 KB

Home Assistant can be installed in docker on the UCM-Pi. There is not enough capacity on a CM3, so a CM3+ with 32Gb of storage is highly recommended

First, ssh into the UCM-Pi after following the general install process, and run the following

curl -sSL https://get.docker.com | sh
sudo usermod -aG docker pi
mkdir ~/alphawerk/homeassistant

Now, download and create a docker container to run Home-Assistant within. If you don't want to use ZWave with Home-Assistant, the following command will create a container which will automatically restart upon boot, store all the configuration data in ~/alphawerk/homeassistant and use the local time of the Pi.

sudo docker run --init -d --restart=unless-stopped --name="home-assistant"  -v /home/pi/alphawerk/homeassistant:/config -v /etc/timezone:/etc/timezone --net=host homeassistant/raspberrypi3-homeassistant:stable

The following also redirects the Z-Wave device to homne assitant if you wish to use a Z-Wave usb controlled from within Home-Assistant (Please note the name of the device may not be that of your USB adapter)

sudo docker run --init -d --restart=unless-stopped --name="home-assistant" -v /home/pi/alphawerk/homeassistant:/config -v /etc/timezone:/etc/timezone --device=/dev/zwave --net=host homeassistant/raspberrypi3-homeassistant:stable

If you wish to share device status and control between Home-Assistant and Comfort you will also need to do the following:

  1. Install the MQTT adapter in Home-Assistant, referencing the local MQTT server (127.0.0.1) and enable discovery. (Username and Password is not necessary as it is limited to localhost only).
  2. Cope and Paste the flow below into a new flow in Node-Red.
[{"id":"69f018dc.1a17c8","type":"tab","label":"Home-Assistant","disabled":false,"info":""},{"id":"cd5ff647.0f1e28","type":"function","z":"69f018dc.1a17c8","name":"Zones & Output Iterator","func":"// send index for zones and outputs\n\nfor (x=1; x<97; x++) {\n    msg={payload:{id:x}};\n    node.send(msg);\n}","outputs":1,"noerr":0,"x":450,"y":80,"wires":[["d5db8bab.0934e8","4364f6c.c249308"]]},{"id":"43355e7d.a2aac","type":"function","z":"69f018dc.1a17c8","name":"Flag Iterator","func":"// send index for flags\n\nfor (x=1; x<255; x++) {\n    msg={payload:{id:x}};\n    node.send(msg);\n}","outputs":1,"noerr":0,"x":410,"y":120,"wires":[["d1eff687.664ec8"]]},{"id":"c016e904.f48028","type":"function","z":"69f018dc.1a17c8","name":"Counter Iterator","func":"// send index for flags\n\nfor (x=0; x<255; x++) {\n    msg={payload:{id:x}};\n    node.send(msg);\n}","outputs":1,"noerr":0,"x":420,"y":160,"wires":[["9e7fb03c.a307f"]]},{"id":"b9c589a3.066928","type":"function","z":"69f018dc.1a17c8","name":"Sensor Iterator","func":"// send index for flags\n\nfor (x=0; x<32; x++) {\n    msg={payload:{id:x}};\n    node.send(msg);\n}","outputs":1,"noerr":0,"x":420,"y":200,"wires":[["64e609cb.a18288"]]},{"id":"d1eff687.664ec8","type":"cytech flag event","z":"69f018dc.1a17c8","name":"Flags","flag":"*","trigger":false,"setvalue":false,"setvalueparam":"payload","inputtype":"passive","activewait":"30","outputtype":"detailed","outputsimplifiedvalue":"boolean","outputsimplifiedkey":"payload","x":650,"y":120,"wires":[["24214a33.27d016","943bbd72.411ee"]]},{"id":"84413287.0dc8a","type":"inject","z":"69f018dc.1a17c8","name":"Full Discovery","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":40,"wires":[["c016e904.f48028","cd5ff647.0f1e28","43355e7d.a2aac","b9c589a3.066928"]]},{"id":"9e7fb03c.a307f","type":"cytech counter event","z":"69f018dc.1a17c8","name":"Counters","counter":"*","trigger":false,"setvalue":false,"setvalueparam":"payload","inputtype":"passive","activewait":5,"outputtype":"detailed","outputsimplifiedkey":"payload","x":660,"y":160,"wires":[["dc3750c9.715d8","86dcccdf.0e835"]]},{"id":"64e609cb.a18288","type":"cytech sensor event","z":"69f018dc.1a17c8","name":"Sensors","sensor":"*","trigger":false,"setvalue":false,"setvalueparam":"payload","inputtype":"passive","activewait":5,"outputtype":"detailed","outputsimplifiedkey":"payload","x":660,"y":200,"wires":[["6f62032f.79699c","568552d5.629a7c"]]},{"id":"d5db8bab.0934e8","type":"cytech zone event","z":"69f018dc.1a17c8","name":"Zones","zone":"*","event":"*","trigger":false,"setvirtualinput":false,"setvirtualinputparam":"payload.value","setbypass":false,"setbypassparam":"payload.bypass","inputtype":"passive","activewait":5,"outputtype":"detailed","outputsimplifiedvalue":"boolean","outputsimplifiedkey":"payload","x":650,"y":40,"wires":[["ab0d5045.66432","10de6564.c92f7b"]]},{"id":"4364f6c.c249308","type":"cytech output event","z":"69f018dc.1a17c8","name":"Outputs","output":"*","trigger":false,"setvalue":false,"setvalueparam":"payload","inputtype":"passive","activewait":5,"outputtype":"detailed","outputsimplifiedvalue":"boolean","outputsimplifiedkey":"payload","x":660,"y":80,"wires":[["e133fcfd.fabd6","f5165dfb.ab55e"]]},{"id":"ab0d5045.66432","type":"function","z":"69f018dc.1a17c8","name":"Zone Discovery","func":"var data\n\nif (msg.payload.hasOwnProperty('event')) {\n    data = msg.payload.event;\n} else if (msg.payload.hasOwnProperty('status')) {\n    data = msg.payload.status;\n} else {\n    node.log(\"Invalid message received \" + JSON.parse(msg))\n    return msg;\n}\n\nvar device_class = \"none\";\nif (data.zone.zonetypename!==\"\") {    \n    switch (data.zone.zonetypename) {\n        case \"DoorWindow\":\n        case \"EntryDoor\":\n            device_class = \"door\";\n            break;\n        case \"PIRNightAway\":\n        case \"PIRAway\":\n        case \"PerimNightAway\":\n        case \"PerimAway\":\n            device_class = \"motion\";\n            break;\n        case \"AlertVibration\":\n        case \"ArmedVibration\":\n        case \"24HrVibration\":\n        case \"VibrArmed\":\n        case \"VibrAwayNigh\":\n        case \"VibrAway\":\n            device_class = \"vibration\";\n            break;\n        case \"FireNO\":\n        case \"FireNC\":\n            device_class = \"smoke\";\n            break;\n        case \"GasNC\":\n        case \"GasNO\":\n            device_class = \"gas\";\n            break;\n        case \"ArmedTamper\":\n        case \"24HrTamper\":\n            device_class = \"problem\";\n            break;\n        case \"DoorBell\":\n            device_class = \"sound\";\n    } \n    \n    var topic = \"homeassistant/binary_sensor/comfort/\" + data.type + \"_\" + data.index + \"_value/config\"\n    var payload = {\n        name: data[data.type].name,\n        device_class: device_class,\n        state_topic: \"homeassistant/binary_sensor/comfort/\" + data.type + \"_\" + data.index + \"_value/state\",\n        payload_on : \"1\",\n        payload_off : \"0\"\n    }\n    \n    msg.topic = topic;\n    msg.payload = payload;\n    node.send(msg);\n    \n    if (data.zone.virtualinput == \"true\") {\n        var topic = \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_value/config\"\n        var payload = {\n            name: data[data.type].name,\n            //device_class: \"motion\",\n            state_topic: \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_value/state\",\n            command_topic: \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_value/set\",\n            state_on : \"1\",\n            state_off : \"0\"\n        }\n    \n        msg.topic = topic;\n        msg.payload = payload;\n        node.send(msg);\n    \n    }\n    \n     var topic = \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_\" + \"bypass\" + \"/config\"\n        var payload = {\n            name: data[data.type].name + \" bypass\",\n            //device_class: \"motion\",\n            state_topic: \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_bypass/state\",\n            command_topic: \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_bypass/set\",\n            state_on : \"1\",\n            state_off : \"0\"\n        }\n    \n        msg.topic = topic;\n        msg.payload = payload;\n        node.send(msg);\n}\nreturn;\n","outputs":1,"noerr":0,"x":840,"y":40,"wires":[["d73e4e04.6f18"]]},{"id":"e133fcfd.fabd6","type":"function","z":"69f018dc.1a17c8","name":"Output Discovery","func":"var data\n\nif (msg.payload.hasOwnProperty('event')) {\n    data = msg.payload.event;\n} else if (msg.payload.hasOwnProperty('status')) {\n    data = msg.payload.status;\n} else {\n    node.log(\"Invalid message received \" + JSON.parse(msg))\n    return msg;\n}\nif (!data[data.type].name.startsWith(\"Output\")) {\n    var topic = \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/config\"\n    var payload = {\n        name: data[data.type].name,\n        state_topic: \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/state\",\n        command_topic: \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/set\",\n        state_on : \"1\",\n        state_off : \"0\"\n    }\n    msg.topic = topic;\n    msg.payload = payload;\n    return msg;\n}\n","outputs":1,"noerr":0,"x":850,"y":80,"wires":[["d73e4e04.6f18"]]},{"id":"dc3750c9.715d8","type":"function","z":"69f018dc.1a17c8","name":"Counter Discovery","func":"var data\n\nif (msg.payload.hasOwnProperty('event')) {\n    data = msg.payload.event;\n} else if (msg.payload.hasOwnProperty('status')) {\n    data = msg.payload.status;\n} else {\n    node.log(\"Invalid message received \" + JSON.parse(msg))\n    return msg;\n}\nif (!data[data.type].name.startsWith(\"Counter\")) {\n    var topic = \"homeassistant/sensor/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/config\"\n    var payload = {\n        name: data[data.type].name,\n        //device_class: \"motion\",\n        state_topic: \"homeassistant/sensor/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/state\",\n        command_topic: \"homeassistant/sensor/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/set\",\n        //state_on: \"1\",\n        //state_off: \"0\"\n    }\n    \n    msg.topic = topic;\n    msg.payload = payload;\n    return msg;\n} else {\n    node.error(data[data.type].name + \" not in \");\n}","outputs":1,"noerr":0,"x":850,"y":160,"wires":[["d73e4e04.6f18"]]},{"id":"24214a33.27d016","type":"function","z":"69f018dc.1a17c8","name":"Flag Discovery","func":"var data\n\nif (msg.payload.hasOwnProperty('event')) {\n    data = msg.payload.event;\n} else if (msg.payload.hasOwnProperty('status')) {\n    data = msg.payload.status;\n} else {\n    node.log(\"Invalid message received \" + JSON.parse(msg))\n    return msg;\n}\nif (!data[data.type].name.startsWith(\"Flag\")) {\n    var topic = \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/config\"\n    var payload = {\n        name: data[data.type].name,\n        state_topic: \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/state\",\n        command_topic: \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/set\",\n        state_on : \"1\",\n        state_off : \"0\"\n    }\n    msg.topic = topic;\n    msg.payload = payload;\n    return msg;\n}\n","outputs":1,"noerr":0,"x":840,"y":120,"wires":[["d73e4e04.6f18"]]},{"id":"6f62032f.79699c","type":"function","z":"69f018dc.1a17c8","name":"Sensor Discovery","func":"var data\n\nif (msg.payload.hasOwnProperty('event')) {\n    data = msg.payload.event;\n} else if (msg.payload.hasOwnProperty('status')) {\n    data = msg.payload.status;\n} else {\n    node.log(\"Invalid message received \" + JSON.parse(msg))\n    return msg;\n}\nif (!data[data.type].name.startsWith(\"Sensor\")) {\n    var topic = \"homeassistant/sensor/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/config\"\n    var payload = {\n        name: data[data.type].name,\n        //device_class: \"motion\",\n        state_topic: \"homeassistant/sensor/comfort/\" + data.type + \"_\" +  data.index + \"_\" + data.element + \"/state\",\n        command_topic: \"homeassistant/sensor/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/set\",\n        //state_on: \"1\",\n        //state_off: \"0\"\n    }\n    \n    msg.topic = topic;\n    msg.payload = payload;\n    return msg;\n}","outputs":1,"noerr":0,"x":850,"y":200,"wires":[["d73e4e04.6f18"]]},{"id":"8f21a7c0.dabdc8","type":"inject","z":"69f018dc.1a17c8","name":"Clear All Discovery","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":260,"wires":[["c0df816a.230b7","b9719024.c9609","10652ed4.85a191","6dc1fb8a.3c61e4"]]},{"id":"c0df816a.230b7","type":"function","z":"69f018dc.1a17c8","name":"Zones & Output Cleaner","func":"// send index for zones and outputs\n\nfor (x=1; x<97; x++) {\n    msg={topic:\"homeassistant/binary_sensor/comfort/zone_\" + x + \"_value/config\", payload:\"\"};\n    node.send(msg);\n    msg={topic:\"homeassistant/switch/comfort/zone_\" + x + \"_value/config\", payload:\"\"};\n    node.send(msg);\n    msg={topic:\"homeassistant/switch/comfort/zone_\" + x + \"_bypass/config\", payload:\"\"};\n    node.send(msg);\n    msg={topic:\"homeassistant/switch/comfort/output_\" + x + \"_value/config\", payload:\"\"};\n    node.send(msg);\n}","outputs":1,"noerr":0,"x":450,"y":300,"wires":[["d73e4e04.6f18"]]},{"id":"b9719024.c9609","type":"function","z":"69f018dc.1a17c8","name":"Flag Cleaner","func":"// send index for flags\n\nfor (x=1; x<255; x++) {\n    msg={topic:\"homeassistant/switch/comfort/flag_\" + x + \"_value/config\", payload:\"\"};\n    node.send(msg);\n}","outputs":1,"noerr":0,"x":410,"y":340,"wires":[["d73e4e04.6f18"]]},{"id":"10652ed4.85a191","type":"function","z":"69f018dc.1a17c8","name":"Counter Cleaner","func":"// send index for flags\n\nfor (x=0; x<255; x++) {\n    msg={topic:\"homeassistant/sensor/comfort/counter_\" + x + \"_value/config\", payload:\"\"};\n    node.send(msg);\n    msg={topic:\"homeassistant/sensor/comfort/counter_\" + x + \"_value/state\", payload:\"\"};\n    node.send(msg);\n}","outputs":1,"noerr":0,"x":420,"y":380,"wires":[["d73e4e04.6f18"]]},{"id":"6dc1fb8a.3c61e4","type":"function","z":"69f018dc.1a17c8","name":"Sensor Cleaner","func":"// send index for flags\n\nfor (x=0; x<32; x++) {\n    msg={topic:\"homeassistant/sensor/comfort/sensor_\" + x + \"_value/config\", payload:\"\"};\n    node.send(msg);\n}","outputs":1,"noerr":0,"x":420,"y":420,"wires":[["d73e4e04.6f18"]]},{"id":"d73e4e04.6f18","type":"mqtt out","z":"69f018dc.1a17c8","name":"Discovery MQTT","topic":"","qos":"","retain":"true","broker":"7967aff2.430ca","x":850,"y":360,"wires":[]},{"id":"86dcccdf.0e835","type":"function","z":"69f018dc.1a17c8","name":"Counter Event","func":"var data\n\nif (msg.payload.hasOwnProperty('event')) {\n    data = msg.payload.event;\n} else if (msg.payload.hasOwnProperty('status')) {\n    data = msg.payload.status;\n} else {\n    node.log(\"Invalid message received \" + JSON.parse(msg))\n    return msg;\n}\nvar topic = \"homeassistant/sensor/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/state\"\nvar payload = data.value;\n\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":640,"wires":[["fc965093.fd779"]]},{"id":"17605e8e.3e6551","type":"cytech counter event","z":"69f018dc.1a17c8","name":"Counter Event","counter":"*","trigger":true,"setvalue":false,"setvalueparam":"payload","inputtype":"passive","activewait":5,"outputtype":"detailed","outputsimplifiedkey":"payload","x":120,"y":640,"wires":[["86dcccdf.0e835"]]},{"id":"fc965093.fd779","type":"mqtt out","z":"69f018dc.1a17c8","name":"Update MQTT","topic":"","qos":"","retain":"true","broker":"7967aff2.430ca","x":840,"y":600,"wires":[]},{"id":"e724196.2c64ce8","type":"inject","z":"69f018dc.1a17c8","name":"Zone & Output Discovery","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":80,"wires":[["cd5ff647.0f1e28"]]},{"id":"9506357d.a497c8","type":"inject","z":"69f018dc.1a17c8","name":"Flag Discovery","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":120,"wires":[["43355e7d.a2aac"]]},{"id":"4d44138e.5c877c","type":"inject","z":"69f018dc.1a17c8","name":"Counter Discovery","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":160,"wires":[["c016e904.f48028"]]},{"id":"8e6b5afc.072848","type":"inject","z":"69f018dc.1a17c8","name":"Sensor Discovery","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":200,"wires":[["b9c589a3.066928"]]},{"id":"12bacd3a.dddd23","type":"inject","z":"69f018dc.1a17c8","name":"Clear Zone & Output Discovery","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":300,"wires":[["c0df816a.230b7"]]},{"id":"ba8f135d.a91c5","type":"inject","z":"69f018dc.1a17c8","name":"Clear Flag Discovery","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":340,"wires":[["b9719024.c9609"]]},{"id":"9da1b94a.d755b8","type":"inject","z":"69f018dc.1a17c8","name":"Clear Counter Discovery","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":380,"wires":[["10652ed4.85a191"]]},{"id":"849f3c8d.5d8ab","type":"inject","z":"69f018dc.1a17c8","name":"Clear Sensor Discovery","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":420,"wires":[["6dc1fb8a.3c61e4"]]},{"id":"10de6564.c92f7b","type":"function","z":"69f018dc.1a17c8","name":"Zone Event","func":"var data\n\nif (msg.payload.hasOwnProperty('event')) {\n    data = msg.payload.event;\n} else if (msg.payload.hasOwnProperty('status')) {\n    data = msg.payload.status;\n} else {\n    node.log(\"Invalid message received \" + JSON.parse(msg))\n    return msg;\n}\n\nvar topic = \"homeassistant/binary_sensor/comfort/\" + data.type + \"_\" +  data.index + \"_\" + data.element + \"/state\"\nvar payload = data.value;\nmsg.topic = topic;\nmsg.payload = payload;\nnode.send(msg);\n\nif ((data.zone.virtualinput==\"true\") && (data.element == \"value\")) {\n    var topic = \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/state\"\n    var payload = data.value;\n    msg.topic = topic;\n    msg.payload = payload;\n    node.send(msg);  \n}\n\n","outputs":1,"noerr":0,"x":410,"y":520,"wires":[["fc965093.fd779"]]},{"id":"f5165dfb.ab55e","type":"function","z":"69f018dc.1a17c8","name":"Output Event","func":"var data\n\nif (msg.payload.hasOwnProperty('event')) {\n    data = msg.payload.event;\n} else if (msg.payload.hasOwnProperty('status')) {\n    data = msg.payload.status;\n} else {\n    node.log(\"Invalid message received \" + JSON.parse(msg))\n    return msg;\n}\n\nvar topic = \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/state\"\nvar payload = data.value;\nmsg.topic = topic;\nmsg.payload = payload;\nnode.send(msg);\n","outputs":1,"noerr":0,"x":410,"y":560,"wires":[["fc965093.fd779"]]},{"id":"943bbd72.411ee","type":"function","z":"69f018dc.1a17c8","name":"Flag Event","func":"var data\n\nif (msg.payload.hasOwnProperty('event')) {\n    data = msg.payload.event;\n} else if (msg.payload.hasOwnProperty('status')) {\n    data = msg.payload.status;\n} else {\n    node.log(\"Invalid message received \" + JSON.parse(msg))\n    return msg;\n}\n\nvar topic = \"homeassistant/switch/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/state\"\nvar payload = data.value;\nmsg.topic = topic;\nmsg.payload = payload;\nnode.send(msg);\n","outputs":1,"noerr":0,"x":410,"y":600,"wires":[["fc965093.fd779"]]},{"id":"568552d5.629a7c","type":"function","z":"69f018dc.1a17c8","name":"Sensor Event","func":"var data\n\nif (msg.payload.hasOwnProperty('event')) {\n    data = msg.payload.event;\n} else if (msg.payload.hasOwnProperty('status')) {\n    data = msg.payload.status;\n} else {\n    node.log(\"Invalid message received \" + JSON.parse(msg))\n    return msg;\n}\nvar topic = \"homeassistant/sensor/comfort/\" + data.type + \"_\" + data.index + \"_\" + data.element + \"/state\"\nvar payload = data.value;\n\nmsg.topic = topic;\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":680,"wires":[["fc965093.fd779"]]},{"id":"186e5f4d.9494d1","type":"cytech sensor event","z":"69f018dc.1a17c8","name":"Sensor Event","sensor":"*","trigger":true,"setvalue":false,"setvalueparam":"payload","inputtype":"passive","activewait":5,"outputtype":"detailed","outputsimplifiedkey":"payload","x":120,"y":680,"wires":[["568552d5.629a7c"]]},{"id":"d3472cdd.fbcd1","type":"cytech flag event","z":"69f018dc.1a17c8","name":"Flag Event","flag":"*","trigger":true,"setvalue":false,"setvalueparam":"payload","inputtype":"passive","activewait":5,"outputtype":"detailed","outputsimplifiedvalue":"boolean","outputsimplifiedkey":"payload","x":110,"y":600,"wires":[["943bbd72.411ee"]]},{"id":"12dddcd6.99ce23","type":"cytech output event","z":"69f018dc.1a17c8","name":"Output Event","output":"*","trigger":true,"setvalue":false,"setvalueparam":"payload","inputtype":"passive","activewait":5,"outputtype":"detailed","outputsimplifiedvalue":"boolean","outputsimplifiedkey":"payload","x":110,"y":560,"wires":[["f5165dfb.ab55e"]]},{"id":"48cae14.343e42","type":"cytech zone event","z":"69f018dc.1a17c8","name":"Zone Event","zone":"*","event":"*","trigger":true,"setvirtualinput":false,"setvirtualinputparam":"payload.value","setbypass":false,"setbypassparam":"payload.bypass","inputtype":"passive","activewait":5,"outputtype":"detailed","outputsimplifiedvalue":"boolean","outputsimplifiedkey":"payload","x":110,"y":520,"wires":[["10de6564.c92f7b"]]},{"id":"868bedb9.bcc36","type":"mqtt in","z":"69f018dc.1a17c8","name":"","topic":"homeassistant/+/comfort/+/set","qos":"2","broker":"7967aff2.430ca","x":170,"y":820,"wires":[["137c8ec4.125131"]]},{"id":"137c8ec4.125131","type":"function","z":"69f018dc.1a17c8","name":"Set Event","func":"var type = msg.topic.split(\"/\")[3].split(\"_\")[0];\nvar index = msg.topic.split(\"/\")[3].split(\"_\")[1];\nvar element = msg.topic.split(\"/\")[3].split(\"_\")[2];\nvar value = msg.payload;\n\nswitch (type) {\n    case \"zone\":\n        switch (value) {\n            case \"ON\":\n            case 1:\n            case \"1\":\n                msg = {payload:{id:index}};\n                msg.payload[element] = 1;\n                node.send(msg);\n                break;\n            case \"OFF\":\n            case 0:\n            case \"0\":\n                msg = {payload:{id:index}};\n                msg.payload[element] = 0;\n                node.send(msg);\n                break;\n            default:\n                node.warn(\"Unexpected value from MQTT\");\n        }    \n        break;\n    case \"output\":\n        switch (value) {\n            case \"ON\":\n            case 1:\n            case \"1\":\n                msg = {payload:{id:index, value:1}};\n                node.send([null, msg]);\n                break;\n            case \"OFF\":\n            case 0:\n            case \"0\":\n                msg = {payload:{id:index, value:0}};\n                node.send([null, msg]);\n                break;\n            default:\n                node.warn(\"Unexpected value from MQTT\");  \n        }\n        break;\n    case \"flag\":\n        switch (value) {\n            case \"ON\":\n            case 1:\n            case \"1\":\n                msg = {payload:{id:index, value:1}};\n                node.send([null, null, msg]);\n                break;\n            case \"OFF\":\n            case 0:\n            case \"0\":\n                msg = {payload:{id:index, value:0}};\n                node.send([null, null, msg]);\n                break;\n            default:\n                node.warn(\"Unexpected value from MQTT\");\n        }\n        break;\n    case \"counter\":\n        msg = {payload:{id:index, value:value}};\n        node.send([null,null, null, msg]);\n        break;   \n}\n\n","outputs":4,"noerr":0,"x":400,"y":820,"wires":[["61271525.54660c"],["44174870.f908c8"],["7dfd5f20.2ff91"],["2e146a30.ceaee6"]]},{"id":"61271525.54660c","type":"cytech zone event","z":"69f018dc.1a17c8","name":"Zones","zone":"*","event":"*","trigger":false,"setvirtualinput":true,"setvirtualinputparam":"payload.value","setbypass":true,"setbypassparam":"payload.bypass","inputtype":"passive","activewait":5,"outputtype":"detailed","outputsimplifiedvalue":"boolean","outputsimplifiedkey":"payload","x":650,"y":760,"wires":[["2d943211.25a85e"]]},{"id":"44174870.f908c8","type":"cytech output event","z":"69f018dc.1a17c8","name":"Outputs","output":"*","trigger":false,"setvalue":true,"setvalueparam":"payload.value","inputtype":"passive","activewait":5,"outputtype":"detailed","outputsimplifiedvalue":"boolean","outputsimplifiedkey":"payload","x":660,"y":800,"wires":[[]]},{"id":"7dfd5f20.2ff91","type":"cytech flag event","z":"69f018dc.1a17c8","name":"Flags","flag":"*","trigger":false,"setvalue":true,"setvalueparam":"payload.value","inputtype":"passive","activewait":"30","outputtype":"detailed","outputsimplifiedvalue":"boolean","outputsimplifiedkey":"payload","x":650,"y":840,"wires":[[]]},{"id":"2e146a30.ceaee6","type":"cytech counter event","z":"69f018dc.1a17c8","name":"Counters","counter":"*","trigger":false,"setvalue":true,"setvalueparam":"payload.value","inputtype":"passive","activewait":5,"outputtype":"detailed","outputsimplifiedkey":"payload","x":660,"y":880,"wires":[[]]},{"id":"2d943211.25a85e","type":"cytech zone event","z":"69f018dc.1a17c8","name":"Poll Zones","zone":"*","event":"value","trigger":true,"setvirtualinput":false,"setvirtualinputparam":"payload.value","setbypass":false,"setbypassparam":"payload.bypass","inputtype":"active","activewait":5,"outputtype":"detailed","outputsimplifiedvalue":"boolean","outputsimplifiedkey":"payload","x":830,"y":760,"wires":[[]]},{"id":"7967aff2.430ca","type":"mqtt-broker","z":"","name":"Local MQTT","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
  1. Deploy the flow and then initiate discovery by pressing clicking on the 'Full Discovery' Node in the newly create Home-Assistant tab.
  2. You should now find all yours Zones, Outputs, Flags, Counters and Sensors exposed in Home-Assistant, whcih will both update status and can be controlled (where possible) from Home-Assistant.

To add an alarm panel, you will need to do the following:

  1. Copy the code below into the configuration.yaml found in the Home-Assistant configuration directory:
cd ~/alphawerk/homeassistant
sudo nano configuration.yaml
  1. Copy the code below and paste into the text editor now open, then save with 'CTRL-O'
# Comfort Panel

alarm_control_panel:
  - platform: mqtt
    name: 'Comfort Alarm'
    state_topic: 'homeassistant/alarm/comfort/alarm_mode/status'
    command_topic: 'homeassistant/alarm/comfort/alarm_mode/set'
    code_arm_required: true
    code_disarm_required: true
    code: '1234'
    payload_arm_away: 'away'
    payload_arm_home: 'day'
    payload_arm_night: 'night'
    payload_disarm: 'off'
    command_template: '{{action}},{{code}}'
  1. Paste the code below into a new flow
[{"id":"9fc2111b.359e2","type":"debug","z":"1ad238aa.a6309f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1090,"y":800,"wires":[]},{"id":"9103975.c7b9c68","type":"mqtt in","z":"1ad238aa.a6309f","name":"Subscribe to Alarm Panel","topic":"homeassistant/alarm/comfort/alarm_mode/set","qos":"2","broker":"b0dfbff0.af86a8","x":170,"y":660,"wires":[["78561467.1d9504"]]},{"id":"c390e356.42677","type":"cytech alarm mode event","z":"1ad238aa.a6309f","name":"Set Alarm Mode","trigger":true,"setmode":true,"setmodeparam":"control","setmodevalue":"cytechtext","setpassparam":"code","setpassvalue":"","inputtype":"off","activewait":5,"outputtype":"simplified","outputsimplifiedkey":"payload","outputmodevalue":"cytechtext","x":1080,"y":620,"wires":[[]]},{"id":"78561467.1d9504","type":"split","z":"1ad238aa.a6309f","name":"Get Command & Code","splt":",","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":440,"y":660,"wires":[["bc1a5411.571e1"]]},{"id":"2c463e20.fae50a","type":"join","z":"1ad238aa.a6309f","name":"Join 'em up again","mode":"auto","build":"object","property":"","propertyType":"full","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":990,"y":720,"wires":[["9fc2111b.359e2","c390e356.42677"]]},{"id":"bc1a5411.571e1","type":"switch","z":"1ad238aa.a6309f","name":"Split Up Command & Code","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":460,"y":720,"wires":[["2f699b4e.b0dbe4"],["2e712949.5f3206"]]},{"id":"2f699b4e.b0dbe4","type":"change","z":"1ad238aa.a6309f","name":"Set Control Payload","rules":[{"t":"set","p":"control","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":700,"wires":[["2c463e20.fae50a"]]},{"id":"2e712949.5f3206","type":"change","z":"1ad238aa.a6309f","name":"Set Code Payload","rules":[{"t":"set","p":"code","pt":"msg","to":"payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":740,"wires":[["2c463e20.fae50a"]]},{"id":"b0dfbff0.af86a8","type":"mqtt-broker","z":"","name":"HASS MQTT 2","broker":"192.168.16.21","port":"1883","clientid":"comfort","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
  1. You may need to update the MQTT broker settings in the flow for your local MQTT server.