Topic/payload Confusion

Posted on
Sat Oct 12, 2019 8:12 am
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Topic/payload Confusion

Apologies for the brain lapse this morning - I've checked the Wiki and read through the threads and can't seem to find what I'm looking for.

I have the plugin loaded and communicating with an external MQTT broker. I can see messages being published from Indigo to the broker. For testing, I'm currently subscribing to '#' and my publishing topic is set to:
indigo/{{deviceId}}/update
with the default payload JSON template.

What I want to do is control the device state/value of Indigo Devices/Variables through MQTT.

So let's say I have an Indigo Device "Master Bedroom Lights' with a device id of '303008679', what would be the correct topic/payload to publish to turn on/off or dim that device from outside of Indigo (Using MQTTLens and Home Assistant to test)?

Thanks in advance!

Terry

Posted on
Sat Oct 12, 2019 8:35 am
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Topic/payload Confusion

roussell wrote:
So let's say I have an Indigo Device "Master Bedroom Lights' with a device id of '303008679', what would be the correct topic/payload to publish to turn on/off or dim that device from outside of Indigo (Using MQTTLens and Home Assistant to test)?


Totally up to you. ;)

First, you don't need to publish anything to get MQTT->Indigo control to work. Publishing is for sending data out from Indigo to be used somewhere else.

Second, the plugin doesn't have a built in mechanism to control Indigo devices. That's a dangerous thing to implement in any kind of generic fashion. But you can do it.

  1. Decide how you want the control topic structured. Something like 'indigo/<<deviceID>>/command/<<cmd>>' work work.
  2. Subscribe to 'indigo/#'
Now you have a choice of two ways to do things. The no-script way for a few selected devices, or the Python script way which can handle arbitrary devices or commands.

The no-scripting way is to create an MQTT Topic Component Match trigger that matches one exact combination of deviceID and command. IE, it matches the exact topic. Then just put whatever command(s) you want in the action group. You will need two or more triggers for every device.

The more generic way is to creat an MQTT Topic Component Match trigger which has the components 'Match: indigo', 'Any', 'Match: command', 'Any'. That will fire when you get any command message. Then write a Python script which looks at the "last_topic" and "last_payload" states and does whatever it needs to do.

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

Posted on
Sat Oct 12, 2019 8:46 am
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Re: Topic/payload Confusion

Gotcha, thanks. I was thinking it functioned more like the built-in REST server. I'll go the catch-all route with python to avoid several hundred triggers!

Terry

Posted on
Sat Oct 12, 2019 8:48 am
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Topic/payload Confusion

roussell wrote:
Gotcha, thanks. I was thinking it functioned more like the built-in REST server. I'll go the catch-all route with python to avoid several hundred triggers!


I thought about doing that, but I really didn't want to deal with the security issues. Now if you wanted to post your script as a sample in the plugin Wiki, that would be great. ;)

And I'm not totally averse to revisiting this subject in the future.

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 1 guest