HS4 + Wyze device control using Node-RED (Plugs, Bulbs, Cameras) - ON/OFF/State
I have been playing around with Node-RED and I got HS4 connected to my Wyze cams (this will also work for Wyze plugs and bulbs... maybe locks)
This is just a basic setup to use an HS4 virtual device to turn On/Off Wyze devices. (This setup uses the Wyze app API, it is not local control). You can only get the status from Wyze by request. Wyze will not update HS4 on change, you would need to periodically check the state of Wyze and update HS4
The 3 main node red component are
https://flows.nodered.org/node/node-...ntrib-homeseer
https://www.npmjs.com/package/wyze-node
https://flows.nodered.org/node/node-red-contrib-config
Step 1
Install Node Red and Setup with HS4
https://forums.homeseer.com/forum/ho...pported-by-hs4
https://docs.homeseer.com/display/HS...r+use+with+HS4
Step 2
Install the unofficial wyze api for node red. (wyze-node is currently not part of the libraries, so you need to add it as an external third party library)
run the following command: (navigate to nodered folder first if you want.... cd ~/.node-red )
npm install wyze-node --save
wyze-node is using an old version of axios, so you will want to update that. Open the wyze-node folder that was just created
1) in the wyze-node folder, delete the node-modules folder
2) edit the package.json to read....
"dependencies": {
"axios": "^0.21.1",
3) run command: npm install
4) run command: npm audit fix
5) run command: npm audit
Step 3
(Add wyze-node as an external third party node)
Edit your node red setting.js file (Linux located in cd ~/.node-red ). Set functionGlobalContext To look like this...
functionGlobalContext: {
// os:require('os'),
// jfive:require("johnny-five"),
// j5board:require("johnny-five").Board({repl:false}),
Wyze:require("wyze-node")
},
Step 4 (This isn't needed, but this is how I stored username/password in the flow)
install https://flows.nodered.org/node/node-red-contrib-config
Step 5
create a virtual device On/Off in HS4
Step 6
import the flow...

Step 7
-Setup your HS4 device node to the virtual device
-Setup your Wyze username and password in the Config node json
-Deploy
-Do a test of "get wyze devices" to get your devices names
-Edit the functions to have your wyze device name
-Deploy
Step 8
Test it using injects and/or HS4 device on/off control
I have been playing around with Node-RED and I got HS4 connected to my Wyze cams (this will also work for Wyze plugs and bulbs... maybe locks)
This is just a basic setup to use an HS4 virtual device to turn On/Off Wyze devices. (This setup uses the Wyze app API, it is not local control). You can only get the status from Wyze by request. Wyze will not update HS4 on change, you would need to periodically check the state of Wyze and update HS4
The 3 main node red component are
https://flows.nodered.org/node/node-...ntrib-homeseer
https://www.npmjs.com/package/wyze-node
https://flows.nodered.org/node/node-red-contrib-config
Step 1
Install Node Red and Setup with HS4
https://forums.homeseer.com/forum/ho...pported-by-hs4
https://docs.homeseer.com/display/HS...r+use+with+HS4
Step 2
Install the unofficial wyze api for node red. (wyze-node is currently not part of the libraries, so you need to add it as an external third party library)
run the following command: (navigate to nodered folder first if you want.... cd ~/.node-red )
npm install wyze-node --save
wyze-node is using an old version of axios, so you will want to update that. Open the wyze-node folder that was just created
1) in the wyze-node folder, delete the node-modules folder
2) edit the package.json to read....
"dependencies": {
"axios": "^0.21.1",
3) run command: npm install
4) run command: npm audit fix
5) run command: npm audit
Step 3
(Add wyze-node as an external third party node)
Edit your node red setting.js file (Linux located in cd ~/.node-red ). Set functionGlobalContext To look like this...
functionGlobalContext: {
// os:require('os'),
// jfive:require("johnny-five"),
// j5board:require("johnny-five").Board({repl:false}),
Wyze:require("wyze-node")
},
Step 4 (This isn't needed, but this is how I stored username/password in the flow)
install https://flows.nodered.org/node/node-red-contrib-config
Step 5
create a virtual device On/Off in HS4
Step 6
import the flow...
Code:
[{"id":"8c2cdc64.8a845","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"5ae3a92e.c81058","type":"function","z":"8c2cdc64.8a845","name":"","func":"let Wyze = global.get('Wyze')\n\nlet wyze = new Wyze(flow.get(\"wyzeOptions\"))\n\nlet device = await wyze.getDeviceByName('CameraName')\nlet result = await wyze.turnOff(device)\n\nmsg.payload={\n \"command\":\"off\",\n \"value\":result.code,\n};\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"const options = {\n username: env.get(\"username\"),\n password: env.get(\"password\")\n}\n","finalize":"","x":680,"y":220,"wires":[["1ad9241e.01a9e4"]]},{"id":"63519b88.ac392c","type":"inject","z":"8c2cdc64.8a845","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":510,"y":220,"wires":[["5ae3a92e.c81058"]]},{"id":"71e19088.93fec8","type":"inject","z":"8c2cdc64.8a845","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":510,"y":320,"wires":[["2567ac77.8e9114"]]},{"id":"487e814b.26e358","type":"function","z":"8c2cdc64.8a845","name":"","func":"let Wyze = global.get('Wyze')\n\nlet wyze = new Wyze(flow.get(\"wyzeOptions\"))\nlet devices = await wyze.getDeviceList()\n\nmsg.payload={\n \"devices\":devices\n};\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":680,"y":120,"wires":[["21ee2da1.8868ea"]]},{"id":"21ee2da1.8868ea","type":"debug","z":"8c2cdc64.8a845","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":120,"wires":[]},{"id":"6e445cef.b82644","type":"inject","z":"8c2cdc64.8a845","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":510,"y":120,"wires":[["487e814b.26e358"]]},{"id":"1ad9241e.01a9e4","type":"debug","z":"8c2cdc64.8a845","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":220,"wires":[]},{"id":"3231f270.9a096e","type":"debug","z":"8c2cdc64.8a845","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":320,"wires":[]},{"id":"2567ac77.8e9114","type":"function","z":"8c2cdc64.8a845","name":"","func":"\nlet Wyze = global.get('Wyze')\n\nlet wyze = new Wyze(flow.get(\"wyzeOptions\"))\n\nlet device = await wyze.getDeviceByName('CameraName')\nlet result = await wyze.turnOn(device)\n\nmsg.payload={\n \"command\":\"on\",\n \"value\":result.code,\n};\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"const options = {\n username: env.get(\"username\"),\n password: env.get(\"password\")\n}\n","finalize":"","x":680,"y":320,"wires":[["3231f270.9a096e"]]},{"id":"bc4153d.f60703","type":"comment","z":"8c2cdc64.8a845","name":"Turn Off Wyze device by Name","info":"","x":530,"y":180,"wires":[]},{"id":"a32002a8.87ddf","type":"comment","z":"8c2cdc64.8a845","name":"Turn On Wyze device by Name","info":"","x":530,"y":280,"wires":[]},{"id":"b3e989c4.20f878","type":"comment","z":"8c2cdc64.8a845","name":"Get Wyze devices","info":"","x":490,"y":80,"wires":[]},{"id":"475a5c60.54541c","type":"inject","z":"8c2cdc64.8a845","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":510,"y":420,"wires":[["5963f4d0.b7f534"]]},{"id":"f119d969.9f62a","type":"debug","z":"8c2cdc64.8a845","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":420,"wires":[]},{"id":"5963f4d0.b7f534","type":"function","z":"8c2cdc64.8a845","name":"","func":"let Wyze = global.get('Wyze')\n\nlet wyze = new Wyze(flow.get(\"wyzeOptions\"))\n\nlet device = await wyze.getDeviceByName('CameraName')\nlet deviceState = await wyze.getDeviceState(device)\n\nmsg.payload={\n \"state\":deviceState,\n};\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"const options = {\n username: env.get(\"username\"),\n password: env.get(\"password\")\n}\n","finalize":"","x":680,"y":420,"wires":[["f119d969.9f62a"]]},{"id":"25bb421a.b788ee","type":"comment","z":"8c2cdc64.8a845","name":"Get Wyze device state","info":"","x":500,"y":380,"wires":[]},{"id":"a48a9442.8f24f","type":"hs-device","z":"8c2cdc64.8a845","name":" WyzeCam1 Control","device":0,"server":"","feature":0,"reportonstartup":false,"x":190,"y":220,"wires":[["7c6ab079.c9308"]]},{"id":"7c6ab079.c9308","type":"switch","z":"8c2cdc64.8a845","name":"","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"100","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":220,"wires":[["5ae3a92e.c81058"],["2567ac77.8e9114"]]},{"id":"b7fadddf.5af94","type":"config","z":"8c2cdc64.8a845","name":"wyzeConfig","properties":[{"p":"wyzeOptions","pt":"flow","to":"{ \"username\": \"username@email.com\", \"password\": \"yourPassword\" }","tot":"json"}],"active":true,"x":250,"y":120,"wires":[]}]
Step 7
-Setup your HS4 device node to the virtual device
-Setup your Wyze username and password in the Config node json
-Deploy
-Do a test of "get wyze devices" to get your devices names
-Edit the functions to have your wyze device name
-Deploy
Step 8
Test it using injects and/or HS4 device on/off control
Comment