Node-RED nodes for hubitat

So I have this object:


and I want an array of just the payload.songs,id parts.

{["music_86808","music_91627"]}

Any suggestions on nodes to use?

Easiest would probably just use a function node and do a foreach to cycle through the songs array..

1 Like

Or maybe the template node...

see "mustache templates"..

1 Like

Also consider the split and join nodes. They work really well for this purpose.

For example I can take a list like this:

And process it into something like this, which is convenient to send as an SMS:

1 Like

I love that there are so many ways to handle stuff in NR. Really shows the flexibility and power...

1 Like

Yup.

That output is actually from a set of sequences that are super-useful to me. I use the Alexa app to add things to various shopping lists (eg. Grocery, Pharmacy, Costco). When OwnTracks detects that I am in the vicinity (100 ft) of the appropriate place, I use alexa2-remote (or cakebaked now) to retrieve the correct list, process it, and send it as an SMS to myself. Which shows up on my watch ...

Helps protect me from my own absent-mindedness!

3 Likes

That is so cool - I have had a love hate relationship with OwnTracks on Android. Hard to figure out which mode to be in. Right now just using Unifi node to detect when our phones are connected to our WiFi. With MAC protection set off for each of our phones of course.

1 Like

I have pretty much stopped using other methods of geofencing, except to detect when my car is approaching the house.

If you ever try it again, tt works well for me with this situation

  1. I have a constant wireguard connection back to my house (whether I am on WiFi or cell)
  2. Using MQTT with a password but no encryption. Mosquitto is not exposed outside of my LAN, so that's ok.
  3. Turn off ranging and extended data.
2 Likes

Mmm food for thought thanks!!! Gotta love WireGuard. I frequently forget that I'm still connected on my phone from time to time. I guess to your point no reason not to be given the speed and security implications..

1 Like

Wireguard is great except for on all the networks I use that block outbound udp (which is a surprising number of wifi)... Then I have to fall back to openvpn anyway.

2 Likes

That's a shame. My primary use is to connect back home. When I connect to work, I use a reverse-ssh tunnel.

1 Like

I wonder if that's my issue with the TMobile Hotspot... when I connect with my laptop I cannot use WG. I do have openvpn on my firewall so maybe will give that a shot too..

edit: I wonder if something like UDP2Raw or udptunnel would work...

Jsonata can do this easy. I think it would be as simple as payload.songs.id the default example on try.jsonata.org is almost exactly this.

1 Like

Woohoo the jsonata worked! Thanks!

3 Likes

Very cool!!! can you post the jsonata code?

Here you go

Next up: figuring out how to delete the dsaudio queue instead of appending. One step closer to automating my music using a Synology and Chromecast

1 Like

Embarrassed to say I did not realize JSONATA could operate across an array of objects like that.. just tested and works great - fun stuff. Thanks @durable-navy-blue-ot & @napalmcsr!!

2 Likes

Node-red: Do node

Anyone know why I am getting this error in the debug log?

"Missing meta data for returning to do-node. Flow ends here."

The flow is:

And the "do-node" config is:

I originally had the link out node on the last output of the do-node and I thought that may have been the problem, so added another task (Get Chart Data) and attached the link out to that output, but that did not get rid of the error in the debug. The flow works correctly, just logs this error in the debug pane. Thanks for your help.

I would assume the issue is the link out node. Each task needs a completion - can you add a "done" alongside the link maybe?

1 Like

Also to make things even more fun - have you seen action flows?

2 Likes