I can select the valve and start it. A button (tap action) calls a script that calls the esphome service defined in the api configuration. I can select the valve number or I can select a duration, but I can’t do both.
Any tips here would be appreciated.
Here is the esphome api:
api:
services:
- service: start_single_valve
variables:
valve: int
then:
- sprinkler.start_single_valve:
id: lawn_sprinkler_ctrlr
valve_number: !lambda 'return valve - 1;'
- service: start_valve_with_duration
variables:
duration: int
then:
- sprinkler.start_single_valve:
id: lawn_sprinkler_ctrlr
valve_number: 0
run_duration: !lambda 'return duration;'
Here are my Lovelace cards:
type: vertical-stack
cards:
- type: entities
entities:
- entity: input_number.sprinkler_valve_number
- entity: input_number.sprinkler_zone1_run_duration
title: Valve Number
- type: button
show_name: true
show_icon: true
tap_action:
action: call-service
service: script.start_sprinkler_valve
name: Start selected valve
- type: button
show_name: true
show_icon: true
tap_action:
action: call-service
service: script.start_sprinkler_valve_with_duration
name: Start Valve 1 for selected seconds
Here is the script that calls the esphome service to run a selected valve number:
alias: Start Sprinkler Valve
sequence:
- service: esphome.sprinkler_controller_1_start_single_valve
data:
valve: "{{ states('input_number.sprinkler_valve_number') | int }}"
mode: single
icon: mdi:sprinkler
And finally the script that calls the esphome service to set the duration for a hard-coded valve number:
alias: Start Sprinkler Valve with Duration
sequence:
- service: esphome.sprinkler_controller_1_start_valve_with_duration
data:
duration: "{{ states('input_number.sprinkler_zone1_run_duration') | int }}"
mode: single
As I said, either function works alone, but I can’t find a way to combine them.