Package: bcg
Hub Service for HARDWARIO USB GatewayThis repository contains CLI service for HARDWARIO USB Gateway.IntroductionThe service connects to a serial port where HARDWARIO USB Gateway is connected.
It converts messages from serial port to MQTT broker and vice versa.
Run with--helpparameter to see the available options.
It works with Python 2.7+ and Python 3.5+ environments and it has been tested under Linux, macOS and Windows.Setuppip3 install -U bcgInstall as a system-wide local Python package.git clone https://github.com/bigclownlabs/bch-gateway.git
cd bch-gateway
sudo pip3 install -e .Note: Parameter-einstructs to install files as symlinks, so changes to the source files will be immediately available to other users of the package on the host.MQTTGet info about all connected gatewaymosquitto_pub -t 'gateway/all/info/get' -nresponse:gateway/{name}/info {"id": "836d19839c3b", "firmware": "bcf-gateway-...."}List of paired nodesmosquitto_pub -t 'gateway/{name}/nodes/get' -nresponse:gateway/{name}/nodes ["{id-node-0}", "{id-node-id1}", "{id-node-id2}"]Pairing modeStartmosquitto_pub -t 'gateway/{name}/pairing-mode/start' -nLED on gateway start blinkresponse:gateway/{name}/pairing-mode "start"Gateway is waiting to pair node. To pare node, long press the button on Core Module.response when the node is successfully added:gateway/{name}/attach "{id-node-0}"
gateway/{name}/attach "{id-node-1}"
...Error response if there is not enough space:gateway/{name}/attach-failure "{id-node-1}"Stopmosquitto_pub -t 'gateway/{name}/pairing-mode/stop' -nLED on gateway turns offresponse:gateway/{name}/pairing-mode "stop"Purge all nodesmosquitto_pub -t 'gateway/{name}/nodes/purge' -nresponse:gateway/{name}/nodes []Manual Add/Pair nodemosquitto_pub -t 'gateway/{name}/nodes/add' -m '"{id-node}"'response:gateway/{name}/attach "{id-node}"Error response if there is not enough space:gateway/{name}/attach-failure "{id-node-1}"Manual Remove/Unpair nodemosquitto_pub -t 'gateway/{name}/nodes/remove' -m '"{id-node}"'response:gateway/{name}/detach "{id-node}"Set node aliasmosquitto_pub -t 'gateway/usb-dongle/alias/set' -m '{"id": "id-node", "alias": "new-alias"}'respose:gateway/usb-dongle/alias/set/ok {"id": "id-node", "alias": "new-alias"}Remove node aliasmosquitto_pub -t 'gateway/usb-dongle/alias/remove' -m '"{id-node}"'mosquitto_pub -t 'gateway/usb-dongle/alias/set' -m '{"id": "id-node", "alias": null}'Scan StartStartmosquitto_pub -t 'gateway/{name}/scan/start' -nresponse:gateway/{name}/scan "start"response for unknown nodegateway/{name}/found "{id-node-0}"
gateway/{name}/found "{id-node-1}"
gateway/{name}/found "{id-node-2}"
...Stopmosquitto_pub -t 'gateway/{name}/scan/stop' -nresponse:gateway/{name}/scan "stop"Automatic pairing of all visible nodes!!! This is experimental features do not all workStartmosquitto_pub -t 'gateway/{name}/automatic-pairing/start' -nLED on gateway start blinkresponse:gateway/{name}/automatic-pairing "start"response when the node is successfully added:gateway/{name}/attach "{id-node-0}"
gateway/{name}/attach "{id-node-1}"
...Stopmosquitto_pub -t 'gateway/{name}/automatic-pairing/stop' -nLED on gateway turns off

