Pulse Meter - Get Watts and Kw

Is it possibly to get ESPHome to report both a Watts and Kilowatts values to home assistant?
This is my existing code that does the kW…

sensor:
  - platform: pulse_meter
    pin: D4
    unit_of_measurement: 'kW'
    name: 'Electricity Usage'
    id: meter_power
    state_class: measurement
    device_class: power
    icon: mdi:flash-outline
    internal_filter_mode: "PULSE"
    internal_filter: 100ms
    timeout: 1min
    filters:
      - multiply: 0.06

Sure, use a template sensor:

sensor:
  - platform: pulse_meter
    pin: D4
    unit_of_measurement: 'kW'
    name: 'Electricity Usage'
    id: meter_power
    state_class: measurement
    device_class: power
    icon: mdi:flash-outline
    internal_filter_mode: "PULSE"
    internal_filter: 100ms
    timeout: 1min
    filters:
      - multiply: 0.06
  - platform: template
    name: "Electricity Usage W"
    unit_of_measurement: 'W'
    state_class: measurement
    device_class: power
    lambda: 'return (id(meter_power).state / 1000);'

Hi @tom_l , I added that to the yaml of my ESpHome device and it uploaded okay but it never seems to report anything except for the existing kW amount.
I’ve never delved into Template sensors before… Have I put it in the correct place?

Okay wait… Watched the logs for a while and looks like it is reporting it every 60s, I tried adding a filter of 10s but that didn’t make it report any quicker…?

Okay, have read the docs on template sensors and saw the update interval and now this looks to be working well! I did also change the lambda to multiply to get the watts :slight_smile:

sensor:
  - platform: pulse_meter
    pin: D4
    unit_of_measurement: 'kW'
    name: 'Electricity Usage'
    id: meter_power
    state_class: measurement
    device_class: power
    icon: mdi:flash-outline
    internal_filter_mode: "PULSE"
    internal_filter: 100ms
    timeout: 1min
    filters:
      - multiply: 0.06
  - platform: template
    name: "Electricity Usage W"
    unit_of_measurement: 'W'
    state_class: measurement
    device_class: power
    lambda: 'return (id(meter_power).state * 1000);' 
    update_interval: 10s

Doh! Sorry.

A couple of things to try.

This updates the template sensor whenever the kW value updates, not sure if it causes the template to send the value to home assistant though:

sensor:
  - platform: pulse_meter
    pin: D4
    unit_of_measurement: 'kW'
    name: 'Electricity Usage'
    id: meter_power
    state_class: measurement
    device_class: power
    icon: mdi:flash-outline
    internal_filter_mode: "PULSE"
    internal_filter: 100ms
    timeout: 1min
    filters:
      - multiply: 0.06
    on_value:
      then:
        - component.update: meter_power_w
  - platform: template
    name: "Electricity Usage W"
    id: meter_power_w
    unit_of_measurement: 'W'
    state_class: measurement
    device_class: power
    lambda: 'return (id(meter_power).state * 1000);' 

An alternate version that may work:

sensor:
  - platform: pulse_meter
    pin: D4
    unit_of_measurement: 'kW'
    name: 'Electricity Usage'
    id: meter_power
    state_class: measurement
    device_class: power
    icon: mdi:flash-outline
    internal_filter_mode: "PULSE"
    internal_filter: 100ms
    timeout: 1min
    filters:
      - multiply: 0.06
    on_value:
      then:
        - sensor.template.publish:
      id: meter_power_w
      state: !lambda 'return (id(meter_power).state * 1000);' 

  - platform: template
    name: "Electricity Usage W"
    id: meter_power_w
    unit_of_measurement: 'W'
    state_class: measurement
    device_class: power

Which one worked?

Sorry I ticked the wrong box… I tried both of your options but got lots of errors to do with syntax and yaml… So my version which has the 10s update will work okay for my use case :slight_smile:

I’m getting random high spikes and have enabled the internal_filter and tried entering several different figures but without success.
How do I actually calculate the figure I enter, I have 2 setup on my solar generation meters. Both meters are 1000 pulses per kWh meters and the max wattage I would ever expect to see would be approx. 1500w