Help with MQTT

Posted on
Wed Dec 14, 2022 4:04 am
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Help with MQTT

Hi all,

I have bought a couple of ESP32 board to be used as presence monitor (using BLE).
This is basically thought to work with MQTT, but I am confused on how to do it.

What do I need on the Indigo side?
MQTT Shims to create a device? What kind of device?

Thanks
Marco

Posted on
Wed Dec 14, 2022 5:08 am
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Help with MQTT

I am trying to playing a little bit, but without success, so far I have:

Code: Select all
14. Dec 2022 at 12:07:23
   MQTT Shims Debug                message_handler: MQTT message ##espresense## from Local MQTT
   MQTT Shims Debug                message_handler: MQTT message ##espresense## from Local MQTT
   MQTT Shims Debug                Bagno_OG: processMessages: '##espresense##' espresense/rooms/bagno_og/telemetry -> {"ip":"192.168.2.118","uptime":2971,"firm":"esp32","rssi":-79,"ver":"v3.1.1","adverts":30411,"seen":30154,"freeHeap":92584,"maxAllocHeap":77812,"memFrag":15.95524065,"scanHighWater":1036,"reportHighWater":808}
   MQTT Shims Error                Bagno_OG: error getting uid value from payload, aborting
   MQTT Shims Debug                Bagno_OG: processMessages: '##espresense##' espresense/rooms/bagno_og/telemetry -> {"ip":"192.168.2.118","uptime":2971,"firm":"esp32","rssi":-79,"ver":"v3.1.1","adverts":30411,"seen":30154,"freeHeap":92584,"maxAllocHeap":77812,"memFrag":15.95524065,"scanHighWater":1036,"reportHighWater":808}
   MQTT Shims Error                Bagno_OG: error getting uid value from payload, aborting



Why is trying to get "status" key from "telemetry"?

Thanks
Attachments
Screenshot 2022-12-14 alle 12.07.01.png
Screenshot 2022-12-14 alle 12.07.01.png (302.05 KiB) Viewed 1907 times
Screenshot 2022-12-14 alle 12.06.34.png
Screenshot 2022-12-14 alle 12.06.34.png (119.09 KiB) Viewed 1907 times

Posted on
Wed Dec 14, 2022 6:55 am
cuhouse offline
Posts: 144
Joined: Feb 21, 2007
Location: Virginia, USA

Re: Help with MQTT

Marco,

From the MQTT Explorer information you provided, status is not JSON. Payload Type: Raw from what I see.

Jody

Indigo 2022.1.2, Big Sur v11.7.1, Dedicated late 2014 Mac Mini, PowerLinc 2413U.

Posted on
Wed Dec 14, 2022 7:06 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help with MQTT

Also the UID ('bagno_og ') is not in the payload, it's part of the topic. Third part, which makes it field 2 (zero based).

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

Posted on
Wed Dec 14, 2022 10:50 am
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Help with MQTT

Thanks a lot for the inputs, but I think I am still missing something

Code: Select all
MQTT Shims Debug                message_handler: MQTT message ##espresense## from Local MQTT
   MQTT Shims Debug                message_handler: MQTT message ##espresense## from Local MQTT
   MQTT Shims Debug                Bagno_OG: processMessages: '##espresense##' espresense/rooms/bagno_og/telemetry -> {"ip":"192.168.2.118","uptime":2175,"firm":"esp32","rssi":-84,"ver":"v3.1.1","adverts":4484,"seen":4437,"freeHeap":93292,"maxAllocHeap":79860,"memFrag":14.39780474,"scanHighWater":1044,"reportHighWater":808}
   MQTT Shims Debug                Bagno_OG: Raw payload = {"ip":"192.168.2.118","uptime":2175,"firm":"esp32","rssi":-84,"ver":"v3.1.1","adverts":4484,"seen":4437,"freeHeap":93292,"maxAllocHeap":79860,"memFrag":14.39780474,"scanHighWater":1044,"reportHighWater":808}
   MQTT Shims Debug                Bagno_OG: states_key=
   MQTT Shims Debug                Bagno_OG: Updating state to False
   MQTT Shims Debug                Bagno_OG: processMessages: '##espresense##' espresense/rooms/bagno_og/telemetry -> {"ip":"192.168.2.118","uptime":2175,"firm":"esp32","rssi":-84,"ver":"v3.1.1","adverts":4484,"seen":4437,"freeHeap":93292,"maxAllocHeap":79860,"memFrag":14.39780474,"scanHighWater":1044,"reportHighWater":808}
   MQTT Shims Debug                Bagno_OG: Raw payload = {"ip":"192.168.2.118","uptime":2175,"firm":"esp32","rssi":-84,"ver":"v3.1.1","adverts":4484,"seen":4437,"freeHeap":93292,"maxAllocHeap":79860,"memFrag":14.39780474,"scanHighWater":1044,"reportHighWater":808}
   MQTT Shims Debug                Bagno_OG: states_key=
   MQTT Shims Debug                Bagno_OG: Updating state to False
   Hubitat Bridge                  received "Movimento Cucina" motion sensor "active" event
   MQTT Shims Debug                message_handler: MQTT message ##espresense## from Local MQTT
   MQTT Shims Debug                message_handler: MQTT message ##espresense## from Local MQTT
   MQTT Shims Debug                Bagno_OG: processMessages: '##espresense##' espresense/rooms/bagno_og/telemetry -> {"ip":"192.168.2.118","uptime":2190,"firm":"esp32","rssi":-81,"ver":"v3.1.1","adverts":4637,"seen":4590,"freeHeap":93292,"maxAllocHeap":79860,"memFrag":14.39780474,"scanHighWater":1044,"reportHighWater":808}
   MQTT Shims Debug                Bagno_OG: Raw payload = {"ip":"192.168.2.118","uptime":2190,"firm":"esp32","rssi":-81,"ver":"v3.1.1","adverts":4637,"seen":4590,"freeHeap":93292,"maxAllocHeap":79860,"memFrag":14.39780474,"scanHighWater":1044,"reportHighWater":808}
   MQTT Shims Debug                Bagno_OG: states_key=
   MQTT Shims Debug                Bagno_OG: Updating state to False
   MQTT Shims Debug                Bagno_OG: processMessages: '##espresense##' espresense/rooms/bagno_og/telemetry -> {"ip":"192.168.2.118","uptime":2190,"firm":"esp32","rssi":-81,"ver":"v3.1.1","adverts":4637,"seen":4590,"freeHeap":93292,"maxAllocHeap":79860,"memFrag":14.39780474,"scanHighWater":1044,"reportHighWater":808}
   MQTT Shims Debug                Bagno_OG: Raw payload = {"ip":"192.168.2.118","uptime":2190,"firm":"esp32","rssi":-81,"ver":"v3.1.1","adverts":4637,"seen":4590,"freeHeap":93292,"maxAllocHeap":79860,"memFrag":14.39780474,"scanHighWater":1044,"reportHighWater":808}
   MQTT Shims Debug                Bagno_OG: states_key=
   MQTT Shims Debug                Bagno_OG: Updating state to False
   Hubitat Bridge                  received "Movimento Bagno-EG" motion sensor "active" event
   MQTT Shims Debug                validateDeviceConfigUi, devId=178623972, typeId=shimOnOffSensor, valuesDict = UiValuesDict : (dict)
