#And what s the data in the render node

1 messages · Page 1 of 1 (latest)

lavish cargo
#

i couldn't determine how to access any of the msg.payload information from within the ha render template node, so i was adding it in a node red template node. would simplify if i could just access the msg from the template in the ha render templat enode... am i missing something?

#

basically... a binary_sensor gets flopped and i generate a note of when it changed and who changed it. i was using the ha render template to output a log

lament pelican
#

Send me a screenshot of the nodes please.

#

Just the flow, not the content...not yet anyway

lavish cargo
#

lots of debug stuff... not much more than what you had in your screenshot.

lament pelican
#

Do you have those debug nodes set to "complete msg object"?

lavish cargo
#

sure do

lament pelican
#

Can you send me a screenshot of the debug output and the data you want to access within it?

lavish cargo
#

node red template ```{{ data.event.new_state.attributes.friendly_name }} has been {% if ({{ payload}}) %}Enabled{% else %}Disabled by {% endif %}
{{=<% %>=}}
{{ states.person|selectattr("attributes.user_id", "==", "{{ data.event.new_state.context.user_id}}")|map(attribute="attributes.friendly_name")|first }}

#

almost there... debug 3 has everything except the person's name.

lament pelican
#

that's enough

#

you're just trying to access that template section, correct?

lavish cargo
#

within the ha render template? that would be ideal. I didn't think i could.

lament pelican
#

Is there anything relevant in Debug 1 when you expand topic?

lavish cargo
#

in debug 1 there is the variables that i'm using in the node template. it's the trigger.

#

(yes)

lament pelican
#

But the template doesn't exist in the flow object until after the template node...and the template is what you want, isn't it?

lavish cargo
#

I'm not sure i agree with that... basically i'm converting this automation from ha to node-red. does that help make things clear?

lament pelican
#

yes, that does help

lavish cargo
#

the one caveat is that this automation is triggering based on the state of an automation, the new node-red flow is triggering based on an input_binary.

lament pelican
#

Looks like you want to get notified via Discord every time a certain window is opened or closed

lavish cargo
#

already have that. and my thing works great for that... this is to build on that... we have a switch that allows us to silence it, and we want to know when the "dnd" is enabeld or disabled.

lament pelican
#

oh, that's easy...if I get you.

lavish cargo
#

the ha equiv of that was UGGGLY. so... i'm loving the power of NR so far... but some little things like this seem a bit ... convoluted.

#

i think i'm over-complicating it though

lament pelican
#

You are....hang on

#

In HA, Settings -> Helpers -> Create Helper -> Toggle

#

Call it something like "Window Notification Enabled"

lavish cargo
#

already got one 🙂

#

input_boolean.opened_alert_discord

#

i'm ha old-school though so i made it via yaml but...

lament pelican
#

Okay, now insert a current state node after your very first node

#

Now the state of the window can change all it want, it won't get through the newly added current state node if the toggle is set to False.

lavish cargo
#

already have all that... i just need to know when THAT input_boolean is switched

#

i want to output to discord that it was silenced

#

buuut the only complexity is to know WHO did it

lament pelican
#

Oh, so if the input_boolean is toggled, notify via Discord?

lavish cargo
#

right.

#

should be easy, but gotta pull information from a ha-render template

#

{{ states.person|selectattr("attributes.user_id", "==", "{{ data.event.new_state.context.user_id}}")|map(attribute="attributes.friendly_name")|first }}

#

so i gotta pass the data.event.new_state.context.user_id to the template to render in ha.

#

then take whatever it rendered and output that to discord.

lament pelican
#

k, give me a few.

lavish cargo
#

❤️

lavish cargo
#

It may not be the cleanest... but i think i figured it out

#

node template ```{{ data.event.new_state.attributes.friendly_name }} has been {% if ({{ payload}}) %}Enabled{% else %}Disabled{% endif %}by {{=<% %>=}}{{ states.person|selectattr("attributes.user_id", "==", <%={{ }}=%>"{{ data.event.new_state.context.user_id}}")|map(attribute="attributes.friendly_name")|first }}

#

only thing left:

#

tripple curly brackets. all fixed. Thank you for your help CHris!