Hi everybody,
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!