MQTT Chirpstack

Dear,

I’m trying to use MQTT data in Home Assistant from Chirpstack LORA. I’ve bridged Chirpstack into the HA MQTT Broker with success.
I do have a problem with the parsing of the data.

I can’t get the battery data out of the following:

{“applicationID”:“2”,“applicationName”:“DoorSensor”,“deviceName”:“DoorSensor04”,“devEUI”:“qEBBX3GE/PM=”,“rxInfo”:[{“gatewayID”:“5F8B//48tas=”,“time”:“2024-10-03T21:29:27.523103Z”,“timeSinceGPSEpoch”:“1416.523s”,“rssi”:-99,“loRaSNR”:8.5,“channel”:2,“rfChain”:1,“board”:0,“antenna”:0,“location”:{“latitude”:0.00000,“longitude”:0.0000,“altitude”:-625,“source”:“UNKNOWN”,“accuracy”:0},“fineTimestampType”:“NONE”,“context”:“Ij3h7w==”,“uplinkID”:“PAx0DNaAT+SfF0LUxW4nNg==”,“crcStatus”:“CRC_OK”}],“txInfo”:{“frequency”:868500000,“modulation”:“LORA”,“loRaModulationInfo”:{“bandwidth”:125,“spreadingFactor”:7,“codeRate”:“4/5”,“polarizationInversion”:false}},“adr”:true,“dr”:5,“fCnt”:77531,“fPort”:10,“data”:“CzQBAB0jAAAAAA==”,“objectJSON”:“{"BAT_V":2.868,"DOOR_OPEN_STATUS":0,"DOOR_OPEN_TIMES":7459,"LAST_DOOR_OPEN_DURATION":0,"MOD":"Door sensor"}”,“tags”:{},“confirmedUplink”:true,“devAddr”:“AVZ6TA==”,“publishedAt”:“2024-10-03T20:27:46.327232445Z”,“deviceProfileID”:“56e416e1-7c79-4e0b-a97e-a61113d7244c”,“deviceProfileName”:“DoorSensor”}

I’ve tried this in the configuration.yaml but i can’t seem to find what i do wrong.

mqtt:
sensor:
- name: “Battery Voltage”
device_class: voltage
unique_id: “ds11_doorsensor”
state_topic: “application/2/device/a840418d9184fce3/event/up”
unit_of_measurement: ‘V’
value_template: “{{ value_json[‘txInfo’][‘objectJSON’][‘BAT_V’] }}”

Who can help me solve this?

Thanks

{{ (value_json["objectJSON"] | from_json)["BAT_V"]}}

Thanks for your feedback - some minor adaptations but below did the trick

mqtt:
sensor:
- name: “Door : Battery Voltage”
device_class: voltage
unique_id: “doorsensor_battery_voltage”
state_topic: “application/2/device/xxxxxxxxxxx/event/up”
unit_of_measurement: ‘V’
value_template: “{{ (value_json[‘objectJSON’] | from_json)[‘BAT_V’]}}”

If you are to mark your answer as the solution, please make it properly formatted

Code_format