Put last payload contents into a variable.

Posted on
Sun Sep 20, 2020 12:15 am
ppespepe offline
Posts: 49
Joined: May 27, 2020

Put last payload contents into a variable.

Hello everyone!

I was wondering if there is a way to write the payload from a topic, to a variable.

I'm using a trigger to match the component and then trying to figure out a way to use the action to put payload value into a variable.

Thanks in advance!

Posted on
Sun Sep 20, 2020 4:17 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Put last payload contents into a variable.

You want the "Insert Device State into Variable" action.
Attachments
Screen Shot 2020-09-20 at 6.16.12 AM.jpg
Screen Shot 2020-09-20 at 6.16.12 AM.jpg (185.47 KiB) Viewed 1895 times

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

Posted on
Sun Sep 20, 2020 11:56 am
ppespepe offline
Posts: 49
Joined: May 27, 2020

Re: Put last payload contents into a variable.

That is AWESOME!!!

Worked like a charm!

Thanks Diver!

PP

Posted on
Sun Sep 20, 2020 12:10 pm
ppespepe offline
Posts: 49
Joined: May 27, 2020

Re: Put last payload contents into a variable.

On another slightly different subject... what is this and how can I solve it? :lol:

Queue for message type '##EatonStatus##' has 1455 messages pending

It sound self explanatory but I have no idea why... :D

Thanks in advance!!!

PP

Posted on
Sun Sep 20, 2020 12:27 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Put last payload contents into a variable.

Make sure this check box is NOT checked. It's only for use with the MQTT Shims plugin (or specially written scripts).
Attachments
Screen Shot 2020-09-20 at 2.25.24 PM.jpg
Screen Shot 2020-09-20 at 2.25.24 PM.jpg (107.5 KiB) Viewed 1871 times

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

Posted on
Sun Sep 20, 2020 4:15 pm
ppespepe offline
Posts: 49
Joined: May 27, 2020

Re: Put last payload contents into a variable.

FlyingDiver wrote:
Make sure this check box is NOT checked. It's only for use with the MQTT Shims plugin (or specially written scripts).


Awesome!!! Thanks again! :D

Posted on
Wed Nov 18, 2020 10:31 pm
geoffsharris offline
Posts: 45
Joined: Nov 26, 2012

Re: Put last payload contents into a variable.

Hi,

This looks really cool and I feel like I'm having a bit a difficulty figuring out the last steps.

I have a weather station that is feeding data to a Mosquitto broker on my mac at the local host, no password, not encrypted. Very simple.

I set up the device:
Screen Shot 2020-11-18 at 7.54.26 PM.png
Screen Shot 2020-11-18 at 7.54.26 PM.png (42.41 KiB) Viewed 1713 times


And I set the debug so I can see that the data is getting into Indigo:
Screen Shot 2020-11-18 at 8.04.54 PM.png
Screen Shot 2020-11-18 at 8.04.54 PM.png (40 KiB) Viewed 1713 times


I have set up the subscription as:
Screen Shot 2020-11-18 at 8.03.01 PM.png
Screen Shot 2020-11-18 at 8.03.01 PM.png (37.15 KiB) Viewed 1713 times


And I'm trying to get the weather/extraTemp1_F payload into a variable or device state. Any pointers here would be great. I've tried:
Screen Shot 2020-11-18 at 8.13.21 PM.png
Screen Shot 2020-11-18 at 8.13.21 PM.png (32.84 KiB) Viewed 1713 times

Screen Shot 2020-11-18 at 8.17.49 PM.png
Screen Shot 2020-11-18 at 8.17.49 PM.png (49.38 KiB) Viewed 1713 times

Screen Shot 2020-11-18 at 8.26.26 PM.png
Screen Shot 2020-11-18 at 8.26.26 PM.png (53.65 KiB) Viewed 1713 times

Screen Shot 2020-11-18 at 8.27.47 PM.png
Screen Shot 2020-11-18 at 8.27.47 PM.png (62.01 KiB) Viewed 1713 times


Any help to fix what might be obvious would be much appreciated. Still not getting the MQTT variable to update with the value.

Posted on
Thu Nov 19, 2020 4:13 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Put last payload contents into a variable.

Two things. For your Broker device configuration, if you're subscribing to "weather/#", then you don't need "weather/extraTemp1_F". The '#' is a wildcard. Having both isn't broken, but it's redundant.

For the trigger, the match list should be:

Code: Select all
Match: weather
Match: extraTemp1_F
End:


