Getting value from JSON into device

Posted on
Mon Oct 18, 2021 7:53 am
roquej offline
User avatar
Posts: 608
Joined: Jan 04, 2015
Location: South Florida, USA

Getting value from JSON into device

Mr. MQTT Jedi, while you have a chance to work on the Nexia plugin, I am trying to get a few details from my Nexia thermostat using MQTT and Home Assistant. Got the temperature and humidity without any issues. However, having a problem understanding how to get the "system status", a string, configured.

The topic looks like this:

Screen Shot 2021-10-18 at 9.30.08 AM.png
Screen Shot 2021-10-18 at 9.30.08 AM.png (50.45 KiB) Viewed 1765 times


So, trying to configure the device as such:

Device type: Generic JSON

Screen Shot 2021-10-18 at 9.30.08 AM.png
Screen Shot 2021-10-18 at 9.30.08 AM.png (50.45 KiB) Viewed 1765 times


What am I doing wrong?

Thank you!!

JP
Attachments
Screen Shot 2021-10-18 at 9.36.23 AM.png
Screen Shot 2021-10-18 at 9.36.23 AM.png (163.38 KiB) Viewed 1765 times

Posted on
Mon Oct 18, 2021 9:34 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Getting value from JSON into device

It doesn't look like you're showing the complete topic string there. It easier to see what's going on if you configure the MQTT Connector plugin to subscribe to the topics you want, then put it in debug level logging so it logs the topics and payloads.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Oct 18, 2021 12:31 pm
roquej offline
User avatar
Posts: 608
Joined: Jan 04, 2015
Location: South Florida, USA

Re: Getting value from JSON into device

This is from the debug mgs and exactly the info I would like to collect via a Shims device:

processMessages: '##haSensors##' homeassistant/sensor/house_system_status/state -> System Idle

is this enough to point me in the right direction?

JP

Posted on
Mon Oct 18, 2021 12:52 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Getting value from JSON into device

From that, it looks like the payload for that topic is NOT a JSON string, but a plain text string. I'm not sure the Shims plugin can deal with that the way you want. Is there any way to get HA to send actual JSON?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Oct 18, 2021 1:52 pm
roquej offline
User avatar
Posts: 608
Joined: Jan 04, 2015
Location: South Florida, USA

Re: Getting value from JSON into device

Not sure, but I will check. Will let you know

Thank you!

Posted on
Mon Oct 18, 2021 1:56 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Getting value from JSON into device

If not, you can modify this script to get the payload and put it in a variable. Edit as needed and run as an external script.
Code: Select all
#! /usr/bin/env python
# -*- coding: utf-8 -*-
####################

import json
import time
import indigo

mqttPlugin = indigo.server.getPlugin("com.flyingdiver.indigoplugin.mqtt")
if mqttPlugin.isEnabled():
    props = {
        'message_type':"#Test#"
    }
    while True:
        message_data = mqttPlugin.executeAction("fetchQueuedMessage", deviceId=1867973662, props=props, waitUntilDone=True)
        if message_data != None:
            indigo.server.log("Queue Fetch, version = {}, message_type = {}, topic_parts = {}".format(message_data["version"], message_data["message_type"], message_data["topic_parts"]))
            payload = json.loads(message_data["payload"])
            indigo.server.log("Queue Fetch, payload = {}".format(payload))
        else:
            time.sleep(1.0)


The deviceid in the call to mqttPlugin.executeAction() is the MQTT Connector device.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Oct 18, 2021 3:12 pm
roquej offline
User avatar
Posts: 608
Joined: Jan 04, 2015
Location: South Florida, USA

Re: Getting value from JSON into device

as always, you rock!! thank you!

JP

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests