So one of the recent core updates (2021.12.8) has rendered these MQTT devices unusable for me. Can someone shed some light of the error message??
I’ve tried adding an availability topic, although this device doesn’t post an online, offline message.
I sort of played around with the timesstamp, timestamp_local. they seem to be the most frustrating.
I had a look through this link from petro, although it doesn’t seem to relate to MQTT sensors.
Any tips would be welcomed.
Logger: homeassistant.helpers.template
Source: helpers/template.py:1791
First occurred: 16:54:29 (532 occurrences)
Last logged: 17:35:12
Template variable error: 'value_json' is undefined when rendering '{{ value_json.IDC1 }}'
Template variable error: 'value_json' is undefined when rendering '{{ value_json.IDC2 }}'
Template variable error: 'value_json' is undefined when rendering '{{ value_json.PDC1 }}'
Template variable error: 'value_json' is undefined when rendering '{{ value_json.PDC2 }}'
Template variable error: 'value_json' is undefined when rendering '{{ value_json.status }}'
Template variable error: 'value_json' is undefined when rendering '{{ value_json.Timestamp_local }}'
MQTT message json
(Timestamp: "09/01/2022 17:25:03",SunRise: "09/01/2022 06:10:00",SunSet: "09/01/2022 20:43:00",InvSerial: 2100443252,InvName: "SN: 2100443252",InvTime: "09/01/2022 17:24:59",InvStatus: "Ok",
InvTemperature: 61.460,InvGridRelay: "Closed",EToday: 20.376,ETotal: 57245.059,PACTot: 1456.000,UDC1: 254.020,UDC2: 276.090,IDC1: 4.671,IDC2: 1.087,PDC1: 1186.000,PDC2: 299.000}
MQTT yaml config
sensor:
- platform: mqtt
name: "SMA Output"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.status }}'
json_attributes_topic: "sbfspot"
- platform: mqtt
name: "SMA Sunny Boy"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.InvName }}'
icon: "mdi:flash"
- platform: mqtt
name: "SMA TimeStamp"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.Timestamp_local }}'
icon: "mdi:clock"
- platform: mqtt
name: "SMA Sun Rise"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.SunRise }}'
icon: "mdi:weather-sunny"
- platform: mqtt
name: "SMA Sun Set"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.SunSet }}'
icon: "mdi:weather-sunset-down"
- platform: mqtt
name: "SMA Running Temp"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.InvTemperature }}'
unit_of_measurement: "°C"
icon: "mdi:coolant-temperature"
device_class: temperature
- platform: mqtt
name: "SMA Status"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.InvStatus }}'
icon: "mdi:flash"
- platform: mqtt
name: "SMA Grid Relay"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.InvGridRelay }}'
icon: "mdi:electric-switch"
- platform: mqtt
name: "SMA Daily Energy"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.EToday }}'
unit_of_measurement: "kWh"
icon: "mdi:solar-power"
device_class: energy
state_class: total_increasing
- platform: mqtt
name: "SMA Total Energy"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.ETotal }}'
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
- platform: mqtt
name: "SMA Power AC"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.PACTot }}'
unit_of_measurement: "W"
icon: "mdi:flash"
device_class: power
state_class: measurement
- platform: mqtt
name: "SMA DC Array"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.UDC1 }}'
unit_of_measurement: "Volts"
icon: "mdi:solar-panel-large"
device_class: voltage
- platform: mqtt
name: "SMA DC Array2"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.UDC2 }}'
unit_of_measurement: "Volts"
icon: "mdi:solar-panel"
device_class: voltage
- platform: mqtt
name: "SMA DC Array"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.IDC1 }}'
unit_of_measurement: "Amps"
icon: "mdi:solar-panel-large"
device_class: current
- platform: mqtt
name: "SMA DC Array2"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.IDC2 }}'
unit_of_measurement: "Amps"
icon: "mdi:solar-panel"
device_class: current
- platform: mqtt
name: "SMA DC Array"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.PDC1 }}'
unit_of_measurement: "Watts"
icon: "mdi:solar-panel-large"
device_class: power
- platform: mqtt
name: "SMA DC Array2"
state_topic: "sbfspot_YOUR_PLANT_NAME/sbfspot_YOUR_INVERTER_SERIAL"
value_template: '{{ value_json.PDC2 }}'
unit_of_measurement: "Watts"
icon: "mdi:solar-panel"
device_class: power