Hi,

I have two sensors connected, voltage measured from Sonoff POW and a CT Clamp Current Sensor on nodemcu Esphome.

What I want to do is calculate both Watts / kw and KWh in HA and show / display calculated values on my glance card…

I think this can be achieved with a Template but unsure how to implement as my knowledge is very basic for now, something like this?

```
# Example configuration.yaml entry
sensor:
- platform: template
sensors:
Kw:
friendly_name: "Kw"
unit_of_measurement: 'Kw'
value_template: "{{ state_attr(input_number.power_factor.state | int ) }} x {{ state_attr(sensor.pow_voltage'', 'V') }} x {{ state_attr('sensor.measured_current', 'A') }}"
```

Current Sensor

entity

sensor.measured_current

unit_of_measurement: A

friendly_name: Measured Current

icon: ‘mdi:flash’

Voltage Sensor

```
sensor:
- platform: mqtt
name: 'POW Voltage'
state_topic: 'tele/sonoff30/SENSOR'
value_template: '{{ value_json["ENERGY"].Voltage }}'
unit_of_measurement: 'Volts'
force_update: true
```

Power Factor input boolean

```
input_number:
power_factor:
name: Power Factor
initial: 0.8
min: 0
max: 1
step: .1
mode: box
```

friendly_name: Power Factor

So for now I have the following on my glance card

Power factor input integra as a input Boolean, initial default 0.8,

AC single phase amps to watts calculation

The power *P* in watts (W) is equal to the *PF* times the phase current *I* in amps (A), times the RMS voltage *V* in volts (V):

*P* (W) = *PF* × *I* (A) × *V* (V)

Watts to kWh calculation

*E* (kWh) = *P* (W) × *t* (hr) / 1000

Would appreciate any assistance?

Regards,