Node-RED nodes for hubitat

thanks @JasonJoel, thanks for all of your inputs! :+1::love_you_gesture:

I'll go back to @fblackburn first example and give it another go this time.
Just wondering if there's a way to get/monitor the "power" attribute of a power plug?

If it shows up as an attribute on the attribute list on the device node, I would think so... If not, then probably not (at least not currently)?

okay, I can't seems to find that attribute list, is it within the device node?
image

Sorry, I said it wrong. All events for the device should show up as an output. So run that into a filter and filter out the event you are looking for. Then you should be able to do whatever you want to with the value.

See the OP, I believe he uses filter blocks similarly in his example.

thanks. so do you mean that if it doesn't show within the complete payload output, then there's nothing much I can do for now?

No you can request it with an input message with the property attribute=power. In the first post example, you can see that I requesting the attribute=switch to know the state of the outlet

I'm using with docker, no issue.

So I created my first Node-RED sequence - and it WORKED! Pleased as punch.

A big thank you to @fblackburn @JasonJoel @Vettester - your instructions helped me get this running in less than 10 minutes.

Obviously, I still have an enormous amount to learn, but I think in the long run, I will be able to move my automations to run on separate hardware.

FWIW, my crummy first automation was to turn on a color bulb and then turn it red.

A minuscule step for you folks, but a giant leap for this fool!

7 Likes

New version 0.0.15 :tada:

  • New mode node (thank you to @btk)
    A node that stores and can send the current mode (Day, Night, ...) of your Hubitat hub.

You must enable Include location events to be sent by POST? in Maker API

3 Likes

It seems my NodeRED issue is to do with username/passwords, even though I believed that was disabled.
I can get around it by totally disabling all security but...

Do you know if it should be possible to include credentials in the POST url ?
http://username:password@192.168.1.50:8080/hubitat/webhook?

I don't know, it's my next reading. But it would be nice !!
Do you expose NodeRED on internet or hostile user (like a family lol)?

Well - I had access via DuckDNS and port forwarding - but I have now disabled both with having to remove passwords. I prefer to use this NodeRED as it's on a powerful machine.

Updated to v15 - the application ID was purged so the nodes were in error. If you're using HomeAssistant what I noticed was you can't install or edit nodes via the HA NabuCasa remote https url to NodeRED - they stay in error and the dropdowns have no devices. You must use a local url to NodeRED and then it all works well.

BTW control works from either - you just can't edit.

New mode node seems to work as expected. Thanks!

Hi @fblackburn @JasonJoel @Vettester @kevin,

Thanks for all of your help so far.

I've now managed to get things slowly working, but I'm trying to get my head around the payload for my power plug.

I'm trying to get reading of power, but all payload output seems to have no topic nor they're integers. they all seems to be in strings.

I believe there's a way to convert string to number using json byt the value as a letter behind the number.
can anyone please advise the best way for this? do i need to inject a topic? if yes how?
thanks

Lots of ways to do it. You could run the message into a function node and do it in javascript. Something like:
msg.payload.currentValue = parseFloat(msg.payload.currentValue);
return msg;

Or you could run the message into a change node and do something like:
Set --> msg.payload.currentValue
to: $number(payload.currentValue)

Thanks Jason.

I've tried the 2nd one b4, since the currentValue is STRING e.g 3 VAr, I believe the output became NaN when i tried it last time.

I've just tried the first one (parseFloat), the output became like this
image

but because each of the payload output has similar "sub payload" (sorry for my lack of using the correct terminology) :laughing:

if you see the output above, the path of each of the payload is the same, so how can I set a tag to differentiate each of them? so that I can then target the one that I need? because at the moment, if I target currentvalue, it will output all the currentvalue for each payload.
Hope I'm making sense here.

If you want you could try this node, it will convert a string to float.

1 Like

I'm still not getting 100% what you are trying to do... But if you only want to convert/pass SOME of the events, then add that to the function node's code....

something like
if msg.payload.name == "current"
{
msg.payload.currentValue = parseFloat(msg.payload.currentValue);
return msg;
}

Or kill the original message and shove the value in msg.payload...

Feature request if you get bored....

Make a toggle option to use the defined device name as node name instead of the default "device" or "command".