diff --git a/CHANGELOG.md b/CHANGELOG.md index a9274cd..84f6d02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog All notable changes to this project will be documented in this file. +## [11.2.0] - 2024-09-19 +### all gen2+ devices can act as blu gateway - [#164](https://github.com/windkh/node-red-contrib-shelly/issues/164) + ## [11.1.1] - 2024-09-19 ### added Shelly Pro 2 UL - [#179](https://github.com/windkh/node-red-contrib-shelly/issues/179) diff --git a/README.md b/README.md index a31f609..8bb19f8 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ In callback mode a webhook is configured to the shelly which notifies to the nod You must configure this network port, make sure that it is not already in use. If node-red runs inside a docker container or any other bridged network then you should also configure the hostname under that the shelly device can reach the node-red server (Leave this field empty if you run inside the same network segment). The node retries to set the webhook if the device is sleeping as long as it succeeds. As soon as the status shows "Connected" the webhook is set. +Note that gen2+ devices that have bluetooth support can act as a bluetooth gateway for shelly BLU devices. To activate that feature you must use callback node and check the bluetooth checkbox. # Shelly Node (Generation 1) diff --git a/examples/blugateway.json b/examples/blugateway.json index 3dfdebc..e5c68c3 100644 --- a/examples/blugateway.json +++ b/examples/blugateway.json @@ -1 +1 @@ -[{"id":"0daaca6c559a4ac6","type":"shelly-gen2","z":"62a53d6e4cbdfb9a","hostname":"192.168.178.220","description":"BLU-Gateway","mode":"callback","server":"7f2759a4fe573634","outputmode":"event","uploadretryinterval":5000,"pollinginterval":5000,"pollstatus":false,"getstatusoncommand":true,"devicetype":"BluGateway","outputs":1,"x":280,"y":1140,"wires":[["0f371eef3226cba9"]]},{"id":"7e7af4802db81b4f","type":"debug","z":"62a53d6e4cbdfb9a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":1160,"wires":[]},{"id":"a3c70e46afb486d0","type":"inject","z":"62a53d6e4cbdfb9a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":1140,"wires":[["0daaca6c559a4ac6"]]},{"id":"0f371eef3226cba9","type":"function","z":"62a53d6e4cbdfb9a","name":"filter for BLU events","func":"let isBluMessage = msg.payload.info.event === \"shelly-blu\";\nif (isBluMessage){\n node.send(msg);\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":1140,"wires":[["841589a76e05b12c"]]},{"id":"853a58645666004f","type":"debug","z":"62a53d6e4cbdfb9a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":1100,"wires":[]},{"id":"841589a76e05b12c","type":"function","z":"62a53d6e4cbdfb9a","name":"switch device","func":"// TODO: adapt your mac addresses here\nlet address1 = \"90:ab:96:3c:af:47\";\nlet address2 = \"90:ab:96:3c:af:48\";\n\nswitch (msg.payload.info.data.address){\n case address1:\n node.send([msg, null]);\n break;\n\n case address2:\n node.send([null, msg]);\n break;\n default:\n // nothing to do\n break;\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":1140,"wires":[["853a58645666004f"],["7e7af4802db81b4f"]]},{"id":"7f2759a4fe573634","type":"shelly-gen2-server","port":"20000","hostname":""}] \ No newline at end of file +[{"id":"8e9829097c80f37f","type":"shelly-gen2","z":"62a53d6e4cbdfb9a","hostname":"192.168.178.76","description":"ShellyBluGateway","mode":"callback","verbose":false,"server":"7f2759a4fe573634","outputmode":"event","uploadretryinterval":5000,"pollinginterval":5000,"pollstatus":false,"getstatusoncommand":true,"devicetype":"SNGW-BT01","devicetypemustmatchexactly":false,"captureblutooth":true,"outputs":1,"x":370,"y":480,"wires":[["f25343742f4f9c0d","257776387e10fb0e"]]},{"id":"f8c170f943de0fa3","type":"debug","z":"62a53d6e4cbdfb9a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1070,"y":500,"wires":[]},{"id":"1fd69529e146100a","type":"inject","z":"62a53d6e4cbdfb9a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":480,"wires":[["8e9829097c80f37f"]]},{"id":"f25343742f4f9c0d","type":"function","z":"62a53d6e4cbdfb9a","name":"filter for BLU events","func":"if(msg.payload.info){\n let isBluMessage = msg.payload.info.event === \"shelly-blu\";\n if (isBluMessage){\n node.send([msg, null]);\n }\n}\nelse{\n node.send([null, msg]);\n}\n","outputs":2,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":650,"y":480,"wires":[["52087e57509e02a1"],["83bfdecf1a502d74"]]},{"id":"a1251db2c18ee554","type":"debug","z":"62a53d6e4cbdfb9a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1070,"y":440,"wires":[]},{"id":"52087e57509e02a1","type":"function","z":"62a53d6e4cbdfb9a","name":"switch device","func":"// TODO: adapt your mac addresses here\nlet address1 = \"90:ab:96:3c:af:47\";\nlet address2 = \"90:ab:96:3c:af:48\";\n\nswitch (msg.payload.info.data.address){\n case address1:\n node.send([msg, null]);\n break;\n\n case address2:\n node.send([null, msg]);\n break;\n default:\n // nothing to do\n break;\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":460,"wires":[["a1251db2c18ee554"],["f8c170f943de0fa3"]]},{"id":"83bfdecf1a502d74","type":"debug","z":"62a53d6e4cbdfb9a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1050,"y":540,"wires":[]},{"id":"257776387e10fb0e","type":"debug","z":"62a53d6e4cbdfb9a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1050,"y":580,"wires":[]},{"id":"7f2759a4fe573634","type":"shelly-gen2-server","port":"20000","hostname":"","hostip":"192.168.178.121"}] \ No newline at end of file diff --git a/package.json b/package.json index d6ce71f..f59a222 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-shelly", - "version": "11.1.1", + "version": "11.2.0", "description": "Shelly nodes.", "node-red": { "version": ">=3.0.0", diff --git a/shelly/99-shelly.html b/shelly/99-shelly.html index 83452ce..cbc1b7c 100644 --- a/shelly/99-shelly.html +++ b/shelly/99-shelly.html @@ -491,6 +491,7 @@

