Faecon
(Jo)
1
I have 4 buttons with the same script. I want to pass a variable… but how can I check in the script for the variable ?
tap_action:
action: call-service
service: script.audio_ruimte1_play
service_data:
option: optie1
tap_action:
action: call-service
service: script.audio_ruimte1_play
service_data:
option: optie2
...
koying
(Chris B)
2
At least I don’t understand what you’re asking for, exactly
Faecon
(Jo)
3
I want to know if it is possible to make 1 script for 4 buttons… Bu giving a variabele to the script and then use an if else structure ?
tom_l
4
1 Like
Faecon
(Jo)
5
Thanks mate, but I don’t have a clue…
I’ve made a tapaction
tap_action:
action: call-service
service: script.audio_ruimte1_play
service_data:
option: optie1
and made a field “option” in my script.
Then I think I have to test a value template. But how do I check that ?
Faecon
(Jo)
6
Hi tom,
can you give me a hint ?
When I press a button I want to pass a value to a script. In that script I want to test what value it is by if else structure
if value is "optie1 " then…
if value is “optie2” then…
Faecon
(Jo)
8
Now I have this in my script…
service: climate.turn_on
metadata: {}
data: {}
target:
entity_id: climate.ruimte1
is it possible to give the entity_id the name : climate.FIELD ?
i was thinking like climate.{{option}} because my field is named option, but that does not work
koying
(Chris B)
9
Please post the full script
Faecon
(Jo)
10
alias: airco
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{option == 'ruimte1.verwarmen'}}"
alias: verwarmen
sequence: []
alias: verwarmen
- conditions:
- condition: template
value_template: "{{option == 'ruimte1.koelen'}}"
sequence: []
alias: koelen
- conditions:
- condition: template
value_template: "{{option == 'ruimte1.airco'}}"
sequence:
- if:
- condition: state
entity_id: climate.ruimte1
state: "off"
then:
- service: climate.set_temperature
data:
temperature: "{{ states('input_number.aline_airco')| float(0) }}"
target:
entity_id: climate.ruimte1
- service: climate.set_swing_mode
metadata: {}
data:
swing_mode: Horizontal
target:
entity_id: climate.ruimte1
- service: climate.set_fan_mode
metadata: {}
data:
fan_mode: Auto
- service: climate.turn_on
metadata: {}
data: {}
target:
entity_id: climate.ruimte1
else:
- service: climate.turn_off
metadata: {}
data: {}
target:
entity_id: climate.ruimte1
alias: Ruimte 1
description: ""
fields:
option:
name: option
where it is climate.ruimte1 i want to change it in the fieldsnamevalue…
koying
(Chris B)
11
Not sure where you got that from. Reread the documentation about variables I posted
Faecon
(Jo)
13
i was thinking something like this :
value_template: "{{ is_state("climate.{{"option"}}", 'off') }}"