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 , 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')'' }}"
Yep, now it should be working.
no
I changed the open to close in the icon template since it displayed reversed. It think all works but the button of the reversed does not display correct:
So now realcover is closed (top arrows) but bottom shows only open arrow (should be close?).
the code:
- platform: template
covers:
cover_r_reversed:
friendly_name: "Cover R Reversed"
position_template: "{{ 100 - state_attr('cover.realcover_r', 'position') }}"
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: "{{100-position}}"
entity_id: cover.realcover_r
icon_template: >-
{% if is_state('cover.realcover_r', 'closed') %}
mdi:blinds-open
{% else %}
mdi:blinds
{% endif %}
open and closed are probably coming from your position template then, what is the level of the position slider?
what’s the position at? it should be zero
EDIT: You can try removing the value_template and seeing if the behavior changes. Keep the position_template
I tried that before you suggested. but it does not do anything. The buttons of the template cover do actuate the real cover now but do not do anything with the state of the template… Hope I’m clear.
If I remove the value template I get two arrow after reload and they stay, whether open or closed.
Yes, that makes sense because the cover has a position associated with it. What’s the state on the cover then? It should still have open/close but it’ll also have opening and closing.
Only open/closed, I do not see opening/closing
Ok, well, it’s at least working. Without having one of these myself, i can’t help any further.