Tuya cloud curtain position status reversed

Just installed and calibrated wifi “Curtain Switch-N1” on tuya app, works and shows position correctly. But on home assistant it shows reversed position, if tuya app shows 100% open, then home assistant shows 0% closed. Is it possible to reverse position?
Diagnostic shows tuya “percent_control” 100%, home assistant “current_position” 0%:

"integration_manifest": {
    "domain": "tuya",
    "name": "Tuya",
    "documentation": "https://www.home-assistant.io/integrations/tuya",
    "requirements": [
"status": {
      "control": "stop",
      "percent_control": 100,
      "cur_calibration": "start",
      "control_back_mode": "forward",
      "tr_timecon": 13,
      "light_mode": "relay"
    "home_assistant": {
      "name": "Curtain switch",
      "name_by_user": "Miegamojo langas",
      "disabled": false,
      "disabled_by": null,
      "entities": [
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": "window",
          "original_device_class": "curtain",
          "icon": null,
          "original_icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "cover.miegamojo_langas_curtain",
            "state": "closed",
            "attributes": {
              "current_position": 0,
              "device_class": "window",
              "friendly_name": "Miegamojo langas",
              "supported_features": 15

You can make a template sensor to reverse it.
The issue have been up before, but it is not a bug.
It is a matter of perspective.

Are the blinds 100% open or 100% closed.

Well, I use it for window opening, so position and buttons does opposite what they should. I found, that I am not first with this problem and it is not fixed yet https://github.com/home-assistant/core/issues/63942.
Tried to do cover template, but can’t get it to work correctly.

  - platform: template
        device_class: window
        friendly_name: "Langas"
        position_template: "{{ states('sensor.room_window') }}"
          - condition: state
            entity_id: sensor.room_window
            state: "close"
          - service: cover.close_cover
              entity_id: cover.miegamojo_langas_curtain
          - condition: state
            entity_id: sensor.room_window
            state: "open"
          - service: cover.open_cover
              entity_id: cover.miegamojo_langas_curtain
          service: cover.stop_cover
            entity_id: cover.miegamojo_langas_curtain
          - service: cover.set_cover_position
              position: "{{((100 - position) / 100)|int }}"
              entity_id: cover.miegamojo_langas_curtain
        value_template: "{{is_state('sensor.room_window', 'open')}}"
        icon_template: >-
          {% if is_state('sensor.room_window', 'open') %}
          {% else %}
          {% endif %}

To swap the scale around on a percentage value you do 100-(current value*-1)

it wont work, because with “current value” = 100 you would get 200 and error:

Error executing script. Invalid data for call_service at pos 1: value must be at most 100 for dictionary value @ data['position']

Of course it is just 100-current value :slight_smile:

I have the same problem. Where can I instert the code, in Developer Tools\template?
When I put this code, I habe an error “TemplateSyntaxError: unexpected ‘end of print statement’” in this line
- service: cover.set_cover_position
position: “{{100-current_position*}}”

You sort of have to build a system on top of the original one.
This means you either need to make a change to your lovelace cards or make a template sensor that make the calculation and then just show that.
You also need to make scripts that inverse the numbers from the one you want to see and input to the ones the system actually understand.

0% in the app must translate to 0% in Home Assistant, whether you call it open IRL or not. It’s like having Celsius in the app but Farenheit in Home Assistant then needing to make a template yourself. Makes no sense. This can easily be corrected by adding a switch states button and doing it properly in the backend too instead of making users do the hard work clanging with templates.

Similar issue here… However I have few windows where I have the motor from right on the others I have it from left. So few of them works as expected others not…
On the other side with the localtuya integration always shows the real status as it is setup in the motor itself. Unfotunately localtuya doesn’t work with all my devices (some shutters are in other network which is not accessible from HA) so I have to use both integrations…