Hi
I’m trying to get serial data from this energy monitor to work in HA, I have tested and can read the output using raspbian, but on my pi4 I am using HA OS
It outputs like this:
"pi@raspberrypi:~ $ cat /dev/ttyAMA0
11 2.94 12.55 0.05 244.34 0.159 1.20 8.29 0.03 244.20 0.121 16.25 30.73 0.13 244.31 0.521"
Which according to the documentation is:
NodeID Realpower1 ApparentPower1 Irms1 Vrms1 PowerFactor1 Realpower2 ApparentPower2 Irms2 Vrms2 PowerFactor2 Realpower3 ApparentPower3 Irms3 Vrms3 PowerFactor3
my yaml config looks like this:
- platform: serial
serial_port: /dev/ttyAMA0
baudrate: 115200
- platform: template
sensors:
my_nodeid_sensor:
friendly_name: NodeID
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[1] | float }}"
my_realpower1_sensor:
friendly_name: Realpower1
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[2] | float }}"
my_apparentpower1_sensor:
friendly_name: ApparentPower1
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[3] | float }}"
my_lrms1_sensor:
friendly_name: Irms1
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[4] | float }}"
my_vrms1_sensor:
friendly_name: Vrms1
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[5] | float }}"
my_powerfactor1_sensor:
friendly_name: PowerFactor1
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[6] | float }}"
my_realpower2_sensor:
friendly_name: Realpower2
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[7] | float }}"
my_apparentpower2_sensor:
friendly_name: ApparentPower2
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[8] | float }}"
my_lrms2_sensor:
friendly_name: Irms2
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[9] | float }}"
my_vrms2_sensor:
friendly_name: Vrms2
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[10] | float }}"
my_powerfactor2_sensor:
friendly_name: PowerFactor2
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[11] | float }}"
my_realpower3:
friendly_name: Realpower3
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[12] | float }}"
my_apparentpower3_sensor:
friendly_name: ApparentPower3
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[13] | float }}"
my_lrms3_sensor:
friendly_name: Irms3
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[14] | float }}"
my_vrms3_sensor:
friendly_name: Vrms3
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[15] | float }}"
my_powerfactor3_sensor:
friendly_name: PowerFactor3
unit_of_measurement: "W"
value_template: "{{ states('sensor.serial_sensor').split(' ')[16] | float }}"
If I enter
{{ states('sensor.serial_sensor') }}
Into developer tools - template, I get:
Result type: string
unknown
It seems that it is not reading the serial data at all for some reason, I have spent hours trying to figure this out!