Integration Solutions using MQTT

4 posts were split to a new topic: Help needed with rule JSON for mqtt integration

Community-developed drivers often use “custom capabilities” (i.e. fields or controls) when there is no stock SmartThings capability that meets the need. SmartThngs assigns a random ID to developers that is used to create and identify their custom capabilities. My assigned ID happens to be ‘partyvoice23922’, so for devices created by my drivers, you’ll often find they contain some custom capabilities that include this name.

A quick tip for finding out what these capabilities are for any given device is to use my API Browser+ app. From the Devices menu, you can select the device of interest from the devices list, then tap the Status button and it will show all the components, capabilities, and attributes defined in the device. So you can quickly see what you need to include in your Rule definition.


thanks ,
i see i can create rules in the api browser+

i tried uploading the json and got a hhtp error 422 the request is malformed ,

Yes! I should have mentioned that. It might be a bit easier than using the CLI. But it doesn’t help you with the actual creation of the JSON file itself. Just with the submission to SmartThings.

2 posts were merged into an existing topic: Help needed with rule JSON for mqtt integration

all we need now is a rule to send send mqtt payloads so you dont need a virtual device

ps it was realy easy to add the json to the hub with API BROWSER+

A very basic question. I created an MQTT momentary button as smartthings/momentary/radio/state. I can see it in MQTT Explorer but the state always shows as “push”. I would expect to see maybe “standby” or “pressed” but it always remains unchanged as “push”.

Any thoughts on what I may have done wrong?

Edit: Figured it out. Simply wasn’t the behavior I expected. “State” doesn’t change despite the message being received.

I’m not sure I’m following you. An MQTT button device created with the MQTT Devices driver, should have a one of 4 states: pressed, double pressed, held, or pressed 3 times. When not activated, you would see ‘Standby’ showing in the Control screen for the device.

The button state should absolutely change to one of the values above as long as you are sending the right message payload in the MQTT message and you have it configured in the device Settings screen.

EDIT: I think I know what you are looking at; if you look at the button attribute using the API (via CLI or other tools) then yes, the state shown there is whatever the last value was emitted for the button. So yes, from that perspective the state doesn’t go back to standby.

1 Like

Yes. In the same way that the app has a quick change of status: standby - pressed - standby, I expected to see the same behavior in MQTT Explorer. But instead of “standby” or “pressed”, I would only see “push” regardless of whether I pressed the button. I attached an action (Node-Red) to the receipt of the mqtt button-press and it works perfectly. Sorry for the false alarm.

Unfortunately, just like the mqtt contacts I set up previously, the mqtt momentary device is not recognized by ActionTiles either. I “really” have to open a case with AT.

One last note I stumbled upon in the event anyone else has this issue. I set up my mqtt contacts several weeks ago and they all work great. Then I began setting up these mqtt momentary buttons and whenever I went to create a new mqtt device it would spin until I got a network or server error. Tried all the usual cures: re-start ST, delete and re-install ST app, etc with no luck. I checked the driver for the MQTT creator and I was at the latest version which had updated since creating my original devices. By deleting the MQTT Creator app and re-installing, it worked fine. It almost seems as if I had to delete and reinstall the MQTT App to have it work with the new driver. I’m probably wrong but that’s what fixed it for me.

EDIT: Updated ActionTiles today and mqtt devices now visible.

Any idea why my mqtt switch requires a refresh every two days to keep working? Could it be my settings see below

When this happens again, can you check to verify that messages are still coming through from MQTT? You can use the mosquitto client to subscribe to topics and monitor messages:

mosquitto_sub -v -h <brokerIP> -t <topic> -u <username> -P <password>

Try this BEFORE you hit the refresh button in the SmartThings device.

When you are pressing the Refresh button to get it working again, are you pressing the button in the device or in the MQTT Device Creator?

yeah I monitored the messages and they are still coming through before I hit the refresh button.
I am pressing the refresh button only on the one in the device NOT the one in the mqtt device creator.

1 Like

Can you try and determine exactly when your SmartThings device stops updating? You had mentioned every 2 days. Is this consistent over the course of a week?

I could add a periodic routine to resubscribe, but I wonder why this would be needed?

Do you have anything other than standard broker configuration options? Are you using Mosquitto?

It seems to be inconsistent and disconnecting a lot

Yes I’m using mosquito broker, I think I have a standard setup, do these settings seem ok?

You are using a phone app to configure your Mosquitto broker? I’m not familiar with that!

Turn off the Enable birth message, Birth message retain, Enable will message, and Will message retain options.

Yeah I suppose you can, unfortunately the setting changes did not work. Also it loses connection randomly, sometimes it will last nearly a day but usually it’s a few hours. One time it only lasted 25 mins. Can you do a refresh once every hour?

I’m going to look at periodic resubscribes but technically they shouldn’t be necessary.

What kind of hub do you have?

What is your broker running on? You may also have network problems. Is the machine running your broker under the same router as your hub? Are they both within the same subnet?

Do you have any firewalls, VLANs, VMs, Docker Containers, etc that could be blocking traffic?

1 Like

What kind of hub do you have?
Smartthings wifi

What is your broker running on?
The broker is on home assistant that is running on an odroid board that is the same network as the smartthings wifi hub same subnet

Do you have any firewalls, VLANs, VMs, Docker Containers, etc that could be blocking traffic?

I hate to say it but the wifi mesh hubs have had a lot of trouble with Edge LAN drivers. It’s been reported to SmartThings, but there have been no answers.

It is also possible there is a problem with the HA’s broker. I seem to recall someone else trying to use that and they ended up having to install a separate Mosquitto broker because they were having similar problems.

Do you have anything else you can use to do a long-term test of the MQTT broker connection? Perhaps something like MQTT explorer. You just need something that subscribes to the particular topic and then you leave it running for several days to see if it continues to receive published messages from your broker. Even something like mosquitto_sub could be used, and redirect the output to a file. If that also fails, then we’d know that the problem is not in the Edge driver but rather with your HA broker or the network.

1 Like