jimz011 / homekit-infused

Homekit Infused 5 2023
https://jimz011.github.io/homekit-infused/
Other
878 stars 137 forks source link

[Bug] Button card "type: cover": Erratic initial position and label when using "cover_control: tilt_position" #168

Open veitw opened 2 years ago

veitw commented 2 years ago

Hi,

I am on release 2022.4.1 and tried to add my blinds with tilt control to HKI, example:

        - title: Fenster
          columns: 4
          entities:
            - name: Jalousie rechts
              entity: cover.schlafzimmer_beschattung_rechts
              type: cover
              cover_control: tilt_position
              label: '[[[ return entity.attributes.current_tilt_position + "%" ]]]'

Unfortunately this is buggy both for the position fed to the cover popup card, and also for the label on the button card:

  1. When tapping on the button card, the popup opens. But the initial position of the slider is not read from the current_tilt_position attribute, but from current_position instead. So with the blinds closed, when opening the popup, it always shows 0 instead of the current tilt position. When I run the blinds to 50% open, the popup slider shows 50 instead of the current tilt position. Tilt position control using the slider however works fine, it is just the initial value when opening the card that is wrong.

  2. The label on the button card shows the value of the current_position attribute, too, though I was able to work around this issue using the custom label template in my config above, IMO this should show the value of current_tilt_position by default if the button card is set to cover_control: tilt_position.

Thanks for this great piece of software!

Best regards, // Veit

jimz011 commented 2 years ago

Thanks for the feedback, I will look into it. But since I do not have covers (and no one really tell me about this) it is difficult to test.

I will keep this in mind though

veitw commented 2 years ago

@jimz011 : Can I help with testing?

Alternatively, you could create a virtual cover using cover.template that e.g. simply runs actions that send notifications or emit events or log entries. If you enable optimistic mode for both position and tilt position, you do not have to take care for a feedback channel, HA will simply assume then that the position/tilt position you set has been successfully set and transfer this value to current_cover_position and current_cover_tilt_position:

  - platform: template
    covers:
      my_virtual_cover:
        friendly_name: "my virtual cover"
        device_class: blind
        optimistic: true
        tilt_optimistic: true
        open_cover:
          service: ...
          data: ...
        close_cover:
          service: ...
          data: ...
        stop_cover:
          service: ...
          data: ...
        set_cover_position:
          service: ...
          data:
            ...
            position: "{{position}}"
        set_cover_tilt_position:
          service: ...
          data:
            ...
            tilt: "{{tilt}}"
jimz011 commented 2 years ago

My sincere apologies for this extremely late reply. I have been really busy lately (and still am), but that doesn't mean I don't want to invest time anymore in this project. So the answer is yes, if you can help with anything covers related I'd be glad to accept it.

In March I will move out to a new home and I will buy actual covers, so whatever happens, this will be addressed sooner or later.