esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
415 stars 26 forks source link

Add Apparent Power and Power Factor to HLW8012 #188

Closed bruxy70 closed 5 years ago

bruxy70 commented 5 years ago

Describe the problem you have/What new integration you would like

The HLW8012 sensor claims it is based on Library by Xose Pérez, but it only implements Current, Voltage and Power, whilst the Library also measures Apparent Power and calculates Power Factor. Can you please implement these two parameters to ESPHome?

Please describe your use case for this integration and alternatives you've tried:

These electrical parameters measure the reactive power for capacitors and inductive load (engines). For some devices, their measurement is key to detect their operation mode (e.g. my the Power consumption of my Miele washing machine with Async engine sometimes drops to iddle Power values for several minutes in the midle of operation, but using Power Factor I can confirm that it is still up and running).

Additional context

OttoWinter commented 5 years ago

also measures Apparent Power and calculates Power Factor.

Well it calculates it with the voltage/power/current values. They're not directly measured by the chip itself.

Can you please implement these two parameters to ESPHome?

This should be done in template sensors. ESPHome suggests using template sensors for this because otherwise each power monitor integration would need to re-implement the same stuff each time.

Apparent power: return id(voltage).state * id(current).state; Power factor: return id(power).state / (id(voltage).state * id(current).state);