I have some chinese eWeLink circuit breakers which also have power metering.
They are EARU kind: 1P Din Rail WIFI Smart Energy Meter Power Consumption kWh Meter Circuit Breaker Time Timer Switch Relay Voltmeter for Smart Home|Circuit Breakers| - AliExpress
The power meter function doesn’t present as sensors directly, they are attributes on the switch.
In order to make the attributes into sensors, I need to do something like this in configuration.yaml
:
sensor:
- platform: template
sensors:
10013bc192_voltage:
friendly_name: 'Circuit voltage'
device_class: voltage
unit_of_measurement: 'V'
value_template: "{{ float(state_attr('switch.10013bc192', 'voltage')[0:-2]) }}"
10013bc192_current:
friendly_name: 'Circuit current'
device_class: current
unit_of_measurement: 'A'
value_template: "{{ float(state_attr('switch.10013bc192', 'current')[0:-2]) }}"
10013bc192_power:
friendly_name: 'Circuit power'
device_class: power
unit_of_measurement: 'W'
value_template: "{{ float(state_attr('switch.10013bc192', 'power')[0:-2]) }}"
the [0:-2]
bit is because the sensor reports as a string with a unit suffix; ie, “1500 W”. I strip the unit and cast to a number. With this code these sensors appear to be reporting correctly.
That said, there is a problem. The sensors (from the attributes) update properly every second or so for a little while after I refresh the device in the “eWeLink Smart Home” configuration panel, but after a short time, the device stops updating that data and the value freezes. If I click the refresh button on the device, it starts updating again every second for some time before stopping again.
What is causing it to stop like this? Is there a way I can make sure it keeps updating forever?