OpenMQTTGateway to ESPEasy - JSON parsing

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
kazmid
New user
Posts: 9
Joined: 04 Sep 2023, 20:25

OpenMQTTGateway to ESPEasy - JSON parsing

#1 Post by kazmid » 04 Sep 2023, 22:31

Hi All,
I'm trying to understand how MQTT import works in ESPEasy. This is my 2nd post on a similar topic.

I have ESP32 with OpenMQTTGateway and I download data from Xiaomi Thermometers

It looks like. JSON payload:

Code: Select all

{"id":"58:2D:34:38:F4:6F","name":"MJ_HT_V1","rssi":-89,"brand":"Xiaomi","model":"Mi Jia round","model_id":"LYWSDCGQ","type":"THB","tempc":23.5,"tempf":74.3,"hum":58.6}
Can I configure ESPEasy import to read Temperature, Humidity and Battery Status?

Thank you for your help and your time.

TD-er
Core team member
Posts: 8756
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: OpenMQTTGateway to ESPEasy - JSON parsing

#2 Post by TD-er » 04 Sep 2023, 22:35

There is some documentation on the MQTT import plugin: https://espeasy.readthedocs.io/en/lates ... #p037-page

Not all features for this plugin are included in each build due to build size.
If your ESP32 does have 16 MB flash (highly recommended), you can use the "MAX" build, which has all plugins and all features included.

kazmid
New user
Posts: 9
Joined: 04 Sep 2023, 20:25

Re: OpenMQTTGateway to ESPEasy - JSON parsing

#3 Post by kazmid » 05 Sep 2023, 12:54

Hi

Successfully fetched data using configuration as below:

Code: Select all

Parse JSON messages: = Yes

Code: Select all

Prefix for all topics: omg/OMGateway/BTtoMQTT/
MQTT Topic:

Code: Select all

Topic = 582D3438F46F JSON Attribute = tempc

Code: Select all

Topic = 582D3438F46F JSON Attribute = hum

Code: Select all

Topic = 582D3438F46F JSON Attribute = batt

Code: Select all

Topic = 582D3438F46F JSON Attribute = rssi
But there is a problem when a new payload is sent and one of the attributes is missing, nan or 00 appears in the place until this data appears in the next payload.

User avatar
Ath
Normal user
Posts: 3519
Joined: 10 Jun 2018, 12:06
Location: NL

Re: OpenMQTTGateway to ESPEasy - JSON parsing

#4 Post by Ath » 05 Sep 2023, 14:39

kazmid wrote: 05 Sep 2023, 12:54 But there is a problem when a new payload is sent and one of the attributes is missing, nan or 00 appears in the place until this data appears in the next payload.
Hmm, I could add an option of what to do with a missing attribute-value, I'll think about how to solve that.
/Ton (PayPal.me)

kazmid
New user
Posts: 9
Joined: 04 Sep 2023, 20:25

Re: OpenMQTTGateway to ESPEasy - JSON parsing

#5 Post by kazmid » 05 Sep 2023, 14:46

It would be great.
Please let me know when the option will be available, e.g. in the form of a checkbox.
Thank you Ath

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests