Hello
I trying to override some sensors’ state by using lambdas. I’m using ESPHome for monitoring my solar inverter through the modbus component. when there’s low sunlight, the inverter starts to shutdown, but never updates some values to 0 (or null) when shutting down.leaving my ESPHome with “old data” that will be never updated until the inverter turns on again during morning.
I been reading a specific register that always updates to whatever thing the inverter is doing (well, it’s called inverter status )
I been reading a docs how-to accomplish this automation, but i’m kinda stuck, my code doesn’t update the sensor values.
TL;DR: The point is, when ESPHome receives the status “I’m shutting down”, set the state of some sensors to 0
It might be that you have to do this: if ((id(estado).state == 0))
You were right, my mistake was a silly.
After that I made another (silly) mistake and I accidentally deleted the .state and at first it didn’t worked until I realized that. 🤦♂
With that, my code works now, but the I realized a new problem. There’s a wait window between the last reply and making the new request; during this time the inverter can shutdown and ESPHome wouldn’t receive any new data (corner case I think?). I think this kind of problem, I don’t think with my current code will work. Any idea of how to add some short-of timeout?
At first I tested it global variables and worked, then I realized i deleted the .state in estado ; that was the reason why the solution did not work for me.
@SkateWarp
Hey, could you maybe help me in this matter?
I am also trying to manipulate a sensor value manually (by an MQTT message).
This is my sensor:
By this I want to define a new value for the total pulse counter part of the sensor. But the sensor remains at it’s current value (0) :
[10:06:14][D][pulse_counter:180]: 'Gas Consumption': Total : 0 pulses
[10:06:14][D][sensor:126]: 'Gas Consumption Total': Sending state 0.00000 m³ with 2 decimals of accuracy