Unknown status of tasmota door sensor eventhough they should work smooth

Tags: #<Tag:0x00007f739b15dc48>

Hi,

I am new to home assistant and just in the middle of adding my devices to home assistant.
I got some tuya door sensors. Unfortunately they did not integrated into home assistant with the tuya integraton, which was not a problem for me since I wanted to flash them with tasmota anyway.

So I flashed these door sensors with tasmota 8.3.1. as described on blakadders page (which worked smooth): https://templates.blakadder.com/TY01.html

Now I was able to add them via mqtt autodetection into home assistant, which worked. On the device tasmota page (through ip adress) they work great, in Tasmoadmin they work fine as well and I can see state changes (on/off), too, but when I try to visualize them in lovelace, they state is shown as “not available”. Also under entities their state is shown as “not available”.
I know that these battery powered devices go into deep sleep, but even when they are in rapid change of state (me changing them manually in person every 2 seconds), home assistant will not recognize these changes. When they get into deep sleep, tasmoadmin will show there last state but in red.

I tried to modify them in my configuration.yaml (manual add them) but it did not worked!. I attached the code.

  - platform: mqtt
    name: Tuer1 status
    device_class: door
    state_topic: tele/tasmota/HASS_STATE
    availability_topic: tele/tasmota/LWT
    payload_available: Online
    payload_not_available: Offline
    json_attributes_topic: tele/tasmota/HASS_STATE
    unit_of_measurement: ""
    value_template: '{{value_json[''RSSI'']}}'
    icon: 'mdi:information-outline'
    unique_id: CA7E19_status```

First I thought it has something to do with the device_class, which I tried to change to “door” but confugartion check declined this code saying:

" Invalid config for [sensor.mqtt]: value is not allowed for dictionary value @ data['device_class']. Got 'door'. (See ?, line ?). "

How and where can I permanently change the status attributs if not in my configuration.yaml?

Now I am somewhere in a dead-end because I am missing some expierence and do not know where to search/what to do next.

I enclosed a screenshot of my lovelace card, the entity and Tasmoadmin.

Thanks for your help!

Bildschirmfoto 2020-07-28 um 14.44.38

Configure it manually in the binary_sensor section, not the sensor section and device_class: door should work.

1 Like

Thanks @petro ! That almost worked.
two more questions:

1.) When the state changes, it only recognizes the “close” state, not “open”. Do I need to classify that, too and if so, how?
2.) If the device goes to deep sleep, it shows the state “unknown” but instead I would like to show me the last known state. What do I have to do?

I can’t answer those questions as I don’t have this type of device.

Stop the device sending LWT messages and remove the retained LWT messages from your mqtt broker.

Set the Tasmota state messages to retained (if not already).
Also remove these from your config:

    availability_topic: tele/tasmota/LWT
    payload_available: Online
    payload_not_available: Offline

Could you show your config for the binary sensor?

Hi @tom_l,

Stop the device sending LWT messages

I am not sure if I got that right, but I typed “cmd/tasmota/LWT off” into the consol of the tasmota device (Tuer1) and got these lines:

09:38:24 CMD: stat/tasmota/LWT off
09:38:24 SRC: WebConsole from 192.168.2.203
09:38:24 CMD: Group 0, Index 1, Command "LWT", Data "off"

I also tried to follow The Hook up´s video https://www.youtube.com/watch?v=31IyfM1gygo and config the retained message by setting the following lines inside of the tasmota device consol

switchretain on
switchtopic tuer1

remove the retained LWT messages from your mqtt broker.

I did not managed to do that. How do I do that?

Also remove these from your config:

I deleted the 3 lines from my config

Here is my code for now:

binary_sensor:
  - platform: mqtt
    name: Tuer1 status
    device_class: door
    state_topic: tele/tasmota/tuer1
    json_attributes_topic: tele/tasmota/tuer1
    value_template: '{{value_json[''RSSI'']}}'
    unique_id: CA7E19_status

previously I had “state:topic: tele/tasmota/Hass_state” and “json_attributes_topic: tele/tasmota/hass_state” as shown above, which I thought might help if I switch it to “…/tuer1” (device name) because of the “switchtopic tuer1”-change I made bc of the video but that seems not helped.

Sorry for my inability to implement everything right away. Tried my best for the last 60 minutes.

The easiest way would be by using http://mqtt-explorer.com/

1 Like

I managed to do that but now it shows the state “closed” all the time, while in TasmoAdmin it still works great. Any ideas what to do next from here, @tom_l?

Is the state changing when you observe it in the mqtt broker with mqtt explorer?

You still have this in your config too, remove it.

value_template: '{{value_json[''RSSI'']}}'
1 Like

After beginning from scratch, I finally made it. I startet by autodetect the device with the mqtt addon and saw, that Home Assistant received two messages under the topic “state/tasmota/power”, then I de-implemented it as @tom_l said and added it in my configuration.yaml. By adding “device_class: door” it now works smooth.
Thanks again @tom_l

My code looks like this now:

binary_sensor:
  - platform: mqtt
    name: Tuer1 status
    device_class: door
    state_topic: stat/tuer1/POWER```
1 Like