Node-RED nodes for hubitat

Like maybe some input msg flag that sends everything in the cache. I can see a few uses for that... Deciding on the format of the payload would be interesting though.

I would vote for:
payload: {
attribute name 1: value,
attribute name 2: value,
...
}

But if we think we need dataType, etc, in there then it would have to be something similar to how Maker API returns the values, in an array. The bad part about that is that Maker API returns it with just an indexed array, so you have to check each element of the array to know what the attribute type is.

This is the Maker API response format. The array levels being indices are annoying:

If it came down to an array, doing it like Maker API could work - but with a twist... Just use attribute name for the array tree level instead of "0", "1", "2", etc. I "think" that is possible...

Then users could just do msg.payload.level.value or msg.payload.switch.value, etc. And not have to search or walk the array to find the value they want.

Something like this for msg.payload:

{
    "level": {
        "value": 50,
        "dataType": "NUMBER"
    },
    "switch": {
        "value": "on",
        "dataType": "ENUM"
    }
}
1 Like

Maybe like an info node or something. Yeah I was thinking an array in the payload dunno if thats a good NR way of doing it though.

edit: Ninjad by JJ!!!!!! like your idea.

1 Like

Bah. You are doing all the real work. I'm so lazy I haven't even been issuing PRs like @dan.t has.

2 Likes

Yeah the list is annoying to parse .. it was on my todo list to change the way to store internal data exactly as you propose. And I think it's a good idea to expose it like this

Considering that it takes me 10 times longer to write in English than writing code, then your help is a huge contribution of real work :wink:

5 Likes

Is there a method to shut down/reboot HE hubs from within Node Red. I currently do it from within my synology app, but am trying to bring all house control over to Node Red, so I know where everything is.

Use and http out node to post a command the the hub... there’s a thread from today in the forum that has the url in it

4 Likes

Here's an example for a shutdown URL in the http request node

shutdown

2 Likes

So for folks with a bunch of unused peanuts and an almond 2015 router (or hacked fake one) lying around you might actually be able to use them again - turns out the almond does websockets... so you can maybe control it and it's devices through NR..... :exploding_head: :exploding_head:

https://forum.securifi.com/index.php?topic=5696.0

edit: might be a good "shed" project or something. :grinning:

FYI, if you do have a bunch of Peanuts sitting idle and do not have a Almond Router but would like to try this suggestion, you can get the Homescreen for $15 and flash it with the Almond 2015 firmware.

Is anyone using "Match Regex" in switch nodes? I am trying to use it to take all of my MQTT messages and redirect them to the right Command Nodes to do things in one big sequence. However, I am struggling with it. Right now, I do it with 15 MQTT In Nodes.

For the first switch node, I want to send any messages starting "tele" to go one route, starting "stat" to go another, then all others to go a 3rd. I found this website, Simple RegEx Tutorial, touting itself as "Simple RegEx Tutorial" but I must be doing something wrong. After reading that site, I thought it would be as simple as "^tele" for option 1 and "^stat" for option 2. When I try this, nothing is passed thru those 2 branches of the Switch Node. What elementary mistake am I making?

I'm using it a lot. Here's an example of a node using it ....

In this case "off" goes to output-1 and anything other than "off" goes to output-2 ...

Screen Shot 2020-04-09 at 11.45.02 AM

I use this site www.regextester.com to test my expressions.

1 Like

Couldn't you just use "otherwise" for output 2?

4 Likes

@stephen_nutt

Screenshot 2020-04-09 12.57.55

[{"id":"331813e6.77062c","type":"inject","z":"b1c0e8f3.379a68","name":"Tele","topic":"","payload":"tele-front-1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":760,"wires":[["faf0c055.fc6f8"]]},{"id":"2335bc15.d28924","type":"inject","z":"b1c0e8f3.379a68","name":"Stat","topic":"","payload":"stat-back-3","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":820,"wires":[["faf0c055.fc6f8"]]},{"id":"5626aac6.ddcd54","type":"inject","z":"b1c0e8f3.379a68","name":"Other","topic":"","payload":"Some other value","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":880,"wires":[["faf0c055.fc6f8"]]},{"id":"faf0c055.fc6f8","type":"switch","z":"b1c0e8f3.379a68","name":"","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"^tele.+$","vt":"str","case":false},{"t":"regex","v":"^stat.+$","vt":"str","case":false},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":330,"y":820,"wires":[["887f51f.403ffb"],["c259b13e.9339b"],["23fb77a2.228ee8"]]},{"id":"b48e3304.87a31","type":"debug","z":"b1c0e8f3.379a68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":690,"y":840,"wires":[]},{"id":"887f51f.403ffb","type":"change","z":"b1c0e8f3.379a68","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Tele Branch","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":475,"y":800,"wires":[["b48e3304.87a31"]],"l":false},{"id":"c259b13e.9339b","type":"change","z":"b1c0e8f3.379a68","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Stat Branch","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":475,"y":840,"wires":[["b48e3304.87a31"]],"l":false},{"id":"23fb77a2.228ee8","type":"change","z":"b1c0e8f3.379a68","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Other","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":475,"y":880,"wires":[["b48e3304.87a31"]],"l":false}]

I could have - if I had known of "otherwise". Missed that completely!

1 Like

Turn on Ignore case. Tele will not match ^tele?

Yeah... what is in the screen shot is just the label, not the value....

I'm a RegEx junkie, I do something with it at least 10 times a day with Work stuff

2 Likes

Thanks it's a little clearer now. First switch node down, just a couple of more to go.

1 Like

Trivial cosmetic bug (unless it is on purpose, and a feature?) on device node.

image

A device node that updates from an unsolicited event looks like the top node in the picture. Note that the switch state is "off" (with quotation marks).

A device node that had an incoming message that triggers a node output message, looks like the bottom node. Note that the switch state is off (without quotation marks).

Both of those nodes have the same device and attribute specified.

1 Like

No distinction for numbers so I guess not a feature.. however it might be good to visually distinguish in some way so it helps troubleshoot things like you forget to uncheck "send events"...

The colored blue shape is filled in/solid if send events is checked, a hollow/unfilled shape if send events in unchecked. For the ones in my pic, send events was not checked, and thus the empty shape/donut.

1 Like