Hi everyone,
I am trying to setup an automation to open my window blind if the window is opened and close the window blind if the window is closed. Actually I want to close it to the same position as it was, before the window got opened. I use the hass-variables custom component to store the original position of the blind. I can update the variable with the actual position. However I am unable to close the blind to the original position because the variable is not accepted as integer for the set_cover position service.
initial variable declaration in configuration.yaml:
variable:
home_theather_1_window_blind_position:
value: 0
updating the variable when the window is opening:
action:
- service: variable.set_variable
data:
variable: home_theather_1_window_blind_position
value_template: '{{ state_attr("cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_2", "current_position") }}'
After opening the window I crosscheck with the dev-tools templates that the variable is set. Entering {{ states("variable.home_theather_1_window_blind_position") }}
returns 82
which was the actual position of the blind as desired.
Now I want to set the blind back to this position but it fails:
action:
- service: cover.set_cover_position
data:
position: "{{ states('variable.home_theather_1_window_blind_position') }}"
entity_id: cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_2
Invalid data for call_service at pos 1: expected int for dictionary value @ data[‘position’]`
I also tried to cast it to integer but it doesn’t work, I get the same error:
action:
- service: cover.set_cover_position
data:
position: "{{ states('variable.home_theather_1_window_blind_position') | int }}"
entity_id: cover.fibaro_system_fgrm222_roller_shutter_controller_2_level_2
I also tried like this:
'{{ states.variable.home_theather_1_window_blind_position.state | int }}'
but I get the same error.
Setting the blind if I manually enter an integer number works. So it must be something related that variable state is not taken as integer. Maybe I am overlooking something very obvious. Thanks for help.