The order matters, because it's matching each component of the topic left to right. The topic string is split on the slashes, so you never put them in the match strings.

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

Posted on
Thu Nov 19, 2020 9:14 am
geoffsharris offline
Posts: 45
Joined: Nov 26, 2012

Re: Put last payload contents into a variable.

Awesome! How to set up the parsing of the topics wasn't clear to me. Thank you!

I did also find one other issue to share with others. In the manage aggregators function in the plugin setup, it looks like I added the following :
Screen Shot 2020-11-19 at 6.49.21 AM.png
Screen Shot 2020-11-19 at 6.49.21 AM.png (32.09 KiB) Viewed 1684 times

the ":" blank one seems to have prevented me from getting the payload into the variable. Once I deleted this, all was right with the world.

Since the mqtt feed has about a dozen different variables in weather/# I'd like to get into Indigo, do I need a trigger for each one or is there a better way to parse the components in weather/# into individual variables?

Posted on
Thu Nov 19, 2020 9:19 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Put last payload contents into a variable.

geoffsharris wrote:
Since the mqtt feed has about a dozen different variables in weather/# I'd like to get into Indigo, do I need a trigger for each one or is there a better way to parse the components in weather/# into individual variables?


Yeah, the way that feed is structured you're going to need to do each one individually. If it was one topic with multiple values in the payload you could do it with a single trigger but not when each topic is distinct.

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

Posted on
Thu Nov 19, 2020 2:10 pm
geoffsharris offline
Posts: 45
Joined: Nov 26, 2012

Re: Put last payload contents into a variable.

Hi,

It looks like I can also sent the packet to aggregate as a single JSON string rather than as individual topics.
From the Debug Logger
Code: Select all
MQTT Connector Debug            MQTT Weather TV Mac Mini: Message received: weather/loop, payload: {"dateTime": "1605816354.0", "usUnits": "1.0", "barometer_inHg": "29.919", "inTemp_F": "71.2", "inHumidity": "55.0", "outTemp_F": "59.0", "windSpeed_mph": "0.0", "windSpeed10_mph": "0.0", "extraTemp1_F": "56.0", "extraTemp2_F": "71.0", "extraTemp3_F": "77.0", "outHumidity": "82.0", "extraHumid1": "84.0", "extraHumid2": "87.0", "extraHumid3": "71.0", "rainRate_inch_per_hour": "0.0", "radiation_Wpm2": "362.0", "stormRain_in": "0.0", "dayRain_in": "0.01", "monthRain_in": "0.72", "yearRain_in": "0.73", "dayET": "0.023", "monthET": "1.3", "yearET": "39.94", "leafWet4": "0.0", "insideAlarm": "0.0", "rainAlarm": "0.0", "outsideAlarm1": "0.0", "outsideAlarm2": "0.0", "extraAlarm1": "0.0", "extraAlarm2": "0.0", "extraAlarm3": "0.0", "extraAlarm4": "0.0", "extraAlarm5": "0.0", "extraAlarm6": "0.0", "extraAlarm7": "0.0", "extraAlarm8": "0.0", "soilLeafAlarm1": "0.0", "soilLeafAlarm2": "0.0", "soilLeafAlarm3": "0.0", "soilLeafAlarm4": "0.0", "txBatteryStatus": "0.0", "consBatteryVoltage_volt": "4.13", "forecastIcon": "6.0", "forecastRule": "45.0", "sunrise": "1605796704.0", "sunset": "1605834720.0", "rain_in": "0.0", "windGust_mph": "1.0", "windGustDir": "319.0", "pressure_inHg": "29.72947508822843", "altimeter_inHg": "29.920889211259254", "windchill_F": "59.0", "heatindex_F": "59.0", "dewpoint_F": "53.51039198837947", "inDewpoint_F": "54.193098472434244", "maxSolarRad_Wpm2": "503.0578905003942", "cloudbase_foot": "1422.6381844592117", "humidex_F": "63.02085210222074", "appTemp_F": "60.08883824680897", "hourRain_in": "0.0", "rain24_in": "0.01"}

I can get this into a variable and I'm wondering if there is an elegant way to parse the JSON into variables

Posted on
Thu Nov 19, 2020 2:15 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Put last payload contents into a variable.

Skip the variable totally. Use the MQTT Shims plugin and create a "Value Sensor" device. Pick whatever attribute (temperature, probably) you want as the sensor value. Then put a ".' (period) in the "multi-states" field. Now all of those different values are available as device states. No need for variables at all.

Read the instructions on the Wiki for more details like setting up the trigger properly.

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

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests