t0bst4r / matterbridge-home-assistant

Apache License 2.0
79 stars 9 forks source link

covers are appeared inverted #234

Closed tammeryousef1006 closed 1 month ago

tammeryousef1006 commented 1 month ago

What happened?

my cover already fully opened and appears fully close at matter , if i set position to 80% then at matter appears opened to 20% , its working opposite way

Your configuration

official ha add on

Relevant log output

no log needed

Version

latest

tammeryousef1006 commented 1 month ago

Open close stop working correctly, but full open in real shows closed , and full closed in real shows opened , also position are working opposite way , going to pos 80 makes cover goes to 20 , going to pos 10 makes cover to go to 90 , i hope i could explain it well

t0bst4r commented 1 month ago

Yes, I understood that. Would be nice to know if that’s a bug for all or specific for your device.

I’m not be at home for three days. I’ll take care on the weekend

tammeryousef1006 commented 1 month ago

Im outside also can't check rest of covers , will see once im home

On Mon, 29 Jul 2024, 7:35 pm Tobias Glatthar, @.***> wrote:

Yes, I understood that. Would be nice to know if that’s a bug for all or specific for your device.

I’m not be at home for three days. I’ll take care on the weekend

— Reply to this email directly, view it on GitHub https://github.com/t0bst4r/matterbridge-home-assistant/issues/234#issuecomment-2256396727, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO3B3TDNWILAA47E6JIQSJDZOZVLVAVCNFSM6AAAAABLTTDFECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJWGM4TMNZSG4 . You are receiving this because you authored the thread.Message ID: @.***>

baeksj commented 1 month ago

Here, both of my blinds are also displayed in an inverted state.

genehand commented 1 month ago

I have the.. opposite problem. :) My positions are reported correctly but asking alexa to open the blinds will close them.

Zemismart ZM25RZ01-30 rollershade through zigbee2mqtt, motor direction in normal mode (vs reversed).

tammeryousef1006 commented 1 month ago

its the same problem not different , try for example to open to position 20 and look what happen in real , for me I use shelly cover and its easier to track this

genehand commented 1 month ago

Yes, same problem in reverse.

"Alexa, set the office blinds to 20 percent" -> blinds go to 20%.

"Alexa, open the office blinds" -> blinds close (0%)

t0bst4r commented 1 month ago

@genehand what do you mean with 20%.

If Alexa seems to assume that 0% is „open“. Then 20% should mean „from the top“ and not „from the bottom“.

what are you experiencing exactly, if it’s not the same as for the others?

i‘d do a fix on the weekend inverting it as a first try.

tammeryousef1006 commented 1 month ago

20% partially open , 100% is full open 0% is full closed

t0bst4r commented 1 month ago

Could you test in the mean time what happens when setting the position to 20 via home assistant. Currently I just forward the percentage from matter to HA without any change. So I assume 20% (open) for Alexa means 80% in HA ?

tammeryousef1006 commented 1 month ago

for me i test with ha and smartthings and both works same way as offical shelly app , 0 is closed and 100 is open

tammeryousef1006 commented 1 month ago

any percent between 0 - 100 is mean partially opened

tammeryousef1006 commented 1 month ago

the issue with @genehand is abit different , he claims that he can sit the desired position correctly , but for me its sit opposite percent to 100% , if i go 10% the cover goes 90% , if i set 20% the cover goes 80% , and for sure the only correct percent is 50% lol

genehand commented 1 month ago

If Alexa seems to assume that 0% is „open“. Then 20% should mean „from the top“ and not „from the bottom“.

The percentages with covers seemed weird to me at first, I think it's based on the amount of light let through. So 0% is closed, 20% is from the bottom, and 100% is fully open.

what are you experiencing exactly, if it’s not the same as for the others?

The position attribute is working correctly for me and showing the same value in zigbee2mqtt, home assistant, and the alexa app. "Set the blinds to 20%" works as expected with the blinds open 20% from the bottom, still covering 80% of the window. "Set the blinds to 100%" works correctly and opens the blinds. The only weird part is that using "Open the blinds" closes them, setting them to 0%. This was working correctly before with matterbridge-zigbee2mqtt, I'd just like to consolidate plugins and have everything go through Home Assistant.

