Tuya Door Sensor as sensor not switch

Hi there,
I have here a tuya door sensor and added this to my home assistant.
But now I have the issue, that the sensor is saved as a switch, so I cannot see if the door is closed or opend.
Is there a workaround to change the setting, so I can see the current state of the door with this sensor?

Regards
Timo

I found this one, but I dont know on which point I have to add “garage_sensor”:

binary_sensor:
  - platform: template
    sensors:
      movement:
        device_class: motion
        value_template: "{{ is_state('switch.movement', 'on') }}"
      door:
        device_class: opening
        value_template: "{{ is_state('switch.door', 'on') }}"

How did you added it? If is a door sensor should be a binary sensor.
You can always change the device_class to door in customization.

1 Like

I added it with the Tuya integration.
How the code of this change has to look in my config?


found this, but I cannot change it to binary_sensor :frowning:

Being a switch i dont think you can. You should use the template binary sensor that you posted. What tuya device is it?

Okay, but I dont know how I can use that template.
Its the WiFi Door sensor, https://de.aliexpress.com/item/33047480276.html

Has anybody an idea?
I dont get it right now…

What is the state of “switch.garagentor_sensor” when the door is open and closed?

How can I check this?
Currently its shown as a Switch with on/off toggle…

Under States in Developer Tools

If you look at the state column you would see the change when the sensor is open and closed.

The State only change if I turn on or off the toggle in home assistant.

It doesnt change the State in home assistant if I put the two pieces together (in the tuya app it shows the correct State, so the device works…)

How did you add it to HA?, as sensors isn’t currently supported in the integration.

There is currently support for the following device types within Home Assistant:

* **Climate**  - The platform supports the air conditioner and heater.
* **Cover**  - The platform supports curtains.
* **Fan**  - The platform supports most kinds of Tuya fans.
* **Light**  - The platform supports most kinds of Tuya light.
* **Scene**  - The device state in frontend panel will not change immediately after you activate a scene.
* **Switch**  - The platform supports switch and socket.

I added it over the tuya integration.

Exists there an other way?

Yes, there is https://github.com/rospogrigio/localtuya, but still no sensor support as of yet, I use this instead of the built-in integration as the response time for switch state changes is instant.

As a work around, I have a “Smart” automation setup within the native app for my sensor to trigger a switch which is integrated into HA and use the state change of the switch for my automations.

Can you Show your Code?

Sure, but won’t be till late tonight or tomorrow, currently on the road.

1 Like

What code do you need exactly? all I am doing is triggering automations base on the state of the switch in HA.