Opposite of real status for blind and shutter (Tuya Integration)

Hi,

I recently joined HASS and I am using Home Assistant to integrate my tuya devices to connect to Apple HomeKit. All of my switches, Acs, and curtains are working fine except for 1 blind and 1 shutter.
The issue is with the real status vs the status shown on HASS and HomeKit. When these two devices are actually open, HASS and HomeKit read closed. And when they are actually closed, reads open. And this is confusing my Apple HomePod as when I say “close” it goes open, and when I say “open” it goes closed.
I tried googling some templates here and there and they did not work, probably I am doing something wrong
The name of the two devices as defined in HASS as following:

  • Master Shutter Curtain
    -Dinning Blind Curtain

Any response would be highly appreciated. Thanks

Same for me more than two years later. No solution yet?

The shutter simply cannot be used with HA as it tries to open if it is already open.

You can’t invert them in place, but you can create a template cover that inverts the behavior and hide the original.

Thanks for the hint, @Edwin_D.

Allthough it’s just a workaround to fix a bug, I think I have to give it a try.

But I have now idea, how to proceed in detail in this specific case.

I allready added a few special lines to the config.yaml, but only via copy & paste from a documentaion.

Can you help how to this in detail?

If the cover supports percentage open, the example below should come a long way, maybe you also need to add actions for the buttons:

- platform: template
  covers:
    inverted_cover:
      friendly_name: Inverted cover
      position_template: >
        {{ 100 - (state_attr('cover.my_cover', 'current_position') | int(0)) }}
      set_cover_position:
        service: cover.set_cover_position
        data_template:
          entity_id: cover.my_cover
          position: >
            {{ 100 - position }}

Thanks again for your support!

It does support percentage but I prefer only to switch the wrong states open and closed.

And within the code I have something to replace with my real data, right?

The open and closed states are bound to specific percentages. 100% is 100% open. So trying to ignore that would run into problems one way or another. You can invert the open and close commands by setting actions for those commands, but Home Assistant will keep getting it wrong when 0 or 100 procent do not match up with what home assistant expects.

It just hit me: There is one way that you might be able to reverse behavior in the user interface: an awning has reversed controls for open and closed compared to a blind. So if you change the type in home assistant between the two, the commands will probably inverse too. I do not know about the percentages though.

I really dislike that Home assistant has that different behaviour for awning (same as I dislike that 100% is open for a blind), but it just might help you. Or it could be HA incorrectly identified your device as an awning, and that is why you have this problem.

How to change the device type? My initial idea was to switch it from curtain (what is wrong) to a roller shutter. But I do not know how to change the device type.

It is the “Show as” dropdown in the settings ui of the cover entity.

Okay, I already tried it. But it didn’t work.

From the description “Show as” I understand it does not have any functioal value - only a different lable and icon.

This is how it looks now:

image

“Markise” is german for awning.

And this is the problem:
image

The only available function is to open, but as it is already open, nothing happens. It cannot be used by HA at all.

Instead I should be able to change the entity-ID from cover to shutter or awning or something.

One final (I hope :wink: ) question, if I may, @Edwin_D .

I used the proposed code and adapted it to my setup (changed the device name).

So it reads like this:

cover:
- platform: template
  covers:
    inverted_cover:
      friendly_name: Inverted cover
      position_template: >
        {{ 100 - (state_attr('cover.rollladen_terrasse_vorhang', 'current_position') | int(0)) }}
      set_cover_position:
        service: cover.set_cover_position
        data_template:
          entity_id: cover.rollladen_terrasse_vorhang
          position: >
            {{ 100 - position }}

But there seems to be something wrong with a not unique ID.

Can you help me?

If you want a unique_id, then by all means add it, you can also add the following, then it should be complete:

      unique_id: cover.inverted_cover
      device_class: blind
      availability_template: "{{ has_value('cover.rollladen_terrasse_vorhang') }}"
      open_cover:
        action: cover.close_cover
        target:
          entity_id: cover.rollladen_terrasse_vorhang
        data: {}
      close_cover:
         action: cover.open_cover
        target:
          entity_id: cover.rollladen_terrasse_vorhang
        data: {}
      stop_cover:
        action: cover.stop_cover
        target:
          entity_id: cover.rollladen_terrasse_vorhang
        data: {}

I am not keen on a unique ID but I get the error message, it cannot be controlled without …

But now something is wrong with the indentation …

cover:
- platform: template
  covers:
    inverted_cover:
      friendly_name: Inverted cover
      position_template: >
        {{ 100 - (state_attr('cover.rollladen_terrasse_vorhang', 'current_position') | int(0)) }}
      set_cover_position:
        service: cover.set_cover_position
        data_template:
          entity_id: cover.rollladen_terrasse_vorhang
          position: >
            {{ 100 - position }}
      unique_id: cover.inverted_cover
      device_class: blind
      availability_template: "{{ has_value('cover.rollladen_terrasse_vorhang') }}"
      open_cover:
        action: cover.close_cover
        target:
          entity_id: cover.rollladen_terrasse_vorhang
        data: {}
      close_cover:
         action: cover.open_cover
        target:
          entity_id: cover.rollladen_terrasse_vorhang
        data: {}
      stop_cover:
        action: cover.stop_cover
        target:
          entity_id: cover.rollladen_terrasse_vorhang
        data: {}
```

Ah, it looks like, I could fix it on my own.

1 Like