response:
```
gateway/{name}/automatic-pairing "stop"
```Configuration fileConfiguration file is in yaml formatdevice: stringexample: /dev/ttyUSB0name: stringsupport variables:{ip} - ip address{id} - the id of the connected usb-dongle or core-moduledefault: null - automatic detect name from gateway firmwareexample: "{ip}-ttyUSB0"mqtt: objecthost: stringdefault: 127.0.0.1port: intdefualt: 1883username: stringpassword: stringcafile: stringcertfile: stringkeyfile: stringretain_node_messages: booldefault: Falseqos_node_messages: intdefault: 1base_topic_prefix: stringexample: home-automatic_remove_kit_from_names: booldefault: Trueautomatic_rename_kit_nodes: booldefault: Trueautomatic_rename_generic_nodes: booldefault: Trueautomatic_rename_nodes: booldefault: Truerename: objectNode-Red buttonsIf you use Node-Red, you can import text below to create buttons in your flow. You can list, pair and delete nodes with a click of the mouse.For bcf-gateway-usb-dongle[{"id":"83c6c60c.209d78","type":"mqtt in","z":"97027127.a55f7","name":"","topic":"#","qos":"2","broker":"de273190.7f6f2","x":610,"y":80,"wires":[["454a64bc.50f77c"]]},{"id":"454a64bc.50f77c","type":"debug","z":"97027127.a55f7","name":"","active":true,"console":"false","complete":"false","x":790,"y":80,"wires":[]},{"id":"9e87ab30.a50be8","type":"inject","z":"97027127.a55f7","name":"All gateway info","topic":"gateway/all/info/get","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":639,"y":172,"wires":[["504dd396.bb5b4c"]]},{"id":"504dd396.bb5b4c","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"de273190.7f6f2","x":824,"y":173,"wires":[]},{"id":"f447966d.ed0cb8","type":"inject","z":"97027127.a55f7","name":"Pairing mode start","topic":"gateway/usb-dongle/pairing-mode/start","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":660,"y":280,"wires":[["ae043e16.df77c"]]},{"id":"ae043e16.df77c","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"de273190.7f6f2","x":825,"y":281,"wires":[]},{"id":"80092576.c83998","type":"inject","z":"97027127.a55f7","name":"Pairing mode stop","topic":"gateway/usb-dongle/pairing-mode/stop","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":660,"y":320,"wires":[["86c93689.7d0e58"]]},{"id":"86c93689.7d0e58","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"de273190.7f6f2","x":825,"y":321,"wires":[]},{"id":"8f7b14c7.898c38","type":"inject","z":"97027127.a55f7","name":"List of paired nodes","topic":"gateway/usb-dongle/nodes/get","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":650,"y":220,"wires":[["75f5e8db.ed19a8"]]},{"id":"75f5e8db.ed19a8","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"de273190.7f6f2","x":825,"y":221,"wires":[]},{"id":"ed3cfe08.3321b","type":"inject","z":"97027127.a55f7","name":"purge all nodes","topic":"gateway/usb-dongle/nodes/purge","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":640,"y":380,"wires":[["2acde0de.0d9de"]]},{"id":"2acde0de.0d9de","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"de273190.7f6f2","x":825,"y":381,"wires":[]},{"id":"de273190.7f6f2","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]For bcf-gateway-core-module[{"id":"47ab49a8.0a88f8","type":"mqtt in","z":"97027127.a55f7","name":"","topic":"#","qos":"2","broker":"deefb40d.51f818","x":370,"y":100,"wires":[["7208a9c6.a8d3e8"]]},{"id":"7208a9c6.a8d3e8","type":"debug","z":"97027127.a55f7","name":"","active":true,"console":"false","complete":"false","x":550,"y":100,"wires":[]},{"id":"3e634a0c.8e15e6","type":"inject","z":"97027127.a55f7","name":"All gateway info","topic":"gateway/all/info/get","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":399,"y":192,"wires":[["84e9ef97.a81d5"]]},{"id":"84e9ef97.a81d5","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"deefb40d.51f818","x":584,"y":193,"wires":[]},{"id":"6d1a6395.7b49ac","type":"inject","z":"97027127.a55f7","name":"Pairing mode start","topic":"gateway/core-module/pairing-mode/start","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":400,"y":320,"wires":[["6bb142ef.da565c"]]},{"id":"6bb142ef.da565c","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"deefb40d.51f818","x":585,"y":321,"wires":[]},{"id":"191cf80e.901568","type":"inject","z":"97027127.a55f7","name":"Pairing mode stop","topic":"gateway/core-module/pairing-mode/stop","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":400,"y":360,"wires":[["11669b55.138775"]]},{"id":"11669b55.138775","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"deefb40d.51f818","x":585,"y":361,"wires":[]},{"id":"de1bca38.1214f8","type":"inject","z":"97027127.a55f7","name":"List of paired nodes","topic":"gateway/core-module/nodes/get","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":410,"y":240,"wires":[["7cb77d25.465514"]]},{"id":"7cb77d25.465514","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"deefb40d.51f818","x":585,"y":241,"wires":[]},{"id":"ec929b66.dddbb8","type":"inject","z":"97027127.a55f7","name":"purge all nodes","topic":"gateway/core-module/nodes/purge","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":400,"y":420,"wires":[["afe70282.f5ead"]]},{"id":"afe70282.f5ead","type":"mqtt out","z":"97027127.a55f7","name":"","topic":"","qos":"","retain":"","broker":"deefb40d.51f818","x":585,"y":421,"wires":[]},{"id":"deefb40d.51f818","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]LicenseThis project is licensed under theMIT License- see theLICENSEfile for details.Made with ❤  byHARDWARIO s.r.o.in the heart of Europe.