I think the problem is the switch cant do the templateing on the payload
so
what about change it to a switch template and then using a script to pass a data
some like
im just doing this off top of head need some testing and beater logic
and this would be my work flow getting the problem sorted
- platform: template
switches:
garden_sprinkler:
friendly_name: 'Garden Sprinkler'
value_template: '{{ need some logic to check the state }}'
turn_on:
service: script.turn_on
data:
entity_id: script.garden_sprinkler_on
turn_off:
service: script.turn_on
data:
entity_id: script.garden_sprinkler_off
thats the switch bit done know the payload bit (script)
garden_sprinkler_on:
alias: Garden Sprinkler on
sequence:
- service: mqtt.publish
data_template:
topic: outside/lawn/action
payload: "{zone: 0, time: {{ states('input_number.how_long') | multiply(60) }} }"
garden_sprinkler_off:
alias: Garden Sprinkler off
sequence:
- service: mqtt.publish
data_template:
topic: outside/lawn/action
payload: "{zone: 0, time: 0}"
still can’t think of the logic of the check for if it ON
and yes could of used choose but that would be mark2 and once I get my head around it
thinking …
EDIT: ADDED
what about a input_boolean
garden_sprinkler:
name: Garden Sprinkler
initial: off
then we can add the
- data:
entity_id: input_boolean.garden_sprinkler
service: input_boolean.turn_on
to the on script
and
- data:
entity_id: input_boolean.garden_sprinkler
service: input_boolean.turn_off
to the off script
now we can change the
value_template: '{{ need some logic to check the state }}'
to
value_template: input_boolean.garden_sprinkler
thats my 5 cents
updated script
garden_sprinkler_on:
alias: Garden Sprinkler on
sequence:
- service: mqtt.publish
data_template:
topic: outside/lawn/action
payload: "{zone: 0, time: {{ states('input_number.how_long') | multiply(60) }} }"
- data:
entity_id: input_boolean.garden_sprinkler
service: input_boolean.turn_on
garden_sprinkler_off:
alias: Garden Sprinkler off
sequence:
- service: mqtt.publish
data_template:
topic: outside/lawn/action
payload: "{zone: 0, time: 0}"
- data:
entity_id: input_boolean.garden_sprinkler
service: input_boolean.turn_off