# Tasmota flashed Window Sensor ON/OFF to true/false? MQTT

**URL:** <https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761>\
**Category:** Questions & Help\
**Created:** [May 24, 2021, 6:38pm UTC](https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761 "2021-05-24T18:38:56Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Metatron](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/metatron/32/40136_2.png) [@Metatron](https://community.homey.app/u/Metatron)\
**Post date:** [May 24, 2021, 6:38pm UTC](https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761/1 "2021-05-24T18:38:56Z")

</div>

Hello,  
I flashed a TUYA D06 windows sensor with tasmota.  
It is working fine, but it sends on/off (Power) depending on the window state.

Which is the best way, to integrate it into Homey? I believe I should map it somehow to true/false in MQTT Hub, but I can not figure out, how to do it.  
Any help would be highly appreciated!

Regards, Metratron

---

<div class="post-metadata">

**Author:** ![Joka](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Joka](https://community.homey.app/u/Joka)\
**Post date:** [May 25, 2021, 7:02am UTC](https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761/2 "2021-05-25T07:02:55Z")

</div>

Did you try Tasmota MQTT from @pavlo?

---

<div class="post-metadata">

**Author:** ![Metatron](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/metatron/32/40136_2.png) [@Metatron](https://community.homey.app/u/Metatron)\
**Post date:** [May 25, 2021, 7:51am UTC](https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761/3 "2021-05-25T07:51:09Z")

</div>

To be honest, no, and I won’t.  
It never worked for me, not for a single switch or energy monitoring device, of which I have plenty. They have never been discovered. I gave up on this.  
Anyway, i need to translate an MQTT Power status to a contact alert. I doubt, that this can be done with it.  
Regards, Metatron.

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [May 25, 2021, 8:01am UTC](https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761/4 "2021-05-25T08:01:44Z")

</div>

Why translate, Homey is capable to react on all status changes.Let your signals change the status of a virtual sensor.

---

<div class="post-metadata">

**Author:** ![Metatron](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/metatron/32/40136_2.png) [@Metatron](https://community.homey.app/u/Metatron)\
**Post date:** [May 25, 2021, 8:14am UTC](https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761/5 "2021-05-25T08:14:51Z")

</div>

Yes, this is, what I am trying to do.  
So I try to define a flow to set the virtual device “contact”. Currently, it is not clear to me, how to use the trigger “MQTT Client  
Trigger when a message is received on”  
I can not find any documentation/example for this?

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 25, 2021, 5:25pm UTC](https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761/6 "2021-05-25T17:25:20Z")

</div>

The MQTT Device of the mqtt Hub app is exactly build for this purpose.

---

<div class="post-metadata">

**Author:** ![Metatron](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/metatron/32/40136_2.png) [@Metatron](https://community.homey.app/u/Metatron)\
**Post date:** [May 25, 2021, 5:30pm UTC](https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761/7 "2021-05-25T17:30:31Z")

</div>

Thanks, that is what I thought. Where can I find examples or a documentation, how to set a MQTT Device on true or false based on on/off, and furthermore, same device, the battery level?

In the meantime, I tried to set up a virtual device, trying to set it with flows. However, I am not able to write any values to this device, at least not my way:

 ![WhatsApp Image 2021-05-25 at 19.20.06](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/1/6160f6fe79c4c6d179d4cb3af20f0957708ce321.jpeg)  
 ![WhatsApp Image 2021-05-25 at 19.22.11](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/a/8a4ec6341e9e25928881c8fb37c737e1773dfe1b.jpeg)  
 ![WhatsApp Image 2021-05-25 at 19.23.57](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/3/d36627aa13274fc5371ff35fe487f31b883935a1.jpeg)

Sorry for being such a pain!  
Regards, Metatron.

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 25, 2021, 5:43pm UTC](https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761/8 "2021-05-25T17:43:38Z")

</div>

Just create an MQTT Device and add a ‘Turned On/Off’ capability pointing to the correct state & command topics of your tasmota device.

Then you have two options to solve your problem:

1. Either configure the input and output templates like this:  
input: value == ‘on’  
output: value ? ‘on’ : ‘off’  

2. Or leave the input & output templates empty. After creating the device, go to the advanced device config and select ‘on/off’ for the ‘on/off values’ setting (true/false in screenshot), this will automatically convert boolean values to ‘on’ & ‘off’ in both directions.  

Marh.js expression examples can be found here:  
[https://mathjs.org/](https://mathjs.org/)

You can use ‘path.to.property’ I stead of ‘value’ within the templates, if the input is a JSON formatted message.

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 25, 2021, 5:54pm UTC](https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761/9 "2021-05-25T17:54:34Z")

</div>

> [@Metatron](#):
>
> same device, the battery level?

Just add another capability ‘measure\_battery’?  
By default the value will be translated from [0…100] (external; the rest of the world) to [0…1] (homey). This can also be configured from the advanced device config if needed; the ‘percentage scaling’ option. And again, a simple calculation can be used to transform values if needed (e.g. value / 255).

Eventually I’ll probably remove these two advanced device config options (for new devices). They’re kind of hidden and deprecated since the introduction of the input & output templates per capability. It can also result in unexpected behavior (e.g. percentage values being devided by 100). I thought about inserting the demo templates as default value, when selecting boolean or percentage capabilities in a future release.

---

<div class="post-metadata">

**Author:** ![Metatron](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/metatron/32/40136_2.png) [@Metatron](https://community.homey.app/u/Metatron)\
**Post date:** [May 25, 2021, 7:15pm UTC](https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761/10 "2021-05-25T19:15:40Z")

</div>

Seriously, you saved my day, again! It is working on the first try, even as contact alarm, including battery.  
Thank you very much!!

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [May 25, 2021, 7:29pm UTC](https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761/11 "2021-05-25T19:29:46Z")

</div>

💪

Now you can write the documentation and tutorial 😉

---

<div class="post-metadata">

**Author:** ![Metatron](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/metatron/32/40136_2.png) [@Metatron](https://community.homey.app/u/Metatron)\
**Post date:** [May 27, 2021, 6:31am UTC](https://community.homey.app/t/tasmota-flashed-window-sensor-on-off-to-true-false-mqtt/47761/12 "2021-05-27T06:31:57Z")

</div>

Hi Harrie,

good point. Assuming, I wanted to do it, at least as a working example. Where would I document it? In the forum? There it is (see above). How about a Homey wiki? I am used to work with wikis, and it will give more overview then a forum, only.

Another suggestion: It would be nice to be able to change the MQTT device icon after it has been set up. Would that be possible. please?

Regards, Metatron.
