Mqtt discovery fails because unable to parse JSON

I just flashed a new Wemos D1 Mini Lite on my Win10 machine and plugged in a Dallas temperature sensor to it. That worked just fine following the directions online. I noticed it did not show up in HASS, though, but it looked like it was publishing MQTT just fine. I even installed mosquitto on the RPi that HASS is running on to subscribe to all topics and sure enough it’s there with my other D1s running esphomeyaml. But then I found this error in the HASS log.

Unable to parse JSON living_room_temperature: '{"unit_of_measurement":"°C","expire_after":675,"name":"Living Room Temperature","state_topic":"living_room/sensor/living_room_temperature/state","availability_topic":"living_room/status","unique_id":"dallas-serial_number","device":{"identifiers":"unique_id","name":"living_room","sw_version":"esphomelib v1.9.3 Dec 21 2018, 15:47:31","model":"PLATFORMIO_D1_MINI_LITE","manufacturer":"espressi'

And sure enough, the exact same JSON string exists underneath the /config topic. I changed the name from “living_room_temperature” to “LR_temp” to see if it was simply too many characters but the error immediately shows up when the /config topic is published.

living_room/debug [I][mqtt.client:115]: MQTT Connected!

living_room/status online

homeassistant/sensor/living_room/lr_temp/config {"unit_of_measurement":"°C","expire_after":675,"name":"LR Temp","state_topic":"living_room/sensor/lr_temp/state","availability_topic":"living_room/status","unique_id":"dallas-serial_number","device":{"identifiers":"identifier","name":"living_room","sw_version":"esphomelib v1.9.3 Dec 21 2018, 16:50:13","model":"PLATFORMIO_D1_MINI_LITE","manufacturer":"espressi

living_room/sensor/lr_temp/state 23.3

Finally, I tested another D1 mini I’ve got esphomelib installed on. I just reuploaded the firmware to reboot the device and it output the full config for HASS to discover.

star/light/christmas_star/state {"effect":"None","state":"OFF","brightness":255,"color":{"r":255,"g":255,"b":255}}
homeassistant/light/star/christmas_star/config {"brightness":true,"rgb":true,"flash":true,"effect":true,"effect_list":["Rainbow","Color Wipe","Scan","Twinkle","Random Twinkle","Fireworks","FastLED Flicker","None"],"name":"Christmas Star","platform":"mqtt_json","state_topic":"star/light/christmas_star/state","command_topic":"star/light/christmas_star/command","availability_topic":"star/status","unique_id":"ESPlightchristmas_star","device":{"identifiers":"device_id","name":"star","sw_version":"esphomelib v1.9.3 Dec 21 2018, 17:08:27","model":"PLATFORMIO_D1_MINI_LITE","manufacturer":"espressif"}}

Any help is appreciated. Thanks.

See https://github.com/OttoWinter/esphomelib/pull/323

1 Like