I have made a unit using a ESP32, a ultrasonic detector and a OLED display to help when parking the car in the garage. It works great but I would like to change update_interval for the sensor/display based on how close to zero the measured distance is. Have implemented a template sensor and set it to ‘1s’ or ‘10s’ based on criteria, but I am struggling to get ESPHome to accept how do I transfer this value to the ultrasonic update_interval setting for the sensor and display…
I have a task where I want to poll a temperature measurement every 2 seconds or so when I’m paying attention to it, but stop polling when I don’t care. I was hoping that I’d at least be able to set a very long polling interval, but I’m having no luck at all. It looks like the update_interval is set in the constructor for Component and there are functions to change it, but they don’t seem to affect the already-running instance. I’ll continue poking around, but I feel like I’m going off in the weeds and there must be a better option. Anything in YAML or C++ would be fine.
Yes, probably not possible to change after it has been constructed.
I am a novice, and was unsuccessful using any Lambda to set update_interval at all. Only way I can get it to not throw errors is using a parameter or Substitution.
In my example I was planning on checking for garage_door_open, and adjust update_interval based on that. Probably not elegant if you’d ask a professional programmer, but since this, at least in mye case, does not change more than once or twice a day, maybe one solution would be a controlled reboot with the new set of update_interval values?
I guess that would require a persistent variable for update_interval and being able to reboot via a command in the yaml. Not sure if that is even possible.
Yes, this is the solution. OttoWinter has also suggested the same here. here
Although in his solution he recommends to define the initial interval as never and then define time intervals. I know I have had issues with using time intervals along with other things - the esp simply crashes , so dont know how best is it.