home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.09k stars 31.1k forks source link

Template Cover - position_template doesn't work - grayed out #42954

Closed twproject closed 3 years ago

twproject commented 4 years ago

The problem

Hi all i create this cover template to control open (position 100) /close (position 21) /tilt (between position 0 and 20) of a blind with a shelly2.5 shutter but Position Slider is grayed out.

What I’m doing wrong?

Environment

Problem-relevant configuration.yaml

- platform: template
  covers:
    shelly25_blind02:
      device_class: blind
      friendly_name: "Blind Bedroom 02"
      #value_template: "{{ states('cover.shellyswitch25_68c63af9d218') }}"
      availability_template: "{{ states('cover.shellyswitch25_68c63af9d218') != 'unavailable' }}"   
      position_template: >-
        {% if state_attr('cover.shellyswitch25_68c63af9d218', 'current_position') | float <= 21 %}
           {{ 0|int  }}
        {% else %}
           {{ state_attr('cover.shellyswitch25_68c63af9d218', 'current_position') }}
        {% endif %}
      tilt_template: >-
        {% if state_attr('cover.shellyswitch25_68c63af9d218', 'current_position') | float <= 21 %}
           {{ 100 - (state_attr('cover.shellyswitch25_68c63af9d218', 'current_position') | float / 21 * 100)|int  }}
        {% else %}
           {{ state_attr('cover.shellyswitch25_68c63af9d218', 'current_position') }}
        {% endif %}
      optimistic: true
      open_cover:
        service: 'cover.set_cover_position'
        data:
         entity_id: cover.shellyswitch25_68c63af9d218
         position: 100
      close_cover:
        service: 'cover.set_cover_position'
        data:
         entity_id: cover.shellyswitch25_68c63af9d218
         position: 21         
      stop_cover:
        service: 'cover.stop_cover'
        data:
         entity_id: cover.shellyswitch25_68c63af9d218
      set_cover_tilt_position:
        service: cover.set_cover_position
        data:
         entity_id: cover.shellyswitch25_68c63af9d218
         position: >-
           {{ state_attr('cover.shelly25_blind02', 'current_tilt_position') | int }}

Traceback/Error logs

no errors

Additional information

template works image

also state is correct image

but ha position is grayed out image

I also try with a fake position with no luck

position_template: {{ 50 | int }}
javicalle commented 4 years ago

I would try to implement the set_cover_position in your template:

Could you test it?

probot-home-assistant[bot] commented 4 years ago

cover documentation cover source (message by IssueLinks)

probot-home-assistant[bot] commented 4 years ago

Hey there @home-assistant/core, mind taking a look at this issue as its been labeled with an integration (cover) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

twproject commented 4 years ago

yaaaa It

I would try to implement the set_cover_position in your template:

* https://www.home-assistant.io/integrations/cover.template/#set_cover_position

Could you test it?

yeaahhhh It works perfectly now

Probably the documentation need to be updated with this hint and an example

Thanks

javicalle commented 4 years ago

If it is already solved, could you close the ticket? Thank you.

twproject commented 4 years ago

If it is already solved, could you close the ticket? Thank you.

Yes it works, as I suggested probably the documentation need to be updated with this hint and an example

Thanks

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.