I want to get rid of the inverse behavior (I know there were a lot of discussions regarding that, but in my opinion the way it is currently treated is wrong) of the covers. Therefore I created the following template:
For my dashboard, I use the bubble cards. The values are working correctly, however, there are 2 problems left with that approach.
The state attribute can not be inverted, at least not via overriding state in the template. Is remains to show “open” in case the cover is 100% covering the windows.
The bubble card disables the up/down arrow in relation to the state is_closed. So if the cover is 100% closed, the up arrow is disabled since the is_closed state isn’t inverted. When I override the is_closed state in the template, I get an error when reloading the template.
In my opinion, pos=100 whould be open since this is the state of the original cover (not the inverted). However, even if I change the state to what you proposed, the state override is ignored. It always states closed if the cover is fully opened (you can look out of the windows).
What are you trying to invert? The open/close or the tilt? If you’re trying to invert open close, then you need to provide close/open as the inverted state, while also inverting the position.
You can omit the state completely and only provide the position template as well.
Thanks for the feedback. Going with your improved template, the arrows are working the wrong way. So pressing the up arrow now moves the cover down and vise versa.
The position of the cover and tilt as well as the state, because it shows 0% when my KNX covers are fully closed (100% on KNX position). The arrows shall remain the same, clicking the up arrow still shall move the cover up and vise versa.
What you want is not possible with a template cover.
If you invert the positions, it will invert the state, even if you attempt to override the state.
This is the logic behind the state
def _update_cover_state(self, state: CoverState | None) -> None:
"""Update the state of the cover."""
if state:
if CONF_POSITION not in self._templates:
if state == CoverState.OPEN:
self._attr_current_cover_position = 100
else:
self._attr_current_cover_position = 0
self._attr_is_opening = state == CoverState.OPENING
self._attr_is_closing = state == CoverState.CLOSING
else:
if CONF_POSITION not in self._templates:
self._attr_current_cover_position = None
self._attr_is_opening = False
self._attr_is_closing = False
Under the hood, _attr_current_cover_position is set by the position template if provided.
Otherwise it’s ignored. But the upstream UI items will base icons and service calls based on the position if it’s available.
To clarify this for anyone else who comes to this thread.
Home assistant, no matter what, will always produce 100% == open 0% == closed. This is just how home assistant represents cover entities.
So if you plan to invert the position, just understand that the state will also invert. You cannot have an inverted 0 to 100 and a non inverted state or vise versa.
Here’s a table of what template cover can support:
state
position
/
not inverted
not inverted
inverted
inverted
not inverted
inverted
inverted
not inverted
OP falls into the not inverted state, inverted position row. Which is not possible.
Maybe I got you wrong, I want to invert both, the state and position attribute.
So position=0 shall be treated as open and position=100 shall be considered as closed. So according to your table I want to invert both, position and state which (according to your table) shall be possible?
0 in home assistant is always closed. You cannot change this.
100 in home assistant is always open. You cannot change this.
In order to invert a state, you’ll have to make 100 be 0 and 0 be 100. Which will invert the slider and the state, together. You cannot invert them individually because of the statements:
0 in home assistant is always closed. You cannot change this.
100 in home assistant is always open. You cannot change this.
Meaning, the slider in the UI will always be 0 to 100, where 100 represents open and 0 represents closed.
Okay thanks for the detailed info, now I got it. Is there a way to introduce a core Setting to define what open/close will be treated which is by default as it is currently (to make this changable)?
I can only speak for me, but for me it feels like totally unnatural to treat a fully closed cover as open (position=0%). I have no idea why the knx cover inverts the position by default, if it would read the value as it is from the KNX Bus, it would only behave wrongly (in my opinion) in regards to the state.
This doesn’t make sense, home assistant will say that’s closed. If it’s open in the real world, then inverting the cover is what you’d want to do.
The disconnect here is that you treat 100% as 100% closed, i.e. closed. Where as home assistant treats 0% as 0% open, i.e. closed.
The disconnect here is that you treat 100% as 100% closed, i.e. closed.
Sure, this I think makes more sense than what HA does by default. However, do you know why the KNX cover entity inverts the positions by default? My KNX actors return 100% when the covers are fully down, which I interprete as closed, but the cover entity shows 0% (without all that Template overrides)