@tammeryousef1006 I was wondering if maybe you have the invert_directions setting enabled with shelly and that could be giving us opposite results. But then I realized I have 2 of the same motor, 1 normal motor direction and the other reversed. And I'm getting the same behavior from both so 🤷‍♂️ 😄

tammeryousef1006 commented 1 month ago

thats really confusing , i think matter should follow the entity of ha despite of any other settings , for me the basic commands like (open , close , stop) works perfectly but inverted closed opened , and going to position obvious for me going opposite percentage , i think i should integrate the rest covers and see if all behave the same

t0bst4r commented 1 month ago

Matter.js specification: Open: 0% Closed: 100%

Home Assistant (HA Position Template): Closed: 0 Open: 100

I will definetly reverse it.

In the mean time I got a mocked cover entity working with a input_number and a template-cover entity. Anyway Alexas Translations seem to be wrong for covers. It says (Translated from German Alexa app) "Degree of opening". But when I say "close the cover" it puts it to 100% (matter => closed). So thats wrong, but it should then be the "degree of closing" instead.

Is that the problem you are facing @genehand ? To be honest: i think its a bug of alexa or at least a mistake in the label of the property in Alexa.

t0bst4r commented 1 month ago

Just merged it to main, and triggered the release. Should be fixed with 2.3.2. If you do not agree feel free to reopen this issue.

tammeryousef1006 commented 1 month ago

for me latest fixed 2.3.2 worked for me thanks

genehand commented 1 month ago

Hmm yeah now I'm in the inverted scenario where open/close commands work but the percentages go the other way. Makes sense since home assistant and matter don't line up there. I'll try using a template cover entity to flip it.

My alexa app also says "Opening". I'd guess that's based on the same "100% = open" logic that doesn't match the matter spec now. Thanks for getting this going!

genehand commented 1 month ago

Ok that mostly works, in case anyone's interested:

cover:
  - platform: template
    covers:
      office_blinds_matter:
        device_class: shade
        friendly_name: Office blinds
        unique_id: office_blinds_matter
        availability_template: "{{ has_value('cover.office_blinds') }}"
        value_template: "{{ states('cover.office_blinds') }}"
        position_template: >
          {% set current_position = state_attr('cover.office_blinds', 'current_position') %}
          {% if current_position == 100 or current_position == 0 %}
            {{ current_position }}
          {% else %}
            {{ 100 - current_position }}
          {% endif %}
        set_cover_position:
          service: cover.set_cover_position
          target:
            entity_id: cover.office_blinds
          data:
            position: >
              {% if position == 100 or position == 0 %}
                {{ position }}
              {% else %}
                {{ 100 - position }}
              {% endif %}
        stop_cover:
          service: cover.stop_cover
          target:
            entity_id: cover.office_blinds

The one weird workaround is flipping the full open/close positions between 0 and 100. This makes it possible for "open the blinds" to work, but now "set the blinds to 99%" will open them almost all the way while "set the blinds to 100%" will close them. I'd never use the 100% command so it works for me 😄

cameronkelley commented 1 month ago

Mine is also incorrectly inverted now in Alexa with >=2.3.2 While the workaround from @genehand is usable, it's not ideal. @t0bst4r would it be possible to add an option to the config.json to be able to specify whether covers should be inverted or not? Totally fine with me if it defaults to true, but it would be great to have the choice to set it false to keep the previous functionality.

t0bst4r commented 1 month ago

Yes, I agree, I could do it but shouldn’t we get it working correctly anyway?

Could it be related to the type / device class of the covers? Or is there any attribute at the entity to indicate that inversion is needed? At the moment everything is mapped to the same device type in matter. So no difference for garage door or window cover etc.

t0bst4r commented 1 month ago

What I was thinking about is: what if home assistant inverts the visualizations of specific device classes? Meaning that it shows as 90% but the value is actually 10% ?

tammeryousef1006 commented 1 month ago

@t0bst4r i think you can add it to the config of home assistant inside matterbridge GUI incase others want to reverse or keep

