A script is basically a manually triggered automation, although structured a little differently
I have to be honest. I don’t know. I’ve never tried such a bizzare thing.
But what you are doing is trying to use an V8 engine in an electric toothbrush
It just not the tool for the job
ahahahaha got it
I see, nevertheless for now its working like intendent.
I have a lot of automation, but its doint its job.
If somebody have problem with switching template buttons and trigger switching from the button, connect with the condition with automation, PM me as my solution is complex and i am pretty sure could have been solved easily by different way.But what a hell its working and dont want to waste more than 4hours i already did to solve it
Okay, from your last post I gather that english is not your first language, I have to say you were doing very well upto that last one
Scripts are just like the automations : -
Just click on Scripts - to manage scripts and then the ‘+’ button to add one
I use packages so mine would look a bit different : -
script:
- sc_siren02_sound:
alias: Siren 02 Sound
sequence:
- condition: state
entity_id: binary_sensor.bs_occupancy_mark
state: 'on'
- condition: template
value_template: "{{ is_state('input_boolean.ib_siren_permisive_override', 'on') or is_state('binary_sensor.bs_global_noise_permissive', 'on') }}"
- delay: "00:00:01"
- service: switch.turn_on
entity_id: switch.shenzen_siren02_switch
- delay: "00:00:{{ states('input_number.in_siren02_drtn') | int }}"
- service: switch.turn_off
entity_id: switch.shenzen_siren02_switch
Things to note here, the dashes denote list items so this goes in my announciation package and ‘other’ scripts follow it, Also in the package are automations, input_numbers etc. all to do with announciation.
Your scripts (using the gui editor would go in /config/scripts.yaml and WOULDN’T have a script: key. yours would also have an id: so would probably look like this : -
- id: 'scripttoreplacev8toothbrush'
alias: rolety_number_increase_test_4
sequence:
- service: switch.turn_on
data: {}
entity_id: switch.rolety_channel_change
- delay: 00:00:01
- service: switch.turn_off
data: {}
entity_id: switch.rolety_channel_change
- delay: 00:00:01
- repeat:
until:
- condition: template
value_template: "{{ (states('input_number.slider1') != states('input_number.slider2') }}"
sequence:
- service: switch.turn_on
data: {}
entity_id: switch.rolety_channel_change
- delay: 00:00:01
- service: switch.turn_off
data: {}
entity_id: switch.rolety_channel_change
- service: input_number.increment
data: {}
entity_id: input_number.slider1
- delay: 00:00:01
default: []
mode: single
Again, things to note : -
- you use states.input_number.slider1.state
- I use states(‘input_number.slider1’)
- Mines shorter
- Mine is more resilient during startup where states are being estanblished and will cause a LOT fewer errors
- Mine has extra spaces in it to make it easier to read and thus degug and maintain
- Look how common the code is between the two, this is because the action part of automations and the sequence part of scripts is run by the ‘same’ HA code
- you may not be able to add comments or space stuff as I’ve shown but you ‘can’ get close and the good coding habits will stick with you as you develop.
- Ditch the automation, run with the script
- I couldn’t test this so run the two in parallel until you are happy
What a hell man, you explained to me scripts in 1 post xD thx