I forked the original repo and rewrote the monitor to scan for “all” ERT types, so it includes SCM, SCMplus, IDM.
In addition to that:
- The “state” value is still the base consumption in kWh but I added all attribute data from the SCM and IDM responses, so you can see extra information (see below for examples)
- Messages are posted with ‘retain’ flag enabled so that the meter information is immediately available to HASS on restart
- Messages are published to topics in more unique namespaces for easier filtering
- Messages are published to an availability topic so that HASS can update accordingly when the service is up or down
- A last_reset hack value is posted to workaround the issues with MQTT sensor and last_reset.
See the fork here: GitHub - TonyApuzzo/amridm2mqtt: runs rtlamr to read IDM power meter data and send to MQTT broker<
Example reading an SCM Meter:
state_class: measurement
last_reset: '1970-01-01T00:00:00+00:00'
ChecksumVal: 55361
Consumption: 74504
ID: XXXXXXXX
TamperEnc: 0
TamperPhy: 0
Type: 4
unit_of_measurement: kWh
friendly_name: Electric Meter
device_class: energy
Example reading an IDM Meter:
state_class: measurement
last_reset: '1970-01-01T00:00:00+00:00'
ApplicationVersion: 2
AsynchronousCounters: 22389
ConsumptionIntervalCount: 0
DifferentialConsumptionIntervals: [ 1, 2, 1, 0, 2, 1, 2, 1, 0, 6, 10, 10, 10, 10, 10, 12, 11, 11, 10, 10, 10, 10, 11, 10, 11, 12, 11, 12, 12, 11, 12, 10, 13, 15, 11, 10, 11, 10, 11, 10, 7, 2, 1, 2, 1, 1, 0 ]
ERTSerialNumber: YYYYYYYY
ERTType: 7
HammingCode: 198
LastConsumptionCount: 2673708
ModuleProgrammingState: 204
PacketCRC: 60717
PacketLength: 92
PacketTypeID: 28
PowerOutageFlags: opAwAKEg
Preamble: 1431639715
SerialNumberCRC: 52453
TamperCounters: FoIhbUgS
TransmitTimeOffset: 346
unit_of_measurement: kWh
friendly_name: Electric Meter IDM
device_class: energy
Definitions for the above:
sensor:
- platform: mqtt
state_topic: "amr/reading/SCM/4/XXXXXXXX/message"
name: "Electric Meter"
unique_id: electric_meter_01
unit_of_measurement: kWh
device_class: energy
state_class: measurement
availability_topic: amr/status/availability
last_reset_topic: amr/status/last_reset
value_template: "{{ value_json.Message.Consumption }}"
json_attributes_template: "{{ value_json.Message | tojson }}"
json_attributes_topic: "amr/reading/XXXXXXXX/message"
- platform: mqtt
state_topic: "amr/reading/IDM/7/YYYYYYYY/message"
name: "Electric Meter IDM"
unique_id: electric_meter_02
unit_of_measurement: kWh
device_class: energy
state_class: measurement
availability_topic: amr/status/availability
last_reset_topic: amr/status/last_reset
value_template: "{{ value_json.Message.Consumption }}"
json_attributes_template: "{{ value_json.Message | tojson }}"
json_attributes_topic: "amr/reading/IDM/7/YYYYYYYY/message"