I have a gas meter and I am counting pulses in ESPhome to get the current meter reading. Sometimes, I need to manually adjust the meter reading, so I set up a homeassistant sensor:
That works fine under normal conditions. However, whenever the ESP device reboots, or I restart homeassistant, ESPhome thinks that it got a new value and sets count_reading back to the last adjustment value I entered. Obviously that is not what I want. I tried to add an input_button and only update when that is pressed, too. But I could not make that work…
I also thought of using a factory reset button for “resetting” the value to whatever was entered in HASSIO, but that would require that I modify the initial_value somehow instead of writing the value to my counter variable. so I think that does not work, either.
Not that it matters but why are you manually adjusting the sensor value at all and where is the data coming from if not the main sensor?
Anyways… ok, you have questions about pulse counter? Pulse meter? No one knows because theres no useful information here, you’ve only wrote out 3 paragraphs explaining the problem with what your config is doing but, provided no config… Do you just want people to take random guesses?
Thank you very much! That is the hint I needed. In contrast to the homeassistant sensor I was using, the user defined API service does not update on boot and now everything behaves the way I need it: I can set/adjust the counter by calling the service from HA (Developer tools > services) and in case of reboot, my count is restored from flash. Works like a charm. Thanks again!
And in case someone else stumbles upon this thread with a similar problem, this is what my service definition looks like:
I want the meter reading in ESPhome/HASSIO to be the same as on the physical meter
Pulse counters miss pulses every now and then.
And no, I do not have questions about pulse counter/meter. As my post clearly says, my question was about getting data from HA to ESPhome without it being updated upon reboot of either and how my attempt to use a homeassistant sensor did not work as expected. No guesswork required – just perusal of the question. Dumping entire configs on a paid service professional is ok – doing the same to a forum of volunteers is rude, so I restricted the config to the part relevant to the questions as one should.
You just dont understand why it matters, so let me enlighten you. Pulse meter and pulse counter are different things. They both do the same thing, count pulses but, pulse meter has some extra configuration options. No one knows if you’re even using the right one because you want to tell everyone else what information is relevant or isnt and you withold it.
Knowing which one and your config helps the people your asking do a mental process of elimination because we dont know what level your at. Now, maybe you think it should be obvious to everyone that your using pulse meter since your real cocky and think you know it all. To that I say, " well didnt you read the documentation smart guy?" Its not the the Native AI documentation you needed. You just needed to not be arrogent and read the documentation for pulse meter because it specifically addresses this scenario and answers it! If i could have seen your config or knew which one you used, someone could have just pointed you back to the docs. Instead we have this. Your very public face plant because you couldnt do 5min of reading.
Next time just post the config or at a minimum then post the config that your question is in reference to. In this case it would be your config for pulse_meter. Now you know.