Help with MQTT

MarcoGT
Posts: 1148
Joined: Thu Sep 11, 2014 1:06 pm
Location: Germany

Help with MQTT

Post by MarcoGT »

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
MarcoGT
Posts: 1148
Joined: Thu Sep 11, 2014 1:06 pm
Location: Germany

Re: Help with MQTT

Post by MarcoGT »

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 2977 times
Screenshot 2022-12-14 alle 12.06.34.png
Screenshot 2022-12-14 alle 12.06.34.png (119.09 KiB) Viewed 2977 times
cuhouse
Posts: 151
Joined: Wed Feb 21, 2007 4:10 pm
Location: Virginia, USA

Re: Help with MQTT

Post by cuhouse »

Marco,

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

Jody
Indigo 2024.1, Monterey v12.7.6, Dedicated late 2014 Mac Mini, PowerLinc 2413U, Shelly/ShellyNG, Lutron Caséta Smart Bridge PRO (L-BDGPRO2-WH).
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Help with MQTT

Post by FlyingDiver »

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
MarcoGT
Posts: 1148
Joined: Thu Sep 11, 2014 1:06 pm
Location: Germany

Re: Help with MQTT

Post by MarcoGT »

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 2935 times
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Help with MQTT

Post by FlyingDiver »

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
MarcoGT
Posts: 1148
Joined: Thu Sep 11, 2014 1:06 pm
Location: Germany

Re: Help with MQTT

Post by MarcoGT »

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 2915 times
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Help with MQTT

Post by FlyingDiver »

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
MarcoGT
Posts: 1148
Joined: Thu Sep 11, 2014 1:06 pm
Location: Germany

Re: Help with MQTT

Post by MarcoGT »

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 2902 times
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Help with MQTT

Post by FlyingDiver »

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
MarcoGT
Posts: 1148
Joined: Thu Sep 11, 2014 1:06 pm
Location: Germany

Re: Help with MQTT

Post by MarcoGT »

It worked!
Thanks a lot!
MarcoGT
Posts: 1148
Joined: Thu Sep 11, 2014 1:06 pm
Location: Germany

Re: Help with MQTT

Post by MarcoGT »

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 2897 times
Screenshot 2022-12-14 alle 21.59.18.png
Screenshot 2022-12-14 alle 21.59.18.png (129.63 KiB) Viewed 2897 times
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Help with MQTT

Post by FlyingDiver »

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
MarcoGT
Posts: 1148
Joined: Thu Sep 11, 2014 1:06 pm
Location: Germany

Re: Help with MQTT

Post by MarcoGT »

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
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Help with MQTT

Post by FlyingDiver »

You need to use "Generic JSON Device".
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Post Reply

Return to “MQTT”