Attachments
Screenshot 2022-12-14 alle 12.07.01.png
Screenshot 2022-12-14 alle 12.07.01.png (302.05 KiB) Viewed 1865 times

Posted on
Wed Dec 14, 2022 11:52 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help with MQTT

You didn't fix either of the issues pointed out to you already.

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

Posted on
Wed Dec 14, 2022 1:50 pm
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Help with MQTT

Sorry, you are right, uploaded wrong screenshot
Attachments
Screenshot 2022-12-14 alle 17.49.24.png
Screenshot 2022-12-14 alle 17.49.24.png (252.1 KiB) Viewed 1845 times

Posted on
Wed Dec 14, 2022 2:24 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help with MQTT

Looks to me like your trigger is matching on any of the messages from the device, not just the status topic. I don't see any status topic messages in the log excerpt you posted.

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

Posted on
Wed Dec 14, 2022 2:31 pm
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Help with MQTT

This is my trigger
Attachments
Screenshot 2022-12-14 alle 21.31.13.png
Screenshot 2022-12-14 alle 21.31.13.png (116.52 KiB) Viewed 1832 times

Posted on
Wed Dec 14, 2022 2:35 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help with MQTT

Yeah, that's not going to work. You need to trigger on the specific message topic for the value you're looking for, which is "espresense/rooms/bagno_og/status". So you need:


Code: Select all
Match: espresense
Match: rooms
Any:
Match: status
End:


The any is there because if you if have multiple devices, you want the trigger to work for all of them, identified by the uniqueID (bagno_og)

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

Posted on
Wed Dec 14, 2022 2:41 pm
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Help with MQTT

It worked!
Thanks a lot!

Posted on
Wed Dec 14, 2022 3:01 pm
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Help with MQTT

Now I am doing something different, because I would like not only to get the status value, but also other data in it.
My idea was to create a trigger for every /rooms/<device>, is this approach correct?

Therefore I would have as follows, but something seems wrong as it does not work
Attachments
Screenshot 2022-12-14 alle 22.01.04.png
Screenshot 2022-12-14 alle 22.01.04.png (221.83 KiB) Viewed 1827 times
Screenshot 2022-12-14 alle 21.59.18.png
Screenshot 2022-12-14 alle 21.59.18.png (129.63 KiB) Viewed 1827 times

Posted on
Wed Dec 14, 2022 3:26 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help with MQTT

MarcoGT wrote:
Now I am doing something different, because I would like not only to get the status value, but also other data in it.
My idea was to create a trigger for every /rooms/<device>, is this approach correct?


No. You can create a trigger for each message type you want to use, but they're re-used for multiple devices.

The Shim device represents a specific value (or possibly set of values) for a specific MQTT topic message. So you can use a trigger for all devices for THAT message type. Each message type represents a different topic. Each topic/uniqueID combo maps to a different Shim device.

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

Posted on
Wed Dec 14, 2022 3:33 pm
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Help with MQTT

Yes, in the meantime I modified and used that approach; now I am trying to create a device representing the IP, but what type of sensor shall I use? If I use generic, I get error "unable to convert to float".

Thanks

Posted on
Wed Dec 14, 2022 3:39 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help with MQTT

You need to use "Generic JSON Device".

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

Who is online

Users browsing this forum: No registered users and 11 guests