I receive a MQTT response as follows and I want to read the BAT_V value in HA. Thanks in advance.
MQTT message:
{
“app_eui”: “A84041000000”,
“dc”: {
“balance”: 8956,
“nonce”: 1
},
“decoded”: {
“payload”: {
“ALARM”: 0,
“BAT_V”: 3.006,
“DOOR_OPEN_STATUS”: 0,
“DOOR_OPEN_TIMES”: 53,
“LAST_DOOR_OPEN_DURATION”: 0,
“MOD”: 1
},
“status”: “success”
},
Helium Decoder:
if(mod==1){
var open_times=bytes[3]<<16 | bytes[4]<<8 | bytes[5];
var open_duration=bytes[6]<<16 | bytes[7]<<8 | bytes[8];//units:min
if(bytes.length==10 && 0x07>bytes[0]< 0x0f)
return {
BAT_V:bat,
MOD:mod,
DOOR_OPEN_STATUS:door_open_status,
DOOR_OPEN_TIMES:open_times,
LAST_DOOR_OPEN_DURATION:open_duration,
ALARM:alarm
};
My YAML looks like this and the Mailbox Door part works. How do I enter the YAML to read the BAT_V value?
mqtt:
binary_sensor:
- name: “Mailbox Door”
device_class: opening
payload_on: “1”
payload_off: “0”
payload_not_available: “”
value_template: “{{ value_json.decoded.payload.DOOR_OPEN_STATUS }}”
state_topic: “helium/a11faa84-b9d6-4fc3-a173-4acd35bec9ee/rx”