tammeryousef1006 commented 1 month ago

here

genehand commented 1 month ago

@t0bst4r i think you can add it to the config of home assistant inside matterbridge GUI incase others want to reverse or keep

Unfortunately those settings are setup in the main matterbridge project and afaik not easy to extend through the plugins independently.

genehand commented 1 month ago

Yes, I agree, I could do it but shouldn’t we get it working correctly anyway?

Could it be related to the type / device class of the covers? Or is there any attribute at the entity to indicate that inversion is needed? At the moment everything is mapped to the same device type in matter. So no difference for garage door or window cover etc.

Ok I just put the zigbee2mqtt plugin back in the mix for one of the blinds to compare. Turns out open/close works but the percentages are inverted there too 😉 Looks like we stumbled into a rats nest: https://community.home-assistant.io/t/cover-entities-that-are-0-open-and-100-closed/581979

My only other cover entity is a garage door controlled with ratgdo. Looks like the home assistant/esphome convention is that 100% = open while matter is using 100% = closed.

Oh hold up, zigbee2mqtt has an option for Invert Cover:

Inverts the cover position, false: open=100,close=0, true: open=0,close=100 (default false).

I'll try that for my case but don't know if we'll be able to work out a general autodetection for it.

cameronkelley commented 1 month ago

What I was thinking about is: what if home assistant inverts the visualizations of specific device classes? Meaning that it shows as 90% but the value is actually 10% ?

Definitely a possibility. My use case is a garage door opener using ESPHome on a ratgdo but unfortunately I don't have any other cover devices to test such as blinds.

When I open my garage to 10% the state in home assistant shows "open" and here are the attributes from the dev tools states page.

current_position: 10
device_class: garage
friendly_name: Garage Door
supported_features: 15

Probably not relevant, but do you know what supported_features means?

genehand commented 1 month ago

I encourage everyone here to vote/comment on https://community.home-assistant.io/t/configurable-cover-entities-to-invert-close-open/409595 😄

cameronkelley commented 1 month ago

I encourage everyone here to vote/comment on https://community.home-assistant.io/t/configurable-cover-entities-to-invert-close-open/409595 😄

Although I completely agree that's something that should be configurable, it's only partially applicable to this issue. I feel like the bigger issue here is the inversion of cover_position Both you and I are using a ratgdo and I can't speak for you, but for me personally 10% should mean 10% open, not 10% closed. Bare minimum making the inversion configurable in matterbridge-home-assistant will work great, but maybe there is a real solution somewhere in the matter implementation. Wish I knew enough about it to dig into it.

genehand commented 1 month ago

Both you and I are using a ratgdo and I can't speak for you, but for me personally 10% should mean 10% open, not 10% closed.

Agreed, the issue is that the matter spec says 10% means 10% closed and that's what we're integrating with here. So even if you invert the position like I've tried various ways, you then need special handling for open & close.

t0bst4r commented 1 month ago

Okay, for now I'd go with a config approach:

grafik

invertPercentage defaults to true, swapOpenAndClosePercentage defaults to false - this is the current (matter compliant) behaviour.

This configuration will be configurable for the whole domain or overridable per entity - you can choose where to configure it. I just don't know how I'd add this config to the HA addon config...

cameronkelley commented 1 month ago

Thanks so much! ~I set both to false and it's operating correctly in Alexa now~

Edit: Only invertPercentage needs to be set to false. swapOpenAndClosePercentage needs to be set to true (default)

t0bst4r commented 1 month ago

I would be interested if it’s then working as expected for @genehand 😂

Could somebody already test it with the HA Addon? I‘ve added the override object as a json string to the config. Unfortunately there is no object or json type for Addon configs.

cameronkelley commented 1 month ago

I tried the Addon on my test server and it works correctly, however I realized I made a mistake before on my main config.

invertPercentage needs to be set to false swapOpenAndClosePercentage needs to be set to true (default)

It's actually a good thing I tested this. I forgot I had an alexa routine for "close garage door" that set it to 0% so even though it closed, it was overriding the normal close command and setting the percentage which "worked"

genehand commented 1 month ago

All good here now too with the same invert: false and swap: true 😎