wmulder
(Willem Mulder)
November 10, 2020, 6:00pm
1
I am a starter with a home assistant.
I have a question about controlling a script
On an action of a button:
tap_action:
action: call-service
service: script.change_schedule_livingroom
service_data:
program: ‘12’
With this code my script works
Now I want to change the code to now (). weekday () + and button number
How do I get this working
Is dit de juiste plaats om dit soort vragen te stellen ??
fahr
(Aaron)
November 11, 2020, 4:40am
2
You will need to either use a custom card or include the data you want to template in your script. See How to use template in service_data?
wmulder
(Willem Mulder)
November 11, 2020, 7:54am
3
My button
type: “custom:button-card”
color_type: button-card
entity: input_boolean.woonkamer_weg
name: Weg
icon: mdi:logout
styles:
card:
- height: 75px
tap_action:
action: call-service
service: script.wijzig_regeling_woonkamer
service_data:
programma: 11 (i need now().weekday() + “1” for this button)
My script
wijzig_regeling_woonkamer:
alias: wijzig_regeling_woonkamer
sequence:
- service: input_text.set_value
data_template:
entity_id: input_text.woonkamer_stap
value: ‘{{ programma }}’
fahr
(Aaron)
November 12, 2020, 5:05pm
4
I think it would be easier to use the lovelace-card-templater for this.
- type: "custom:card-templater"
entities:
- input_boolean.woonkamer_weg
card:
type: button
name: Weg
tap_action:
action: call-service
service: script.wijzig_regeling_woonkame
service_data:
programma_template: >
{{ now().weekday() + 1 }}
wmulder
(Willem Mulder)
November 16, 2020, 6:25pm
5
It works fine now.
Thanks for your help.
If there’s something else I can hopefully ask you again