Sorry to bother you, I need to create a couple of simple switches with on an off commands using scripts.
I’ve search for hours and decided to ask for help here:
Should I use template switches? How can I set it to start on OFF (if HA restarts) and then keep the switch locked when toggled on and off on their respective position?
A template switch would only be used if you were using some other entity to determine the state.
The easiest way to do what you want is to use an input_boolean.
Then create an automation based on that.
Here’s an example:
input_boolean
run_sprinklers_now:
name: Run Sprinklers Now
initial: off
automation:
- alias: autoSprinklers
trigger:
- platform: state
entity_id: input_boolean.run_sprinklers_now
to: 'on'
action:
- service: shell_command.rsprinklers