janb2
(Jan)
January 4, 2026, 5:33am
1
kindly assist i keep on getting an error in the following line when compiling: return id(lawn_sprinkler_ctrlr)->valve[0]->run_time_remaining() / 60.0f
Blockquote
esphome:
name: irrigation
friendly_name: Irrigation
esp32:
board: esp32dev
framework:
type: arduino
Enable logging
logger:
Enable Home Assistant API
api:
encryption:
key: “8utVPTBUl/Wdj1toKLosz7lgyabFU2iN5i/y8k4rPwM=”
ota:
platform: esphome
password: “6981dbc0a22c860bede34a9b567225f5”
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.8.111
gateway: 192.168.8.1
subnet: 255.255.255.0
Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: “Irrigation Fallback Hotspot”
password: “APOsweW0dgfS”
captive_portal:
binary_sensor:
platform: status
name: “Irrigation Controller Status”
id: irrigation_controller_status
sprinkler:
id: lawn_sprinkler_ctrlr
main_switch: “Sprinklers”
auto_advance_switch: “Sprinklers Auto Advance”
reverse_switch: “Sprinklers Reverse”
multiplier_number: “Sprinkler Multiplier”
repeat_number: “Sprinkler Repeat”
valve_overlap: 5s
valves:
valve_switch: “Zone 1”
enable_switch: “Enable Zone 1”
run_duration_number: “Zone 1 Run Duration”
valve_switch_id: lawn_sprinkler_valve_sw0
valve_switch: “Zone 2”
enable_switch: “Enable Zone 2”
run_duration_number: “Zone 2 Run Duration”
valve_switch_id: lawn_sprinkler_valve_sw1
valve_switch: “Zone 3”
enable_switch: “Enable Zone 3”
run_duration_number: “Zone 3 Run Duration”
valve_switch_id: lawn_sprinkler_valve_sw2
valve_switch: “Zone 4”
enable_switch: “Enable Zone 4”
run_duration_number: “Zone 4 Run Duration”
valve_switch_id: lawn_sprinkler_valve_sw3
valve_switch: “Zone 5”
enable_switch: “Enable Zone 5”
run_duration_number: “Zone 5 Run Duration”
valve_switch_id: lawn_sprinkler_valve_sw4
valve_switch: “Zone 6”
enable_switch: “Enable Zone 6”
run_duration_number: “Zone 6 Run Duration”
valve_switch_id: lawn_sprinkler_valve_sw5
valve_switch: “Zone 7”
enable_switch: “Enable Zone 7”
run_duration_number: “Zone 7 Run Duration”
valve_switch_id: lawn_sprinkler_valve_sw6
valve_switch: “Zone 8”
enable_switch: “Enable Zone 8”
run_duration_number: “Zone 8 Run Duration”
valve_switch_id: lawn_sprinkler_valve_sw7
switch:
platform: gpio
id: lawn_sprinkler_valve_sw0
pin: GPIO03
inverted: True
platform: gpio
id: lawn_sprinkler_valve_sw1
pin: GPIO13
inverted: True
platform: gpio
id: lawn_sprinkler_valve_sw2
pin: GPIO14
inverted: true
platform: gpio
id: lawn_sprinkler_valve_sw3
pin: GPIO04
inverted: true
platform: gpio
id: lawn_sprinkler_valve_sw4
pin: GPIO05
inverted: true
platform: gpio
id: lawn_sprinkler_valve_sw5
pin: GPIO16
inverted: true
platform: gpio
id: lawn_sprinkler_valve_sw6
pin: GPIO25
inverted: true
platform: gpio
id: lawn_sprinkler_valve_sw7
pin: GPIO26
inverted: true
=========================
TIME REMAINING SENSORS
(Updated from HA)
=========================
sensor:
platform: template
name: “Zone 1 Time Remaining”
id: zone_1_time_remaining
unit_of_measurement: “min”
accuracy_decimals: 1
icon: “mdi:timer-sand”
lambda: |-
// Access the valve directly from the sprinkler controller’s valves array
// Zone 1 corresponds to index
return id(lawn_sprinkler_ctrlr)->valve[0]->run_time_remaining() / 60.0f;
update_interval: 1s
platform: template
name: “Zone 2 Time Remaining”
id: zone_2_time_remaining
unit_of_measurement: “min”
accuracy_decimals: 0
platform: template
name: “Zone 3 Time Remaining”
id: zone_3_time_remaining
unit_of_measurement: “min”
accuracy_decimals: 0
platform: template
name: “Zone 4 Time Remaining”
id: zone_4_time_remaining
unit_of_measurement: “min”
accuracy_decimals: 0
platform: template
name: “Zone 5 Time Remaining”
id: zone_5_time_remaining
unit_of_measurement: “min”
accuracy_decimals: 0
platform: template
name: “Zone 6 Time Remaining”
id: zone_6_time_remaining
unit_of_measurement: “min”
accuracy_decimals: 0
platform: template
name: “Zone 7 Time Remaining”
id: zone_7_time_remaining
unit_of_measurement: “min”
accuracy_decimals: 0
platform: template
name: “Zone 8 Time Remaining”
id: zone_8_time_remaining
unit_of_measurement: “min”
accuracy_decimals: 0
Blockquote
Where did you get this yaml code from? Did this come from AI/LLM, as the spacing is not in yaml format, or has the forum software munged your quoting when you used the </>?
janb2
(Jan)
January 4, 2026, 7:41am
3
yes somehow the spacing got changed i copied it directly out of esphome editor in homeassistant
You are using “blockqoute”, you want to use “preformatted text”
janb2
(Jan)
January 4, 2026, 8:07am
5
esphome:
name: irrigation
friendly_name: Irrigation
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "8utVPTBUl/Wdj1toKLosz7lgyabFU2iN5i/y8k4rPwM="
ota:
- platform: esphome
password: "6981dbc0a22c860bede34a9b567225f5"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.8.111
gateway: 192.168.8.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Irrigation Fallback Hotspot"
password: "APOsweW0dgfS"
captive_portal:
binary_sensor:
- platform: status
name: "Irrigation Controller Status"
id: irrigation_controller_status
sprinkler:
- id: lawn_sprinkler_ctrlr
main_switch: "Sprinklers"
auto_advance_switch: "Sprinklers Auto Advance"
reverse_switch: "Sprinklers Reverse"
multiplier_number: "Sprinkler Multiplier"
repeat_number: "Sprinkler Repeat"
valve_overlap: 5s
valves:
- valve_switch: "Zone 1"
enable_switch: "Enable Zone 1"
run_duration_number: "Zone 1 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw0
- valve_switch: "Zone 2"
enable_switch: "Enable Zone 2"
run_duration_number: "Zone 2 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw1
- valve_switch: "Zone 3"
enable_switch: "Enable Zone 3"
run_duration_number: "Zone 3 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw2
- valve_switch: "Zone 4"
enable_switch: "Enable Zone 4"
run_duration_number: "Zone 4 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw3
- valve_switch: "Zone 5"
enable_switch: "Enable Zone 5"
run_duration_number: "Zone 5 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw4
- valve_switch: "Zone 6"
enable_switch: "Enable Zone 6"
run_duration_number: "Zone 6 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw5
- valve_switch: "Zone 7"
enable_switch: "Enable Zone 7"
run_duration_number: "Zone 7 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw6
- valve_switch: "Zone 8"
enable_switch: "Enable Zone 8"
run_duration_number: "Zone 8 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw7
switch:
- platform: gpio
id: lawn_sprinkler_valve_sw0
pin: GPIO03
inverted: True
- platform: gpio
id: lawn_sprinkler_valve_sw1
pin: GPIO13
inverted: True
- platform: gpio
id: lawn_sprinkler_valve_sw2
pin: GPIO14
inverted: true
- platform: gpio
id: lawn_sprinkler_valve_sw3
pin: GPIO04
inverted: true
- platform: gpio
id: lawn_sprinkler_valve_sw4
pin: GPIO05
inverted: true
- platform: gpio
id: lawn_sprinkler_valve_sw5
pin: GPIO16
inverted: true
- platform: gpio
id: lawn_sprinkler_valve_sw6
pin: GPIO25
inverted: true
- platform: gpio
id: lawn_sprinkler_valve_sw7
pin: GPIO26
inverted: true
# =========================
# TIME REMAINING SENSORS
# (Updated from HA)
# =========================
sensor:
- platform: template
name: "Zone 1 Time Remaining"
id: zone_1_time_remaining
unit_of_measurement: "min"
accuracy_decimals: 1
icon: mdi:timer-sand
update_interval: 1s
lambda: |-
// Safety check: make sure valve exists and is running
if (id(lawn_sprinkler_ctrlr).valves_.size() == 0 ||
!id(lawn_sprinkler_ctrlr).valves_[0].is_running()) {
return 0.0f;
}
// Remaining duration is returned in seconds
return id(lawn_sprinkler_ctrlr)
.valves_[0]
.get_remaining_duration() / 60.0f;
- platform: template
name: "Zone 2 Time Remaining"
id: zone_2_time_remaining
unit_of_measurement: "min"
accuracy_decimals: 0
- platform: template
name: "Zone 3 Time Remaining"
id: zone_3_time_remaining
unit_of_measurement: "min"
accuracy_decimals: 0
- platform: template
name: "Zone 4 Time Remaining"
id: zone_4_time_remaining
unit_of_measurement: "min"
accuracy_decimals: 0
- platform: template
name: "Zone 5 Time Remaining"
id: zone_5_time_remaining
unit_of_measurement: "min"
accuracy_decimals: 0
- platform: template
name: "Zone 6 Time Remaining"
id: zone_6_time_remaining
unit_of_measurement: "min"
accuracy_decimals: 0
- platform: template
name: "Zone 7 Time Remaining"
id: zone_7_time_remaining
unit_of_measurement: "min"
accuracy_decimals: 0
- platform: template
name: "Zone 8 Time Remaining"
id: zone_8_time_remaining
unit_of_measurement: "min"
accuracy_decimals: 0
janb2
(Jan)
January 4, 2026, 8:08am
6
I tried another way but i also cant get this to work/compile
koying
(Chris B)
January 4, 2026, 2:07pm
7
Is this generated by AI?
According to the ESPHome API, the proper way to get the list of valves is id(lawn_sprinkler_ctrlr).valve_
https://api-docs.esphome.io/classesphome_1_1sprinkler_1_1_sprinkler#a1070ffeb9226dc080bdf74792c94724a
Anyway, if you want more help, please specify the actual error you’re getting.
Karosm
(Karosm)
January 4, 2026, 2:52pm
8
.time_remaining_active_valve()
Have a look at the example on docs:
display:
- platform: ...
# ...display configuration...
lambda: |-
if (id(lawn_sprinkler_ctrlr).time_remaining_active_valve().has_value()) {
// the controller is running, print the number of seconds remaining
it.printf(0, 0, "Time left: %u sec.", id(lawn_sprinkler_ctrlr).time_remaining_active_valve().value());
} else {
// the controller is NOT running
it.print(0, 0, "Idle");
}
janb2
(Jan)
January 4, 2026, 4:50pm
9
Please i need help to display the “zone time remaining” per zone…any solution will help to so…i have tried a lot of options but cant get it working.
janb2
(Jan)
January 4, 2026, 4:52pm
10
esphome:
name: irrigation
friendly_name: Irrigation
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "8utVPTBUl/Wdj1toKLosz7lgyabFU2iN5i/y8k4rPwM="
ota:
- platform: esphome
password: "6981dbc0a22c860bede34a9b567225f5"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.8.111
gateway: 192.168.8.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Irrigation Fallback Hotspot"
password: "APOsweW0dgfS"
captive_portal:
sprinkler:
- id: lawn_sprinkler_ctrlr
main_switch: "Sprinklers"
auto_advance_switch: "Sprinklers Auto Advance"
reverse_switch: "Sprinklers Reverse"
multiplier_number: "Sprinkler Multiplier"
repeat_number: "Sprinkler Repeat"
valve_overlap: 5s
valves:
- valve_switch: "Zone 1"
enable_switch: "Enable Zone 1"
run_duration_number: "Zone 1 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw0
- valve_switch: "Zone 2"
enable_switch: "Enable Zone 2"
run_duration_number: "Zone 2 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw1
- valve_switch: "Zone 3"
enable_switch: "Enable Zone 3"
run_duration_number: "Zone 3 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw2
- valve_switch: "Zone 4"
enable_switch: "Enable Zone 4"
run_duration_number: "Zone 4 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw3
- valve_switch: "Zone 5"
enable_switch: "Enable Zone 5"
run_duration_number: "Zone 5 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw4
- valve_switch: "Zone 6"
enable_switch: "Enable Zone 6"
run_duration_number: "Zone 6 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw5
- valve_switch: "Zone 7"
enable_switch: "Enable Zone 7"
run_duration_number: "Zone 7 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw6
- valve_switch: "Zone 8"
enable_switch: "Enable Zone 8"
run_duration_number: "Zone 8 Run Duration"
valve_switch_id: lawn_sprinkler_valve_sw7
switch:
- platform: gpio
id: lawn_sprinkler_valve_sw0
pin: GPIO03
inverted: True
- platform: gpio
id: lawn_sprinkler_valve_sw1
pin: GPIO13
inverted: True
- platform: gpio
id: lawn_sprinkler_valve_sw2
pin: GPIO14
inverted: true
- platform: gpio
id: lawn_sprinkler_valve_sw3
pin: GPIO04
inverted: true
- platform: gpio
id: lawn_sprinkler_valve_sw4
pin: GPIO05
inverted: true
- platform: gpio
id: lawn_sprinkler_valve_sw5
pin: GPIO16
inverted: true
- platform: gpio
id: lawn_sprinkler_valve_sw6
pin: GPIO25
inverted: true
- platform: gpio
id: lawn_sprinkler_valve_sw7
pin: GPIO26
inverted: true
janb2
(Jan)
January 4, 2026, 4:53pm
11
this is my working code so far. I cant get the time remainingg to work.
janb2
(Jan)
January 4, 2026, 4:56pm
12
I have added the following code. The entities work but it does not display the time.
sensor:
- platform: template
name: "Zone 1 Time Remaining"
id: zone_1_time_remaining
unit_of_measurement: "min"
accuracy_decimals: 0
- platform: template
name: "Zone 2 Time Remaining"
id: zone_2_time_remaining
unit_of_measurement: "min"
accuracy_decimals: 0
- platform: template
name: "Zone 3 Time Remaining"
id: zone_3_time_remaining
unit_of_measurement: "min"
accuracy_decimals: 0
- platform: template
name: "Zone 4 Time Remaining"
id: zone_4_time_remaining
unit_of_measurement: "min"
accuracy_decimals: 0
- platform: template
name: "Zone 5 Time Remaining"
id: zone_5_time_remaining
unit_of_measurement: "min"
accuracy_decimals: 0
janb2
(Jan)
January 4, 2026, 5:09pm
13
Karosm
(Karosm)
January 4, 2026, 6:15pm
14
Try like this (state 2 is active):
- platform: template
name: "Zone 2 Time Remaining"
unit_of_measurement: "s"
accuracy_decimals: 0
update_interval: 1s
lambda: |-
auto v = id(lawn_sprinkler_ctrlr)->valve(1);
if (v->state() == 2) {
return v->time_remaining();
}
return 0;
janb2
(Jan)
January 6, 2026, 6:38pm
15
Many thanks for the help. I will action on Monday i am away from home at the moment.
janb2
(Jan)
January 15, 2026, 8:10am
16
Many thanks for the help. I will action on Monday i am