I am reading the analog thermometer of our hot-water boiler using an ESP-Cam and ppf.angauge. The picture-to-temperature conversion works well, but I am struggling with more basic things: The thermometer is in a dark place. Therefore, I use the built-in LED of the ESP-Cam to illuminate the scene.
To take proper pictures, I need the illumination to turn on, first. Then the camera is supposed to take a picture. And afterwards the illumination turns off.
However, I need to use a ridiculously long delay (5 seconds) between light-on and shot to reliably avoid getting dark frames. To use ppf.angauge, I write a custom_component in python. However, the same problem happens with a normal automation (see below).
I assumed that HA executes the actions in the order I give them. I understand that HA works asynchronously: It may do something else while waiting for the ESP-Cam to turn on the LED. But nevertheless I would expect it to execute the next action in my sequence only after completing the first one.
Am I wrong?
Or does the ESP-Cam not actually trigger an exposure when I tell it to, but merely sends the last frame it had already taken earlier (maybe even before I turned on the light)?
Any help or tipps on how to diagnose the problem further are appreciated.
Can’t answer your question, but I have 1 of my own.
Are you sure the dark frames are due to the initial delay & not the subsequent one?
Asking because 100ms delay might start turning off the light before the camera is done taking the picture.
I’m sure, yes. I started from extremely large delays (on both ends) and reduced them until I got dark frames. The values I posted are the minimum values I can get away with without getting dark frames.
You are referring to just the part related to LED-on / capture / LED-off, I guess? That sounds very promising (although I would still like to know what is going on with my automation). Is that possible on ESPHome-yaml grounds or would I have to use C++?
I still think this is a promising approach, but I’m struggling a bit. I have no problem toggling the LED and doing delays in a script. Also, I can link this to a button that I can press from Home-Assistant. But how am I supposed to capture an image and send it to HA?
Hmm, you got me there. After some research, it doesn’t look like my idea is as simple as I first thought. ESPHome doesn’t have the equivalent of HA’s file camera component to expose a stored image as a new camera, but I found something else. I cannot test this, unfortunately.
The ESP camera has an on_image automation, so you could do something like this which should then run automatically when you take a snapshot:
Going back to your original issue, there is something else you could try, at least for debugging. It’s ugly for me, so I wouldn’t stick with this, but hopefully it can give you some info.
You can still have a script within ESPHome, but make a call back to HA to perform the actual snapshot. Seems there’s no way to get a stored image otherwise, except to push it via HTTP to a custom web server.