Hi all
I’ve been fiddling with my code for ages it seems and I need some fresh eyes.
My basic idea is to use the status light on my oil burner to calculate the run time and thus the oil consumption. To detect the status light I have a photoresistor connected to my Wemos analogue input and that seems to work fine. My issue is with the lambda, it either gives me to high or to low result.
0.0396 is the rated oil consumption in liters / minute.
Can anyone please offer some insights? Do I have the whole “if” sequence wrong? Is it an issue for me to run the template every minute instead of every second?
You are redefining a static variable in the scope of the if.
I’m not sure what going to happen. So it can be that the num_execution on the top never got set to zero. But do redefine a static in a scope of an if is over my c++ knowledge.
Suggest like this. This will clear the num_execution.
Hi
I’ve edited my original post and added the global “totalOil” and MQTT fetch that was missing in my first post. I think my issue is my lack of understanding of the “update interval” and how this affects my lambda calculations. Doesn’t the Oilconsumption update interval of 60 seconds mean the template and it’s lambda is “run” every 60 seconds? I that case I don’t need the num_executions value at all since my calculation would be "totalOil (the last calculated amount of oil usage) + 0.0396 (the rated oil consumption per minute).
This will check it every second if the led is on. Then increase the total with (0.0396/60) l
This does not take into account the mysensor value. So that you maybe need to explain some more how you where thinking and how it setup in Home Assistand.
I think I get it, with the update interval at least.
About the mysensor. It’s somewhat of a scope-creep for this topic. It’s my take on making a value persistent across reboots or installs on the ESP, although a bit elaborate. Totaloil is sent to MQTT where Home Assistant picks it up and reposts it back to MQTT when a reboot of the ESP sets the value to “nan”. It’s on my todo list to make ESP native.