Hi all, I’m trying to automate the position of a roller shutter (using a Shelly 2.5) to sync the movement of a second shutter, but I can’t get the automation to save. The error message isn’t very helpful: Message malformed: value must be one of ['close', 'close_tilt', 'open', 'open_tilt', 'stop'] for dictionary value @ data['type']
If I set position to a number (eg position: 10) then it works fine, so I’m assuming its my automation syntax that’s wrong, or a problem evaluating this on save?
alias: Bedroom Sync left shutter with right
description: ''
trigger:
- platform: device
device_id: 09d01ebe6f9305815a78c16ec1092d72
domain: cover
entity_id: cover.bedroom_shutters_right
type: position
above: 0
below: 100
condition:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.bedroom_shutters_synced
state: '1'
action:
- device_id: f69d0d4c5268cdab4b2d2fc94eb9c88d
domain: cover
entity_id: cover.bedroom_shutters_left
type: set_position
position: "{{ int(state_attr('cover.bedroom_shutters_right', 'current_position')) }}"
mode: single
If I jump over to the template section of the developer tools and pop this same line into the example template it works fine:
Blind position is {{ int(state_attr('cover.bedroom_shutters_left', 'current_position')) }}
--> Blind position is 50
Is my syntax wrong?
There’s a similar bug here but it was fixed in Jan 2021 and I’m running the 2022.5.4 release.
There’s a similar bug for ShellyForHASS here but it was related to the position not being sent, whereas my blind’s current position is 50 — perhaps this isn’t sent when saving the automation and so it hits the same bug?
Home Assistant Core 2022.5.4
Home Assistant Supervisor 2022.05.2
Home Assistant OS 7.6
Have you tried : {{ state_attr('cover.bedroom_shutters_left', 'current_position')|int(default=0) }}
Oh nevermind, this is NOT where the error is !!!
The error says that the type must be one of ['close', 'close_tilt', 'open', 'open_tilt', 'stop'] not set_position as you wrote !
This set_position does not exists. You have to close/open to a position.
I have no covers at home so I can’t really be 100% sure of what I’m saying but just based on error you have it looks like you are calling a not existing thing
You should probably write something like :
[...blabla]
action:
- device_id: f69d0d4c5268cdab4b2d2fc94eb9c88d
domain: cover
entity_id: cover.bedroom_shutters_left
type: close
position: "{{ int(state_attr('cover.bedroom_shutters_right', 'current_position')) }}"
mode: single
And… after a quick look, set_position is a thing for a service !
Then :
Last edit (I hope !)
Template is maybe better like this {{ state_attr('cover.bedroom_shutters_left', 'current_position')|int(default=0) }} because the template filter int MUST specify a default value !
You may need to add a delay before the automation evaluates the position of the right blind
edit: I noticed that you have used in the input_boolean condition, which probably guards the right blind when it is in position. No delay will be required