HDL SmartBus \ HDL BusPro \ SBus g4

Is it possible to control this protocol from HA?

Now i’m using Node-red with this nodes https://github.com/efa2000/node-red-contrib-buspro and translate all to mqtt

Based on https://github.com/caligo-mentis/smart-bus in which i changed “status” to “state” because “status” is a function in node-red.

Commands list http://www.hdlautomation.ca/file-download/hdl-bus-pro-operation-codeseng-jan-08-2013-pdf/

Here is one to send command (code 49)

[{"id":"9ba03e7c.385c8","type":"buspro-out","z":"a5118954.594eb8","controller":"965141c7.56bd9","name":"HDL Gate","x":500,"y":700,"wires":[]},{"id":"c3701aa4.3a1648","type":"function","z":"a5118954.594eb8","name":"49 to 1.1 ch & level","func":"msg.code = 49;\n\nmsg.target = msg.topic.slice(4, 7);\nvar pos = msg.topic.indexOf(\"/\", 4);\nvar pos2 = msg.topic.indexOf(\"/\",9);\n// var level = msg.payload;\nvar level = Math.min(Math.max(parseInt(msg.payload), 0), 100);\n\nmsg.payload = {channel: msg.topic.slice(pos + 3, pos2)};\n\nmsg.payload.level = level\n\nreturn msg;\n\n","outputs":1,"noerr":0,"x":310,"y":700,"wires":[["9ba03e7c.385c8","7034d8ba.d921c8"]]},{"id":"3013d403.51cb2c","type":"mqtt in","z":"a5118954.594eb8","name":"","topic":"hdl/1.1/+/set","qos":"0","broker":"d110fe62.0ec2","x":90,"y":700,"wires":[["c3701aa4.3a1648"]]},{"id":"7034d8ba.d921c8","type":"debug","z":"a5118954.594eb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":490,"y":760,"wires":[]},{"id":"965141c7.56bd9","type":"buspro-controller","z":0,"host":"192.168.1.20","port":"6000","subnetid":"1","deviceid":"100"},{"id":"d110fe62.0ec2","type":"mqtt-broker","z":"","name":"hassio.local","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]

And here is the one to read states

[{"id":"4850faeb.01fd74","type":"function","z":"a5118954.594eb8","name":"50 from 1.1","func":"if (msg.sender == \"1.1\" && msg.code == 50 && msg.payload.success == true) \n {\n msg.topic = \"hdl/\" + msg.sender + \"/ch\" + msg.payload.channel;\n msg.payload = msg.payload.level;\n\n return msg;\n}\n\n","outputs":1,"noerr":0,"x":250,"y":540,"wires":[["a93b9a05.e61848","356ba433.80f3cc"]]},{"id":"aa53dcd7.a6867","type":"buspro-in","z":"a5118954.594eb8","controller":"965141c7.56bd9","name":"HDL Gate","x":80,"y":560,"wires":[["4850faeb.01fd74","c503b8d1.3391d8","65bfd47f.860adc"]]},{"id":"c503b8d1.3391d8","type":"function","z":"a5118954.594eb8","name":"52 from 1.1 ","func":"var outputMsgs = [];\nif (msg.sender == \"1.1\" && msg.code == 52) {\n for (i = 0; i < msg.payload.channels.length; i++) {\n// msg.topic = \"hdl/\" + msg.sender + \"/ch\" + msg.payload.channels[i].number;\n// msg.payload = msg.payload.channels[i].level;\n outputMsgs.push({\n topic:\"hdl/\" + msg.sender + \"/ch\" + msg.payload.channels[i].number,\n payload:msg.payload.channels[i].level\n });\n// outputMsgs.push({payload:msg.payload.channels[i].level});\n }\n return [ outputMsgs ];\n}","outputs":1,"noerr":0,"x":250,"y":580,"wires":[["a93b9a05.e61848","bd1abac3.10a298"]]},{"id":"a93b9a05.e61848","type":"mqtt out","z":"a5118954.594eb8","name":"hdl/X.X/chY","topic":"","qos":"0","retain":"true","broker":"d110fe62.0ec2","x":470,"y":560,"wires":[]},{"id":"bd1abac3.10a298","type":"debug","z":"a5118954.594eb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":470,"y":620,"wires":[]},{"id":"965141c7.56bd9","type":"buspro-controller","z":0,"host":"192.168.1.20","port":"6000","subnetid":"1","deviceid":"100"},{"id":"d110fe62.0ec2","type":"mqtt-broker","z":"","name":"hassio.local","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]

Dont blame me for functions i’m not a coder :slight_smile:

By the way here is manufacturer site HDL and another manufacturer, don’t know if second one is still exist.

4 Likes

Were you able to control HDL from HA?

Have looked at your examples but i am a bit lost, do you have a dimmer with adress 1.1?

Yeap, it’s been working in several installations for 3+ years.

Here is new upgraded nodes (with some debug stuff), just import them to node-red, set up HDL Gate address and mqtt server:

[{"id":"b9ac707f.2c7f2","type":"mqtt in","z":"3f0432d3.e7f46e","name":"","topic":"hdl/+/+/set","qos":"0","broker":"d110fe62.0ec2","x":80,"y":120,"wires":[["f4184170.2227b","4b67166a.3a4d18"]]},{"id":"d6cd14d6.e60cc8","type":"debug","z":"3f0432d3.e7f46e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1010,"y":180,"wires":[]},{"id":"f4184170.2227b","type":"debug","z":"3f0432d3.e7f46e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":190,"y":180,"wires":[]},{"id":"4b67166a.3a4d18","type":"json","z":"3f0432d3.e7f46e","name":"","property":"payload","action":"obj","pretty":true,"x":230,"y":120,"wires":[["fa6088c8.9f43c8","abf7ab08.61f8d8"]]},{"id":"fa6088c8.9f43c8","type":"debug","z":"3f0432d3.e7f46e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":350,"y":180,"wires":[]},{"id":"84093149.eb259","type":"function","z":"3f0432d3.e7f46e","name":"50 from any","func":"if (msg.code == 50 && msg.payload.success == true) \n {\n    msg.topic = \"hdl/\" + msg.sender + \"/\" + msg.payload.channel;\n    return msg;\n}\n\n","outputs":1,"noerr":0,"x":370,"y":360,"wires":[["c9945343.c2251","4d81d82.266c728"]]},{"id":"b752e5a3.111228","type":"function","z":"3f0432d3.e7f46e","name":"52 from any","func":"var outputMsgs = [];\nif (msg.code == 52) {\n    for (i = 0; i < msg.payload.channels.length; i++) {\n          outputMsgs.push({\n          topic:\"hdl/\" + msg.sender + \"/\" + msg.payload.channels[i].number,\n          payload:{\n              level:msg.payload.channels[i].level\n              \n          }\n      });\n    }\n    return [ outputMsgs ];\n}\n","outputs":1,"noerr":0,"x":370,"y":500,"wires":[["b3d7343.4eb7ec8","1b9aec33.314424"]]},{"id":"60f9e53c.f850ac","type":"mqtt out","z":"3f0432d3.e7f46e","name":"hdl/X.X/Y","topic":"","qos":"0","retain":"true","broker":"d110fe62.0ec2","x":860,"y":420,"wires":[]},{"id":"c9945343.c2251","type":"debug","z":"3f0432d3.e7f46e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":570,"y":300,"wires":[]},{"id":"b3d7343.4eb7ec8","type":"debug","z":"3f0432d3.e7f46e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":570,"y":560,"wires":[]},{"id":"abf7ab08.61f8d8","type":"range","z":"3f0432d3.e7f46e","minin":"0","maxin":"255","minout":"0","maxout":"100","action":"scale","round":true,"property":"payload.level","name":"","x":460,"y":120,"wires":[["85386df0.36fda","eec37ff.193c18"]]},{"id":"4d81d82.266c728","type":"range","z":"3f0432d3.e7f46e","minin":"0","maxin":"100","minout":"0","maxout":"255","action":"scale","round":true,"property":"payload.level","name":"","x":580,"y":360,"wires":[["60f9e53c.f850ac","24972633.1004fa"]]},{"id":"24972633.1004fa","type":"debug","z":"3f0432d3.e7f46e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":730,"y":320,"wires":[]},{"id":"1b9aec33.314424","type":"range","z":"3f0432d3.e7f46e","minin":"0","maxin":"100","minout":"0","maxout":"255","action":"scale","round":true,"property":"payload.level","name":"","x":580,"y":500,"wires":[["c03c2c1a.9f15a","60f9e53c.f850ac"]]},{"id":"c03c2c1a.9f15a","type":"debug","z":"3f0432d3.e7f46e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":750,"y":500,"wires":[]},{"id":"22563966.d389b6","type":"function","z":"3f0432d3.e7f46e","name":"","func":"msg.code = 49;\nmsg.target = \"1.1\";\nreturn msg;","outputs":1,"noerr":0,"x":650,"y":240,"wires":[["4d55a161.d6ba9","79fdc866.1bece8"]]},{"id":"7759b580.04993c","type":"inject","z":"3f0432d3.e7f46e","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"channel\":\"1\",\"time\":\"1\",\"level\":\"0\"}","payloadType":"json","x":470,"y":240,"wires":[["22563966.d389b6"]]},{"id":"4d55a161.d6ba9","type":"debug","z":"3f0432d3.e7f46e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":850,"y":240,"wires":[]},{"id":"f030f113.b354e","type":"buspro-in","z":"3f0432d3.e7f46e","controller":"965141c7.56bd9","name":"HDL Gate","filter":"all","subnetid":"0","deviceid":"0","commands":"","x":140,"y":420,"wires":[["84093149.eb259","b752e5a3.111228","bed87f8.574718","ab88147d.14b818","48b87bf7.3ecc04"]]},{"id":"79fdc866.1bece8","type":"buspro-out","z":"3f0432d3.e7f46e","controller":"965141c7.56bd9","name":"HDL Gate","x":1080,"y":120,"wires":[]},{"id":"85386df0.36fda","type":"function","z":"3f0432d3.e7f46e","name":"49 to ID (ch & level & time)","func":"msg.code = 49;\n\nmsg.target = msg.topic.split(\"/\")[1];\nvar time = msg.payload.time;\nvar level = Math.min(Math.max(parseInt(msg.payload.level), 0), 100);\n\nmsg.payload = {\n    channel: msg.topic.split(\"/\")[2],\n    time: time,\n    level: level,\n};\n\nreturn msg;","outputs":1,"noerr":0,"x":760,"y":120,"wires":[["79fdc866.1bece8","d6cd14d6.e60cc8"]]},{"id":"eec37ff.193c18","type":"debug","z":"3f0432d3.e7f46e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":570,"y":180,"wires":[]},{"id":"bed87f8.574718","type":"function","z":"3f0432d3.e7f46e","name":"UV to MQTT","func":"if (msg.code == 57372) \n {\n    var type;\n    switch (msg.payload.switch) {\n        case 1:\n            type = \"pir\";\n            break;\n        case 2:\n            type = \"sonic\";\n            break;\n        case 3:\n            type = \"dry1\";\n            break;\n        case 4:\n            type = \"dry2\";\n            break;\n    }\n    msg.topic = \"hdl/\" + msg.sender + \"/\" + type;\n    msg.payload = msg.payload.state;\n    return msg;\n}\n\n","outputs":1,"noerr":0,"x":370,"y":400,"wires":[["60f9e53c.f850ac"]]},{"id":"ab88147d.14b818","type":"function","z":"3f0432d3.e7f46e","name":"temp & lux from any","func":"var outputMsgs = [];\nif (msg.code == 5703) \n{\n    {\n        outputMsgs.push\n        ({\n          topic:\"hdl/\" + msg.sender + \"/temp\",\n          payload : msg.payload.temperature\n        });\n\n        outputMsgs.push\n        ({\n          topic:\"hdl/\" + msg.sender + \"/lux\",\n           payload : msg.payload.brightness\n        });\n    }\n    return [ outputMsgs ];\n}","outputs":1,"noerr":0,"x":400,"y":440,"wires":[["60f9e53c.f850ac"]]},{"id":"48b87bf7.3ecc04","type":"debug","z":"3f0432d3.e7f46e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":210,"y":520,"wires":[]},{"id":"d110fe62.0ec2","type":"mqtt-broker","name":"hassio.local","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"965141c7.56bd9","type":"buspro-controller","host":"192.168.3.21","port":"6000","subnetid":"1","deviceid":"101"}]
1 Like

Thanks for the quick reply :slight_smile:

That looks great. Would you mind sharing your Configuration.yaml setup for a dimmer, relay, US and a sensor?

Hey,
I also have HDL setup at home - how could I connect HDL to Home Assistant? Is there anything I could read?

I just did a writeup on the process if you are still interested:
https://community.home-assistant.io/t/hdl-smartbus-via-nodered-and-mqtt/338974/1