#And what s the data in the render node
1 messages · Page 1 of 1 (latest)
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
Send me a screenshot of the nodes please.
Just the flow, not the content...not yet anyway
lots of debug stuff... not much more than what you had in your screenshot.
Do you have those debug nodes set to "complete msg object"?
sure do
Can you send me a screenshot of the debug output and the data you want to access within it?
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.
within the ha render template? that would be ideal. I didn't think i could.
Is there anything relevant in Debug 1 when you expand topic?
in debug 1 there is the variables that i'm using in the node template. it's the trigger.
(yes)
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?
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?
yes, that does help
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.
Looks like you want to get notified via Discord every time a certain window is opened or closed
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.
oh, that's easy...if I get you.
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
You are....hang on
In HA, Settings -> Helpers -> Create Helper -> Toggle
Call it something like "Window Notification Enabled"
already got one 🙂
input_boolean.opened_alert_discord
i'm ha old-school though so i made it via yaml but...
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.
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
Oh, so if the input_boolean is toggled, notify via Discord?
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.
k, give me a few.
❤️
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!