Hi Guys,
I’ve put together the attached input for mqtt messages encoded in JSON format. My use case is a sensor that posts to a topic with multiple measurements taken published in JSON format. This is able to take the JSON keys and pull out the values. Pretty simple and straightforward, but powerful in having remote sensors.mqtt_paho_json.py (11.5 KB)
Thanks. It looks great. I’ll see if I can think of any changes over the next day, then commit it for the next release. It looks like a nice addition to the MQTT Input lineup.
Was something along these lines ever finalized for inclusion?
I ask because Im onto something similar. Sending JSON string as MQTT output.
For example, sending the following string as an MQTT output:
“IRhvac{“Vendor”:“MIDEA”,“Model”:-,“Mode”:“Cool”,“Power”:“On”,“Celsius”:“Off”,“Temp”:72,“FanSpeed”:“Max”,“SwingV”:“Off”,“SwingH”:“Off”,“Quiet”:“Off”,“Turbo”:“Off”,“Econo”:“Off”,“Light”:“Off”,“Filter”:“Off”,“Clean”:“Off”,“Beep”:“Off”,“Sleep”:-1}”
Yes, this Input was added years ago.
Does the option exist to send JSON strings as MQTT output?
MQTT On/Off Output payloads have always been text. See:
I was wondering about that as the output config text states “(or any other strings of your choosing)” for the ON/OFF output.
Have you considered creating an output similar to “Value: MQTT Publish” but instead “String: MQTT Publish”?
The Value MQTT Output does send the payload as a string. What are you trying to accomplish that can’t already be done with the current Outputs?
I am trying to control a mini split HVAC system (Pioneer) using a infrared puck emitter flashed with Tasmota, which communicates with Mycodo via MQTT.
Tasmota has the ability to accept JSON string input from an MQTT source but somewhere in the process a string that will work for HVAC control when input directly via the Tasmota console somehow gets transmitted incorrectly when I try using any MQTT source from Mycodo.
The string I am trying to send is this with minor changes based on I want to control.
“IRhvac” {“Vendor”:“MIDEA”,“Model”:-1,“Mode”:“Heat”,“Power”:“Off”,“Celsius”:“Off”,“Temp”:72,“FanSpeed”:“Max”,“SwingV”:“Off”,“SwingH”:“Off”,“Quiet”:“Off”,“Turbo”:“Off”,“Econo”:“Off”,“Light”:“Off”,“Filter”:“Off”,“Clean”:“Off”,“Beep”:“Off”,“Sleep”:-1}
Can you elaborate on this and provide examples of what is occurring?
I will get everything set up and record as much info as I can