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

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

Did you try Tasmota MQTT from @pavlo?

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.

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

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?

1 Like

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

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:

Sorry for being such a pain!
Regards, Metatron.

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:

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

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.

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


Now you can write the documentation and tutorial :wink:

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.