aswieton
(Artur Świętonowski)
1
Hi I try to pass url in html5 notify from automation to script using data_template. Below are part of automation and script.
**Automation:**
- alias: 'Camera - move detect'
initial_state: True
trigger:
- platform: state
entity_id:
- sensor.kartur_events
- sensor.kganek_events
- sensor.ksypialnia_events
- sensor.kparter_events
action:
- service: script.message_notify
data_template:
title: Informacja
message: 'Wykryto ruch na kamerze {{ trigger.from_state.attributes.friendly_name }}'
data:
url: 'some url'
**and Script**
message_notify:
alias: "Message notify script"
sequence:
- service: notify.html5_notify
data_template:
title: "{{ title }} - "
message: "{{ message }}"
data:
url: "{{ url }}"
All above works except url value which are simply ignored. Can you help with this? I try a lot of combination but without success.
cgtobi
(Tobi)
2
Please use code blocks and syntax highlighting when posting config snippets.
cgtobi
(Tobi)
3
Did you try the notification right in the automation rather than as a script?
aswieton
(Artur Świętonowski)
4
Yes and it works but I want to have generic notify script
petro
(Petro)
5
it’s because of the way you are passing the variables. The shape of the data template when passing variables is different then when using them:
keep your script the same. this should be your automation data:
- service: script.message_notify
data_template:
title: Informacja
message: Wykryto ruch na kamerze {{ trigger.from_state.attributes.friendly_name }}
url: 'some url'
cgtobi
(Tobi)
6
Take a look at how to pass variables to scripts.
Maybe something like this works:
action:
- service: script.turn_on
entity_id: script.message_notify
data:
variables:
title: Informacja
message: 'Wykryto ruch na kamerze {{ trigger.from_state.attributes.friendly_name }}'
url: 'some url'
petro
(Petro)
7
Close, You need to change data to data_template. I forgot ‘variables’ in my example:
action:
- service: script.turn_on
entity_id: script.message_notify
data_template:
variables:
title: Informacja
message: 'Wykryto ruch na kamerze {{ trigger.from_state.attributes.friendly_name }}'
url: 'some url'
1 Like
aswieton
(Artur Świętonowski)
9
thank you for your help it works perfectly!
1 Like