Details

devicetype: { value: "", required: true}, devicetypemustmatchexactly : { value: true, required: false }, + captureblutooth : { value: false, required: false }, outputs: {value: 1}, }, @@ -701,7 +702,12 @@

Details

-
+ +
+ + Install blutooth gateway script +
+
Tip: If checked a blutooth gateway script is installed. Is automatically activated for BLU gateway.
diff --git a/shelly/99-shelly.js b/shelly/99-shelly.js index 47671bf..317334f 100644 --- a/shelly/99-shelly.js +++ b/shelly/99-shelly.js @@ -2463,7 +2463,9 @@ module.exports = function (RED) { } // Gets a function that initialize the device. - function getInitializer2(deviceType){ + function getInitializer2(node){ + + let deviceType = node.deviceType; let result; switch(deviceType) { @@ -2472,10 +2474,16 @@ module.exports = function (RED) { case 'Measure': case 'Dimmer': case 'RGBW': - result = initializer2CallbackAsync; - // result = initializer2BluCallbackAsync; // TODO: + if(node.captureBlutooth) { + result = initializer2BluCallbackAsync; + } + else { + result = initializer2CallbackAsync; + } break; case 'BluGateway': + // Here we force the capturing f blutooth messages for this specific device. + node.captureBlutooth = true; result = initializer2BluCallbackAsync; break; case 'Sensor': @@ -2723,6 +2731,7 @@ module.exports = function (RED) { let deviceType = config.devicetype; node.deviceTypeMustMatchExactly = config.devicetypemustmatchexactly || false; + node.captureBlutooth = config.captureblutooth || false; node.mode = config.mode; if (!node.mode) { @@ -2747,7 +2756,7 @@ module.exports = function (RED) { node.types = getDeviceTypes2(node.deviceType, node.deviceTypeMustMatchExactly); } - node.initializer = getInitializer2(node.deviceType); + node.initializer = getInitializer2(node); node.inputParser = getInputParser2(node.deviceType); (async () => {