HI,
Trying this script with data_template to show up the switches friendly name, without succes…
What do i need to change here please:
script:
arrive_home:
alias: Arrive Home
sequence:
- service: switch.turn_on
entity_id: switch.sw_tester_cl
- service: notify.ios_telefoonmhb
data_template:
message: "Je bent thuis, het script werkt en {{"switch.sw_tester_cl.attributes.friendly_name" }} staat aan."
btw, the script runs when i get home turns on the switch, and tells me so, but doesn’t show the bit after ‘werkt’.
unhide it from the frontend?
Cheers,
Marius
VDRainer
(🍻)
2
Try {{ states.switch.sw_tester_cl.attributes.friendly_name }}
2 Likes
thank you!
please have a look at another:
trying to have the triggered time show up in the message title:
Templates are rendered using the Jinja2 template engine with some Home Assistant specific extensions.
using this code:
data_template:
title: "Activity selection: {{states.input_select.activity.state}} at {{states.input_select.activity.last_changed|timestamp_custom("%D %I:%M %P") }}"
no matter if i add the timestamp bit or not, or change the order or %'s in the timestamp, the displayed time doesn’t change…?
Jinja2 template documentation
Home Assistant template extensions
data_template:
title: “Activity selection: Opstaan at 2018-01-15 06:33:12.396862+00:00”
ive made it this far:
Templates are rendered using the Jinja2 template engine with some Home Assistant specific extensions.
Jinja2 template documentation
Home Assistant template extensions
data_template:
title: “Selected Mode: Normal”
message: “09:37: Normal operation, going concern.”
with this code:
- service: notify.ios_telefoonmhb
data_template:
title: “Selected Mode: {{states.input_select.ha_mode.state}}”
message: “{{ as_timestamp(states.input_select.activity.last_updated) | timestamp_custom(”%H:%M") }}: Normal operation, going concern."
Inspector showing a nice result!
Still, the error-log gives me this:
while scanning for the next token
found character '%' that cannot start any token
in "/config/scripts/scripts_mode_selection.yaml", line 33, column 98
seems the " " are placed incorrectly?
found the solution:
data_template:
title: "Selected Mode: {{states.input_select.ha_mode.state}} at {{ as_timestamp(states.input_select.activity.last_updated) | timestamp_custom ('%H:%M') }}"
message: "{{ as_timestamp(states.input_select.activity.last_updated) | timestamp_custom ('%H:%M') }}: Normal operation, going concern."
single quotes…
1 Like