Cover completely reverse/invert

I linked to the docs… here’s it circled in the docs

here’s the script in that section of the docs, a bit lower

I have seen that. But sorry, I do really not get it… How does this “copy” the position of the actual slider position to my cover? Do I need to make a script to “get” the value from the slider?
Or do I need to “set” the position of the slider in the template cover?

:ok_man:

It doesn’t, it sets the slider on your cover entity that you’re trying to invert

position_template represents the slider position you see in the UI.

This works no different than value_template and the turn_on / turn_off services. They are all tied together.

So I must make a script to set the position on the realcover entity by using the call service in the reversed entitiy?

I just want very simply: to see the actual slider of the realcover in my reversedcover entity…

you don’t have to make a script. The set_cover_position field is a script field, you can put as many actions as you want in there… This is no different than every other action field in template entities. Again, you’ve done this MANY times. MANY MANY times. Your first post has this, the open_cover and close_cover fields.

look at this too

and this

and this

I really appreciate all you help (always). But you must know and understand this all coding is very hard for a non-coder…

This I have now and does control but does not show the correct position of the slider:

- platform: template
    covers:
      cover__r:
        friendly_name: "Cover R"
        #position_template: "{{ states('cover.realcover_r') }}"
        value_template: "{{is_state('cover.realcover_r', 'closed')}}"
        open_cover:
          service: cover.close_cover
          data: {}
          target:
            entity_id: cover.realcover_r
        close_cover:
          service: cover.open_cover
          data: {}
          target:
            entity_id: cover.realcover_r
        stop_cover:
          service: cover.stop_cover
          data: {}
          target:
            entity_id: cover.realcover_r
        set_cover_position:
          service: cover.set_cover_position
          data:
            position: "{{position}}"
            entity_id: cover.realcover_r
        icon_template: >-
          {% if is_state('cover.realcover_r', 'open') %}
            mdi:blinds-open
          {% else %}
            mdi:blinds
          {% endif %}

and thats the problem, you think it’s code but it’s not. So you never bother learning it, when it’s literally just an automation formatted differently.

That’s not fair…

I gave you 3 links, 2 which describe your cover position tempalte and the 3rd shows you an entire example.

dude, it’s totally fair. Just do a search for your name and template. There’s 90000000 template questions and you’ve never written any of the code itself. All I’m asking is that you try. That’s it. But in 20 posts on this thread, you posted 2 code chucks without any attempts at the cover_postion_template, and just 1 post ago you actually showed something that you tried. I’m 100% convinced you just argue until people show you the answer. I could be wrong :man_shrugging:, but at this point, I’m not going to spoon feed you, i’ll gladly help you fix your broken templates. So, again, all you need to do is post your attempted template cover and I’ll tell you what’s wrong.

This is correct but you aren’t inversing the value. The position variable inside the template is correct. But you need to perform math on it. cover positions range from zero to 100. So if you want to reverse it… you need to do what? Hint: it involves subtracting position from a number.

This is getting the state of the cover, not the position of the cover. How do you grab attributes from the cover?

If you 100% convinced you couldn’t be wrong. See I get logics :-).

I have now below. But that does not reflect the closed/opened states on the template cover (vs realcover)

- platform: template
    covers:
      cover_r:
        friendly_name: "Cover R Reversed"
        position_template: "{{ position('cover.realcover_r') }}"
        value_template: "{{is_state('cover.realcover_r', 'closed')}}"
        open_cover:
          service: cover.close_cover
          data: {}
          target:
            entity_id: cover.cover.realcover_r
        close_cover:
          service: cover.open_cover
          data: {}
          target:
            entity_id: cover.cover.realcover_r
        stop_cover:
          service: cover.stop_cover
          data: {}
          target:
            entity_id: cover.cover.realcover_r
        set_cover_position:
          service: cover.set_cover_position
          data:
            position: "{{100-position}}"
            entity_id: cover.cover.realcover_r
        icon_template: >-
          {% if is_state('cover.cover.realcover_r', 'open') %}
            mdi:blinds-open
          {% else %}
            mdi:blinds
          {% endif %}

That’s not how you get an attribute from an entity. What attribte are you trying to get? What is the name of the method that gets attributes from states?

Correct

the position

Ok, and what method gets attributes from states?

states() gets the state. What on this page gets the attributes?

Also remember you want to inverse this field too. So once you have the code to get the attribute, we’ll work on that next.

position_template: "{{ state_attr('cover.realcover_r'), 'position' }}"

?

Very close, your ) is in the wrong spot, it should look like this:

position_template: "{{ state_attr('cover.realcover_r', 'position') }}"

Now, you want to invert it, just like the set_cover_postion below

position_template: "{{ 100- state_attr('cover.realcover_r', 'position') }}"

or

position_template: "{{ 100- 'state_attr('cover.realcover_r', 'position')'' }}"

:see_no_evil:

Yep, now it should be working.


no