How to convert a switch entity to a cover entity - tuya devices?

Hi there!
At my parents house they installed Tuya switches (MOES WiFi + RF curtain module - you can find it by this name on AliExpress) that manage both via Tuya App and via RF remote control of the shutters.

In fact you can raise, lower and stop the shutter via remote control or via app in the same way.

The original app looks like this:

I’m then doing an integration job inside one of their Home Assistant instances.

The official Tuya integration imports the following objects as switches and NOT as covers, hence I found this guide:

I based my code on the “garage door” example in the linked guide and found another example to compare with on the official forum. So I generated this code:

 - platform: template
        device_class: shutter
        friendly_name: "Finestra sala grande"
          service: switch.turn_on
            entity_id: switch.finestra
          service: switch.turn_off
            entity_id: switch.finestra
          service: switch.turn_on
            entity_id: switch.finestra
        icon_template: >-
          {% if is_state('switch.finestra', 'on') %}
          {% else %}
          {% endif %}

I thought it was not necessary to create an on/off state sensor (as indicated in the offical guide) since the switch itself already has this state.

I would then manage the graphic part with the HACS component “Cover position preset row”.

At the moment I am writing this, the shutter is completely lowered. This is what I see via gui (The behavior of the keys is probably modifiable, but I’m sticking with the default for now - unless the keys are actually calling incorrect services?):


When I press the arrow that goes down the shutter goes up. If I press the stop button, however, it does not stop. In fact, it does nothing and continues to go up. By trial and error I also tried to reverse the behavior, so open_cover becomes switch.turn_off but the behavior does not change.

Basically if I take the simple switch and turn it on (from off to on) the shutter goes up but I have no way to stop it EVEN turning off the switch, which in this case would make the shutter go down. So I have to intervene with the Tuya app and press the pause button.

I add that the default state of the switches is “off”.

So, at this point… Can someone help me to figure out this?

Thanks! :smile:

What you describe seems in line with the app UI.
The important part you’re missing is the equivalent of the “Pause” button.

Yes basically. I can’t figure out how to pause the rise or fall of the shutter.
But if there is a way to do it in the Tuya app… There will be a way to do it in Home Assistant as well. I guess.