I was needed to find a solution for calculating two entities not provided by Shelly EM from API or MQTT directly, like the power factor and the current
I searched for long time inside the community but didn’t find anything what I really needed
So looking on the web and something here, I built this yaml configuration, hoping now to help somebody, like me some hours ago!
Active power and Voltage come from Shelly Integration (or MQTT if you prefer), Reactive power come from MQTT (API not provide this)
- platform: template
# Calcolo Cosfi a partire da potenza attiva P e reattiva Q
sensors:
pci_cosfi:
friendly_name: "PCI CosFi"
value_template: '{{ (cos(atan(states("sensor.pci_potenza_reattiva")|float / states("sensor.pci_power")|float)))|float|round(3) }}'
unit_of_measurement: "CosFi"
# icon: hass:cosine-wave
- platform: template
# Calcolo Corrente a partire da potenza attiva P, Tensione e CosFi
sensors:
pci_corrente:
# EM01 - Canale 2
friendly_name: "PCI Corrente"
value_template: '{{ ((states("sensor.pci_power")|float) / ((states("sensor.pci_voltage")|float)*(states("sensor.pci_cosfi")|float)))|float|round(3) }}'
unit_of_measurement: "A"
# icon: hass:current-ac
Here is the result…It’s all in italian, but hope you understand…Bye!
Thanks for this, it is intersting. I also have a Shelly EM. Could you explain me what usage do yo do with the Reactive Power or the power factor ? Do you use it to detect if certain equipment is on ?
glad to see your interest!
I use these values to control my home electrical power distribution, just to watch consumptions and see if some devices introduce a lot of reactive load that is not really fine. The PF parameter still to be close to one, but for example I saw that my UPSs contributes to decrease it…just an evaluation…
In the screenshot I supervised my induction hob
You can find a lot of info about power active/reactive and PF on the web
Hello.
I’m also trying to do something similar to yours.
I’m trying to calculate the real power consumed by a load. Having a three-phase system, the cosfi on each phase is different from 1 and the absorption values are not real.
To make this calculation, I have these two values:
to calculate the real absorption value I have to do:
163.5 / 207.35 = 0.78 is the cosfi
now I have to do this calculation
163.5 / 78 * 100 = 209.6 is the real consumption of the load
this is the last calculation i am currently using for the cosfi
I added the control on the non-zero value for the active power, this to avoid the division by zero error in the denominator, when there is no consumption (power = 0.0 W) and the cosfi is forced to 0.0
Just change the entities name and it has to work for you too
Let me know
- platform: template
# Calcolo Cosfi a partire da potenza attiva P e reattiva Q
sensors:
# EM01 - Canale 1
totale_cosfi:
friendly_name: "Totale CosFi"
value_template: >-
{% set valore_confronto_totale_power = states("sensor.totale_power") | float %}
{% if valore_confronto_totale_power == 0.0 %} 0.0
{% else %}
{{ (cos(atan(states("sensor.totale_potenza_reattiva")|float / states("sensor.totale_power")|float)))|float|round(2) }}
{% endif %}
unit_of_measurement: "CosFi"