# MQTT Client setup (with Sonoff/ Tasmota Rules)

**URL:** <https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802>\
**Category:** Apps\
**Created:** [May 7, 2019, 6:34pm UTC](https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802 "2019-05-07T18:34:05Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leo838](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/leo838/32/12912_2.png) [@Leo838](https://community.homey.app/u/Leo838)\
**Post date:** [May 7, 2019, 6:34pm UTC](https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802/1 "2019-05-07T18:34:05Z")

</div>

Hello all,

I’m trying to use MQTT Client ([https://apps.athom.com/app/nl.scanno.mqtt](https://apps.athom.com/app/nl.scanno.mqtt)) combined with a D1 mini running Tasmota. I’ve created a ‘rule’ ([https://github.com/arendst/Sonoff-Tasmota/wiki/Rules](https://github.com/arendst/Sonoff-Tasmota/wiki/Rules)) to send a MQTT message once a certain value is reached on a sensor attached to the D1. However I’m uncertain of how to setup the MQTT Client trigger.

I see the tag ‘Message received from topic’ & ‘Name Topic’ but the text to the right is cut off from the screen (I’ve tried rotating to no avail). What is the correct format to use? Must tags be used or can I get the D1 to send out any particular message that the client will recognise & trigger on?

Thanks,

 ![MQTT%20Client](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/a/a608542e3a34216696ba305156c66dcb7901728e.jpeg)

---

<div class="post-metadata">

**Author:** ![Rocodamelshekima](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rocodamelshekima/32/8209_2.png) [@Rocodamelshekima](https://community.homey.app/u/Rocodamelshekima)\
**Post date:** [May 7, 2019, 6:40pm UTC](https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802/2 "2019-05-07T18:40:59Z")

</div>

![chrome_2019-05-07_20-40-32](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/c/c025fd17c9879a1e2d029b5b9b8ed371ffa73ec8.png)

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [May 7, 2019, 7:19pm UTC](https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802/3 "2019-05-07T19:19:08Z")

</div>

Those are the tags that the trigger flow card provides (and that you can use in condition/action cards, for instance). Because the MQTT Client can trigger on wildcard topics, the `Name Topic` tag can be used to determine the exact topic that the message was posted to.

The “Topic” part is the one that you have to fill in, and should contain the topic that the rule will post a message to.

---

<div class="post-metadata">

**Author:** ![Leo838](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/leo838/32/12912_2.png) [@Leo838](https://community.homey.app/u/Leo838)\
**Post date:** [May 11, 2019, 10:08am UTC](https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802/4 "2019-05-11T10:08:09Z")

</div>

Thanks both for the replies. I’m still having some difficulty however. From the console of the D1 when a switch is activated the following MQTT appear to be sent:

```
11:02:15 MQT: stat/post/RESULT = {"POWER":"ON"}
11:02:15 MQT: stat/post/POWER = ON
11:02:15 MQT: stat/post/RESULT = {"POWER":"OFF"}
11:02:16 MQT: stat/post/POWER = OFF

```

So to capture this switch activation on the MQTT client would it be correct to construct the flow as follows:

 ![Screenshot%20from%202019-05-11%2011-06-14](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/d/db85e1cefa951fb627c88fc0368432d5be6c0228.png)

---

<div class="post-metadata">

**Author:** ![Leo838](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/leo838/32/12912_2.png) [@Leo838](https://community.homey.app/u/Leo838)\
**Post date:** [May 11, 2019, 10:51am UTC](https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802/5 "2019-05-11T10:51:38Z")

</div>

No luck so far with this but I think the setup is complicated but the UI. On my android phone it’s not possible to select the Tags (in green) as indicated by the arrows in the picture, but it is on my Firefox browser (& Chromium).

 ![Screenshot_20190511-114809_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/c/c49a7cb97012f1c7d4495ac8d2875dfe48823852.jpeg)

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [May 11, 2019, 10:57am UTC](https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802/6 "2019-05-11T10:57:32Z")

</div>

The topics in your example are `stat/post/RESULT` and `stat/post/POWER`. Everything after the `=` is the message.

---

<div class="post-metadata">

**Author:** ![Leo838](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/leo838/32/12912_2.png) [@Leo838](https://community.homey.app/u/Leo838)\
**Post date:** [May 11, 2019, 11:20am UTC](https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802/7 "2019-05-11T11:20:32Z")

</div>

Thanks Robert. On selection of the green tag (eg. ‘Message received from topic’) is another text box meant to appear? As currently this is the only way I can enter text:

 ![SmartSelect_20190511-122154_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/2/274eeadf779cc4901fc72634617b8382e921b9cb.jpeg)  
& from MQTT Client logs it doesn’t seem like the topic is being correctly subscribed to:

![Screenshot%20from%202019-05-11%2012-23-47](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/f/f59b439937211c9ea2aef0448edbbacb7934f2f0.png)

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [May 11, 2019, 11:26am UTC](https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802/8 "2019-05-11T11:26:23Z")

</div>

The topic field should only contain the topic name (`stat/power/POWER`), not the tag.

For example (from the [flow web interface](https://flow.homey.app/)):  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/f/ff2eb08e6af3522803a9c7f7d76acef35703e446.jpeg)

---

<div class="post-metadata">

**Author:** ![Leo838](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/leo838/32/12912_2.png) [@Leo838](https://community.homey.app/u/Leo838)\
**Post date:** [May 11, 2019, 11:31am UTC](https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802/9 "2019-05-11T11:31:23Z")

</div>

Ahh, I see. Thanks very much, Ive managed to get it working now.

Is there anyway to examine the MQTT message (e.g. ON or OFF)?

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [May 11, 2019, 11:37am UTC](https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802/10 "2019-05-11T11:37:01Z")

</div>

Yes, _that’s_ where you can use the tag. For instance in an “AND” card (using Logic “equals”):

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/b/b660ebe62c5126c1c3c5e0fdfe4f8a03285a17e4.jpeg)

- “Bericht ontvangen via topic” = “Message received from topic”
- “is precies” = “equals”

---

<div class="post-metadata">

**Author:** ![Leo838](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/leo838/32/12912_2.png) [@Leo838](https://community.homey.app/u/Leo838)\
**Post date:** [May 11, 2019, 11:42am UTC](https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802/11 "2019-05-11T11:42:15Z")

</div>

Thanks very much indeed, got it now.

For anyone else following here it is put together:

 ![Screenshot%20from%202019-05-11%2012-41-08](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/1/1ff8f0ae5a5a57ed4736cbe154f1e3ceff4b4f59.png)

---

<div class="post-metadata">

**Author:** ![Leo838](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/leo838/32/12912_2.png) [@Leo838](https://community.homey.app/u/Leo838)\
**Post date:** [May 11, 2019, 3:17pm UTC](https://community.homey.app/t/mqtt-client-setup-with-sonoff-tasmota-rules/12802/12 "2019-05-11T15:17:50Z")

</div>

Here’s how I used this setup

> [@Howto: Extend the use of a Wemos D1 mini using rules & MQTT Client](https://community.homey.app/t/howto-extend-the-use-of-a-wemos-d1-mini-using-rules-mqtt-client/13016):
>
> Hello all, I didn’t come across this anywhere so I thought I’d share how I used a light dependent resistor ([https://en.wikipedia.org/wiki/Photoresistor](https://en.wikipedia.org/wiki/Photoresistor)) connected to a Wemos D1 mini flashed with Tasmota ([https://github.com/arendst/Sonoff-Tasmota/wiki/Wemos-D1-Mini](https://github.com/arendst/Sonoff-Tasmota/wiki/Wemos-D1-Mini)) to trigger my lights. This technique could be extended to alot of sensors connected to similar Tasmota devices. Currently in the Sonoff Homey app sensors are not directly supported so a suitable work around is required. My D1 has an…
