Use input select to controll multiple blinds scenes

I am using luxeaflex duettes (PowerView), where I can define scenes (open / close / whatever inbetween) that appear as scenes in HA. however, I like to see what state the blinds are in when I am away since my sunlight automation can controll the scene that is selected. This is why I use an input_select that enables me to see and select the scene. However, I do not want to end up with a script for every room and scene, so I created this script for both dining and living room. As you guess: it is not working.
Why??

- id: '82644652386' 
  alias: Luxaflex                              
  initial_state: true
  hide_entity: false
  trigger:
  - platform: state
    entity_id: input_select.luxaflex_dining
  - platform: state
    entity_id: input_select.luxaflex_living
  action:
  - service: scene.turn_on
    data:
      data_template: >
        {%- if states.input_select.luxaflex_dining.state = 'Open' -%}
          entity_id: "scene.28541"
        {%- elseif states.input_select.luxaflex_dining.state = 'Zonwering' -%}
          entity_id: "scene.46701"
        {%- else -%}
          entity_id: "scene.20659"
        {%- endif -%}
  - service: scene.turn_on
    data:
      data_template: >
        {%- if states.input_select.luxaflex_living.state = 'Open' -%}
          entity_id: "scene.9632"
        {%- elseif states.input_select.luxaflex_living.state = 'Zonwering' -%}
          entity_id: "scene.1683"
        {%- else -%}
          entity_id: "scene.30891"
        {%- endif -%}

Try this:

- id: '82644652386' 
  alias: Luxaflex                              
  initial_state: true
  hide_entity: false
  trigger:
  - platform: state
    entity_id:
    - input_select.luxaflex_dining
    - input_select.luxaflex_living
  action:
  - service: scene.turn_on
    data_template:
      entity_id: >
        {% if trigger.entity_id == 'input_select.luxaflex_dining' %}
          {% if trigger.to_state.state == 'Open' %}
            scene.28541
          {% elif trigger.to_state.state == 'Zonwering' %}
            scene.46701
          {% else %}
            scene.20659
          {% endif %}
        {% else %}
          {% if trigger.to_state.state == 'Open' %}
            scene.9632
          {% elif trigger.to_state.state == 'Zonwering' %}
            scene.1683
          {% else %}
            scene.30891
          {% endif %}
        {% endif %}

Thanx, This does work!

1 Like