Node-RED nodes for hubitat

Instead of using pushover, how about @Cobra s email notifier? Have them sent to any email address, then review at leisure.

1 Like

I've just tried this one briefly:

1 Like

Logging. Good guess.

1 Like

How would I get a dashboard light switch that reflected the actual state of the switch and also control the switch. This is what I have at present, but I cant seem to get the dash to update. I've tried all 3 options (pass through, match state of input and output).

[{"id":"8ff24c0f.ccce2","type":"ui_switch","z":"1879973f.f50f79","name":"Office Light","label":"Office Lights","tooltip":"","group":"1fae11b3.f9f7ee","order":0,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"Light","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":650,"y":180,"wires":[["b7519259.58b1a"]]},{"id":"630195f8.182e0c","type":"hubitat command","z":"1879973f.f50f79","name":"LS - Mike's Office (Tasmota)","server":"a17596b.3e14568","deviceId":"1890","command":"on","commandArgs":"","x":1060,"y":140,"wires":[[]]},{"id":"b7519259.58b1a","type":"switch","z":"1879973f.f50f79","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":840,"y":180,"wires":[["630195f8.182e0c"],["5c923be4.647e64"]]},{"id":"5c923be4.647e64","type":"hubitat command","z":"1879973f.f50f79","name":"LS - Mike's Office (Tasmota)","server":"a17596b.3e14568","deviceId":"1890","command":"off","commandArgs":"","x":1060,"y":200,"wires":[[]]},{"id":"f6c1ef47.6253f","type":"hubitat device","z":"1879973f.f50f79","name":"LS - Mike's Office (Tasmota)","server":"a17596b.3e14568","deviceId":"1890","attribute":"switch","sendEvent":true,"x":160,"y":180,"wires":[["a2bdab6.d2bc558"]]},{"id":"a2bdab6.d2bc558","type":"switch","z":"1879973f.f50f79","name":"","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":180,"wires":[["2475b9e0.14bbf6"],["6fe87d2b.0e9c34"]]},{"id":"2475b9e0.14bbf6","type":"change","z":"1879973f.f50f79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":475,"y":160,"wires":[["8ff24c0f.ccce2"]],"l":false},{"id":"6fe87d2b.0e9c34","type":"change","z":"1879973f.f50f79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":475,"y":200,"wires":[["8ff24c0f.ccce2"]],"l":false},{"id":"1fae11b3.f9f7ee","type":"ui_group","z":"","name":"Lights","tab":"b90217d9.bf3e68","order":16,"disp":true,"width":"3","collapse":false},{"id":"a17596b.3e14568","type":"hubitat config","z":"","name":"Hubitat Coordinator","usetls":false,"host":"192.168.1.100","port":"80","appId":"1731","nodeRedServer":"http://192.168.1.90:1880","webhookPath":"/hubitat/webhook","autoRefresh":true},{"id":"b90217d9.bf3e68","type":"ui_tab","z":"","name":"Mike","icon":"dashboard","disabled":false,"hidden":false}]

Edit: I tried the example ~2000 posts ago, but I cant physically (with mouse) turn on the dash switch. It wont turn on.

Definitely doable. I have literally dozens of these that do exactly that.

You should make sure you have a startup injection to push device state to the dashboard switch node on startup (or it will break every node-red reboot), make sure the input is in the correct format (state is in msg.payload, not msg.payload.value), and use match state of input.

1st change node:

Dashboard switch node:

2nd change node:

My dashboard. Clicking the bulb icon turns light on/off:

2 Likes

One more comment - on my startup injection for dashboards, I actually do the injection "after 30s" to ensure the hubitat nodes have all initialized first.

1 Like

I use this subflow to initialize dashboard elements on startup. The random delay is 10 to 30 seconds, so I don't have a bunch of flows trying to initialize at the same time.
image

1 Like

I used to use a random delay too. Decided it wasn't worth it since the device nodes don't reach out to hubitat when you send an incoming msg.

Watched my node-red server loading and initializing everything all at once was trivial from a loading standpoint.

But it obviously doesn't hurt anything either.

Hi , on my test send notification %time% when light On, the variable %time%, %now% ... not working right .
How to fix this ?
Thanks.


I don't think you can use %time% like that (?). I've never seen use of time like that in Node-RED in any case.

Typically people either use $now() in a JSONata expression, or use node-red-contrib-moment . Moment is easier as it is timezone and daylight savings time aware.

Or of course you could use a function node and do something like this (which is actually a lot lighter on resources than using the moment node - which is porky):

msg.arguments = new Date().toLocaleString();
return msg;
2 Likes

@JasonJoel

On Rule Machine I have a rule :
Noti 3
But when on NR the command send to HE , I don't know how to make the flow with this action ( on my phone get a notifiaction : " Office 1 is On at 3:30 PM " ).

function node between switch and command nodes with something like this:

msg.arguments = msg.topic + " is " + msg.payload.value + " at " + new Date().toLocaleString();
return msg;

You could almost do it with a change node alone, but $now() in jsonata is not time zone or DST aware (although it does have a timezone adjustment parameter of form "-####" or "+####" - not especially useful), so is a bit of a pain to keep in correct local time.

2 Likes

Thanks @JasonJoel. I will learning more later. Now I keep the action notification with variable on RM, WebCoRE .

1 Like

Would a vm affect this? Worked yesterday on my pi, but today on my vm, same problem, only updates after deploy tia

Assuming everything else is correct, it's probably port 80. You may need to forward/map it from the real machine to the VM.

As long as the host and VM don't have a firewall blocking the connection, and port 8123 (the port you show in your screenshot) is open externally, then it should work.

I've ran node-red in VMs, and hubitat port events work. So a VM by itself should be fine, as is a docker container.

@JasonJoel no luck :disappointed:

Are you running node-red in home assistant? If so, that's a whole other set of issues you will have to work through. As I don't run node-red in home assistant (and recommend against it in general), I'll defer to someone else to help out there.

In any case, hubitat has to be able to contact and send POSTs to the specified port in node-red. If it can, events work, if it can't they don't.

Troubleshooting that seems a little outside of the scope of this thread.

Ok, thank you

No worries, a few others run node-red in HA so maybe they will jump in to help.

1 Like