I’m trying to send json to an mqtt sensor such that the data shows up as attributes on the sensor. I need it this way because that’s how the custom list-card requires it.
Here is my mqtt sensor in configuration.yaml:
- platform: mqtt
name: Traffic Accidents
state_topic: 'accidents'
value_template: "{{ value_json }}"
json_attributes:
- incident_type
- status
- time
- county
- location
Below is the json I’m publishing to the topic accidents. When I publish this, nothing shows up in the attributes nor state of the sensor. If I send just one incident instead of several like below, the json shows up in the state of the sensor and not the attributes. I have no idea what I’m doing wrong.
[
{
"Incident_Type": "COLLISION:NO INJURY",
"Status": "IN PROGRESS",
"Time": "18:08",
"County": "ANDERSON",
"Location": "MICHELIN BLVD x[DOBBINS BRIDGE RD]"
},
{
"Incident_Type": "COLLISION:INJURIES",
"Status": "ROADWAY BLKD",
"Time": "20:23",
"County": "ANDERSON",
"Location": "E RIVER ST x[ESTES DR]"
},
{
"Incident_Type": "COLLISION:PRIV PROP",
"Status": "IN PROGRESS",
"Time": "20:38",
"County": "ANDERSON",
"Location": "4123 CLEMSON BLVD [X2[SC28]] x[US76]"
},
{
"Incident_Type": "COLLISION:NO INJURY",
"Status": "IN PROGRESS",
"Time": "17:43",
"County": "GREENVILLE",
"Location": "8874 N TIGERVILLE RD x[BELK RD]"
},
{
"Incident_Type": "COLLISION:NO INJURY",
"Status": "IN PROGRESS",
"Time": "18:19",
"County": "GREENVILLE",
"Location": "WADE HAMPTON BLVD x[EDWARDS MILL RD]"
},
{
"Incident_Type": "HIT & RUN:NO INJURY",
"Status": "IN PROGRESS",
"Time": "19:40",
"County": "GREENVILLE",
"Location": "BRUCE RD x[E DORCHESTER BLVD]"
},
{
"Incident_Type": "ASSIST MOTORIST",
"Status": "ROADWAY BLKD",
"Time": "19:52",
"County": "GREENVILLE",
"Location": "MARTIN RD x[GREENPOND RD]"
},
{
"Incident_Type": "DEBRIS IN ROADWAY",
"Status": "IN PROGRESS",
"Time": "19:55",
"County": "GREENVILLE",
"Location": "I85 [49SB]"
},
{
"Incident_Type": "COLLISION:NO INJURY",
"Status": "IN PROGRESS",
"Time": "20:12",
"County": "GREENVILLE",
"Location": "BLAKELY AVE x[US25]"
},
{
"Incident_Type": "HIT & RUN:NO INJURY",
"Status": "IN PROGRESS",
"Time": "20:28",
"County": "GREENVILLE",
"Location": "I85 [51SB]"
},
{
"Incident_Type": "HIT & RUN:PRIV PROP",
"Status": "IN PROGRESS",
"Time": "20:22",
"County": "SPARTANBURG",
"Location": "3605 BOILING SPRINGS RD [X2[SC9]] x[SC9]"
}
]