Hi Community
I have a MBUS-MQTT-Gateway from STV electronics (MPW32-IP) that receives data from 4 MBUS devices and sends them as MQTT messages to home assistant. I can see the messages in MQTT Explorer. These have the following scheme (The data_records section is shortened and only 2 of 4 devices are shown).
Can you help to create an configuration for an mqtt-sensor?
{
"primary_address": 1,
"secondary_address": "06365066",
"manufacturer": "SEC",
"medium": "Electricity",
"data_records": [
{
"unit": "Manufacturer (as in fixed header)",
"value": "Schneider Electric"
},
{
"unit": "Model / Version",
"value": "iEM3135 "
},
{
"unit": "Firmware version",
"value": "1.4.002"
},
{
"unit": "Error flags",
"value": "64"
},
{
"unit": "Current (A)",
"value": "2.105615"
},
{
"unit": "Current (A)",
"value": "1.316972"
}
]
}
{
"primary_address": 2,
"secondary_address": "71494503",
"manufacturer": "KAM",
"medium": "Heat: Outlet",
"data_records": [
{
"unit": "Energy (kWh)",
"value": "49077"
},
{
"unit": "Manufacturer specific",
"value": "477854"
},
{
"unit": "Manufacturer specific",
"value": "436544"
},
{
"unit": "Volume (1e-2 m^3)",
"value": "1460506"
}
]
}
thanks in advance for your answer and help
yeaahh, i find the solution. I’m sharing the solution in case others can use it:
template:
- trigger:
- trigger: mqtt
topic: /8C1F6437CC95/mbus
value_template: "{{ value_json.primary_address }}"
payload: 1
sensor:
- name: "Elektrizität (Energie)"
unique_id: "electricity_energy"
state: "{{ trigger.payload_json.data_records[24].value |float / 1000 }}"
state_class: Total
device_class: ENERGY
unit_of_measurement: "kWh"
attributes:
data_records: "{{ trigger.payload_json.data_records }}"
- trigger:
- trigger: mqtt
topic: /8C1F6437CC95/mbus
value_template: "{{ value_json.primary_address }}"
payload: 2
sensor:
- name: "Wärme (Energie)"
unique_id: "heat_energy"
state: "{{ trigger.payload_json.data_records[0].value }}"
state_class: Total
device_class: ENERGY
unit_of_measurement: "kWh"
attributes:
data_records: "{{ trigger.payload_json.data_records }}"
- name: "Wärme (Temperatur Vorlauf)"
unique_id: "heat_temperature_in"
state: "{{ trigger.payload_json.data_records[8].value |float / 100}}"
device_class: TEMPERATURE
unit_of_measurement: "°C"
attributes:
data_records: "{{ trigger.payload_json.data_records }}"
- name: "Wärme (Temperatur Rücklauf)"
unique_id: "heat_temperature_out"
state: "{{ trigger.payload_json.data_records[9].value |float / 100}}"
device_class: TEMPERATURE
unit_of_measurement: "°C"
attributes:
data_records: "{{ trigger.payload_json.data_records }}"
- trigger:
- trigger: mqtt
topic: /8C1F6437CC95/mbus
value_template: "{{ value_json.primary_address }}"
payload: 3
sensor:
- name: "Warmwasser (Volumen)"
unique_id: "water_hotwater_volume"
state: "{{ trigger.payload_json.data_records[1].value |float / 10000}}"
state_class: Total
device_class: WATER
unit_of_measurement: "m³"
attributes:
data_records: "{{ trigger.payload_json.data_records }}"
- trigger:
- trigger: mqtt
topic: /8C1F6437CC95/mbus
value_template: "{{ value_json.primary_address }}"
payload: 5
sensor:
- name: "Kaltwasser (Volumen)"
unique_id: "water_coldwater_volume"
state: "{{ trigger.payload_json.data_records[1].value |float / 10000}}"
state_class: Total
device_class: WATER
unit_of_measurement: "m³"
attributes:
data_records: "{{ trigger.payload_json.data_records }}"