Node-RED nodes for hubitat

The top part of my flow does exactly what you're looking for if you import it and change the devices to your own and the hub to your own, but I also use webhook.

I'm confused about what you said, I can see the activation on sunset and sunrise, but I can't see where your flow increases brightness when motion is active etc..

I've ended up with this, but I'm not sure if it'll work correctly - I also can't see defined start/end time like you have in your time range switch

fair warning @april.brandt, I've been stalking your Node-Red comments and I have started tinkering with my Node-Red setup.. I might be hitting you up before long HAHAHA.. Hope you all are doing ok!!

1 Like

Op shoot! Busted. that flow is on and off - stand by, I'll get you the right flow and post is here.
The one I should share with you is way too complicated. I'll create one and share it in just a minute or so.

1 Like

I don't know that it's better, but I can't wrap my head around condensing the time range to a single

[{"id":"d7526313.23dbf","type":"hubitat device","z":"d19a2683.b31678","name":"Living Room Motion","server":"6b5d6374.da729c","deviceId":"1620","attribute":"motion","sendEvent":true,"x":230,"y":500,"wires":[["1375faed.365745"]]},{"id":"1375faed.365745","type":"switch","z":"d19a2683.b31678","name":"Active/inactive","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"active","vt":"str"},{"t":"eq","v":"inactive","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":460,"y":500,"wires":[["fb815e85.16ea2"],["b36b5b33.f04048"]]},{"id":"fb815e85.16ea2","type":"time-range-switch","z":"d19a2683.b31678","name":"sunset to sunrise = output 1","lat":"43.4561268","lon":"-96.4379696","startTime":"sunset","endTime":"sunrise","startOffset":"-59","endOffset":"+59","x":720,"y":480,"wires":[["d47553ba.7f8f"],[]]},{"id":"a7bfc783.8a9448","type":"switch","z":"d19a2683.b31678","name":"light","property":"payload.currentValue","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1075,"y":480,"wires":[["1a51c9ef.df3e66"]],"l":false},{"id":"d47553ba.7f8f","type":"hubitat device","z":"d19a2683.b31678","name":"light","server":"6b5d6374.da729c","deviceId":"201","attribute":"switch","sendEvent":false,"x":950,"y":480,"wires":[["a7bfc783.8a9448"]]},{"id":"2f6039d1.bcaec6","type":"switch","z":"d19a2683.b31678","name":"light","property":"payload.currentValue","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1075,"y":520,"wires":[["1730452e.3ac71b"]],"l":false},{"id":"4523c31f.6d943c","type":"hubitat device","z":"d19a2683.b31678","name":"light","server":"6b5d6374.da729c","deviceId":"201","attribute":"switch","sendEvent":false,"x":950,"y":520,"wires":[["2f6039d1.bcaec6"]]},{"id":"b36b5b33.f04048","type":"time-range-switch","z":"d19a2683.b31678","name":"sunset to sunrise = output 1","lat":"43.4561268","lon":"-96.4379696","startTime":"sunset","endTime":"sunrise","startOffset":"-59","endOffset":"+59","x":720,"y":520,"wires":[["4523c31f.6d943c"],[]]},{"id":"1a51c9ef.df3e66","type":"hubitat command","z":"d19a2683.b31678","name":"Entry Way Table 100","server":"6b5d6374.da729c","deviceId":"1495","command":"setLevel","commandArgs":"100","x":1220,"y":480,"wires":[[]]},{"id":"1730452e.3ac71b","type":"hubitat command","z":"d19a2683.b31678","name":"Entry Way Table 10","server":"6b5d6374.da729c","deviceId":"1495","command":"setLevel","commandArgs":"10","x":1210,"y":520,"wires":[[]]},{"id":"6b5d6374.da729c","type":"hubitat config","z":"","name":"Hubitat","usetls":false,"host":"192.168.86.32","port":"80","appId":"3451","nodeRedServer":"http://192.168.86.49:1880","webhookPath":"/hubitat/webhook_","autoRefresh":true,"useWebsocket":false}]

I don't think that will give you the outcome your looking for. The motion node is not set to send commands so it won't do anything accept when triggered by sunrise or sunset.

If I was doing it I would use 2 sequences. One to control the lights triggered by sunrise/set . Then a second one triggered by motion, then run it thru a time check if between rise/set go to 100% give timer and then go back to 25%. (or whatever it was).

When you get it, add it to the Node sharing theard for others to use, sounds like a good one.

If you still have trouble LKM and I can throw something together I think will work.

EDIT: This one is close just add the time node after your motion, remove the light check (since it is between the correct times you don't need it), and it should work fine

1 Like

I'm at work and rushed this. needs a motion node - it doesn't have one. I Guess you can use the timeframe as reference for your existing. someone should slap me for rushing this.
:raised_back_of_hand:

3 Likes

So, I am trying to access a function of one of my Kasa dimmers that is exposed to NR. I was wondering, does anyone know if it is possible to send data from the msg.payload message into the argument of the command node?

Specifically, I am trying to set the level per mode, and depending on the mode, the level is changed and added to the msg.payload. I tried msg.payload.level in my case in the argument field and in the logs of Hubitat the log is shown below:

dev:672020-07-21 03:36:38.282 pm errorjava.lang.NumberFormatException: For input string: "msg.payload.level" on line 118 (presetLevel)
dev:692020-07-21 03:36:38.255 pm errorjava.lang.NumberFormatException: For input string: "msg.payload.level" on line 118 (presetLevel)
dev:682020-07-21 03:36:38.216 pm errorjava.lang.NumberFormatException: For input string: "msg.payload.level" on line 118 (presetLevel)

This is the debug for the message being sent:
image

This is the setup for the command node:
image

This shows that it's not actually parsing the message data but just the text I wrote into the argument. Any ideas on what I can do?

You can't specify the msg.payload.level in the command node itself. You would use a change or function node before the command node and set msg.arguments to msg.payload.level.

I could provide an example later, but am in the middle of cooking right now.

1 Like

Oh, so the argument of the hubitat nodes are hard coded to look for msg.arguments? If so, that would be a feature request for me, being able to reference any message in the arguments.

Update: All working now after changing my Change node to this

The node supports explicitly putting in a value, or overriding the node value with msg.arguments. That is a normal way for a node-red node to work.

But changing it or not is up to @fblackburn . If he changes it, he would have to make it have a type selector (like some of the in-box nodes have) to select between msg and value specification.

Oh definitely and I understand that. My only experience with NR, noob over here, is with node-red-contrib-alexa-remote2 and with that it has this for controlling the volume of an echo device for example, which allows you to reference the msg directly.

Understood. That could definitely be done - and you are right, there are many nodes that allow varying types of input like that.

1 Like

I'm open to the idea. There is already a similar PR with global flow variable.
Unfortunately, it was not requested by anyone and the owner of the PR didn't response/fix it

Currently it's not on my priority list, but if it's a feature that some of you need, you can open an issue on github to request it or you can continue the PR (I can rebase it too) :slight_smile:

1 Like

Yeah, I don't think I know enough about how Node-RED works yet, but I can look at that request. But like I said, my problem was solved, but for anything too sophisticated I could see that the change nodes to add whichever argument I want getting out of hand easily.

1 Like

I'll have some time tomorrow to add caution and warning about websocket. I hope it will reduce question/error related :disappointed:

Question: why do I have to keep clicking on 'configure webhook' for devices to work..When I add a new device it pics up the initial state (e.g. motion inactive, but does not update, the only way around this is to click 'configure webhook' when adding each device.

Do have makerapi set to post events ?
image



Yep, It was 2 new devices I connected that were not posting events, but they do now and work fine. I've just had to do it a few times on a couple of instances of adding a device node

Make sure there are no "spaces" before the http part of it, or at the end. That has happened a few times and broke the webhook connection.