I have an ESPHome defined Pzemac current/energy sensor that I need to reset all previous historic measurement values to zero. How can I do this?
sensor:
- platform: pzemac
current:
name: "RV1 Energy Monitor Current"
voltage:
name: "RV1 Energy Monitor Voltage"
energy:
name: "RV1 Energy". <---- I WANT TO RESET THIS VALUE
power:
name: "RV1 Energy Monitor Power"
frequency:
name: "RV1 Energy Monitor Frequency"
power_factor:
name: "RV1 Energy Monitor Power Factor"
update_interval: 10s
Ok, I was being too literal in reading the doc. I think what it says is there needs to be some action that triggers the reset. In light of this revelation, I added this to the top of my config file:
esphome:
name: energy-monitor-house
on_boot:
then:
- pzemac.reset_energy: energy_monitor_house
sensor:
- platform: pzemac
current:
name: "RV1 Energy Monitor Current"
voltage:
name: "RV1 Energy Monitor Voltage"
energy:
name: "RV1 Energy". <---- I WANT TO RESET THIS VALUE
power:
name: "RV1 Energy Monitor Power"
frequency:
name: "RV1 Energy Monitor Frequency"
power_factor:
name: "RV1 Energy Monitor Power Factor"
update_interval: 10s
But one again I cannot figure out how to get the ID right. Does it need to be defined somewhere? I tried all permutations above with no luck.
I’ve also tried:
pzemac.reset_energy: pzemac
pzemac.reset_energy: pzemac_1
pzemac.reset_energy: pzemac_RV1_Energy
pzemac.reset_energy: pzemac.RV1_Energy
And
pzemac.reset_energy: RV1_Energy
Didn’t saw the new logs and new yaml (your edited post) but just the old one that didn’t compile…
Guess what happens (now) is that the command to reset the energy counter is issued before the pzem is actually ready for communication.
Two things you could do about that, one is adding a delay in the on_boot action the other is just to have the action in a template button so you can hit it yourself.
And I think that energy needs it’s own id (but I can also be mistaken), like I suggested
I’ll see if I can figure out a delay and try that. Christ this stuff is convoluted. I just want to reset a frigging value. It shouldn’t be this complicated.
Another “solution” (more of a work’a’round) actually would just to use a software counter in esphome, like total_daily_energy
But the good thing with the counter in the pzem004t (which is stored in eeprom) is that even if the esp is not working/powered it will continue counting the energy - like a fail safe solution.
I actually also make heavy use of the utility_meter in ha to sum up my consumption
Now what? I dont see these as new entities. the only place I see anything about buttons is in Dev Tools using service Button_press, but calling the service does nothing… and the entity name is wrong.
Did you also let esphome do it’s magic (validate the yaml, compile a new binary and upload it ota)?
If so you should see your new buttons popping up in ha (easiest is to just enter device & services under settings and open the regarding esphome device to see all it’s entites).
Also the logs of your esphome node should show which buttons it has set up.
Ok, foolish me. I had assumed I could define these buttons in configuration.yaml, or by extension button.yaml, like all the other dozens of buttons I’ve created…
But no… these are defined in the esphome config files for the device. That’s so obvious, that it’s painfully not obvious.
This shit is So confusing. Honestly, this is not documented well at all. I’ve scoured all the docs and didn’t catch this until an aha moment just now.
Most Buttons are defined in configuration.yaml unless they are part of other entities like esphome. Then sometimes they are defined in those config files. Clear as stinky, murky, filthy mud.
So yeah it’s working now but sheesh… good thing I studied rocket science in college. Seriously…
All HA related stuff will be in your configuration.yaml and your other ha yamls…
Well, not really sometimes. If it is part of your esphome node it will be configured in the yaml for that esphome node (and needs to be verified, compiled and uploaded to actually be “active”).
I guess the similarities are that they use yaml for configuration - but that’s kind of all. Otherwise they are two completely independent things to setup which outcome (esphome nodes) can work great together (with ha) by utilizing the native api.
jazzmonger, thanks for sticking with this one! I need this too!
I’ve struggled a LOT trying to find the solutions in the documentation, too! It’s like the BASIC prog lanuage’s "GOTO’s. They all reference back to one another in an infinite loop without the real solution in them…