Sprinkler Controller - Active Valve


In the documentation I see that there is the function to get the active valve

optional< size_t > esphome::sprinkler::Sprinkler::active_valve	(		)	
returns the number of the valve that is currently active, if any. check with 'has_value()'
Definition at line 798 of file sprinkler.cpp.

Sprinker active_valve()

I would like to use it to display the active valve on a LCD instead of “repeat” the same code for each valve

it.printf(0, 0, "Zone1: %s", id(zone_valve_sw1).state ? "ON" : "OFF");

something like

it.printf(0, 0, "Zone%s", id(esp32_sprinkler_ctrlr)


any idea?

nevernind, I think i got it

return id(esp32_sprinkler_ctrlr).active_valve().value_or(NAN)