Help with draft of blueprint for managing ceiling and room lights

Hi,

I’m working on a blueprint to turn off room lights if ceiling light is swiched on (saving status and attributes) and restore status when ceiling light is swiched off.

Here’s what I achieved so far:

blueprint:
  name: Inverse sync Ceiling vs Secondary Lights 
  description: Turn off room lights if ceiling light is swiched on (saving status and attributes) and restore status when ceiling light is swiched off.
  domain: automation
  input:
    ceiling_light:
      name: Ceiling light
      description: This is the Ceiling light, will be turned on when the secondary light is turned on.
      selector:
        entity:
          domain: light
    room_light_1:
      name: Room light 1
      description: This is the secondary light, will be turned off when the ceiling light is turned on.
      selector:
        entity:
          domain: light
    room_light_2:
      name: Room light 2
      description: This is the secondary light, will be turned off when the ceiling light is turned on.
      selector:
        entity:
          domain: light
    scene_name:
      name: Scene Name 
      description: Name of the scene that will storage attributes of the room lights
      selector:
        entity:
          domain: input_text
variables:
  scene_entity: !input 'scene_name'
trigger:
  - platform: state
    entity_id: !input ceiling_light
    to: "on"
  - platform: state
    entity_id: !input ceiling_light
    to: "off"
action:
  choose:
    - conditions:
        - condition: template
          value_template: "{{ trigger.to_state.state == 'on' }}"
      sequence:
        - service: scene.create
          data:
            scene_id: !input scene_entity
            snapshot_entities:
              - !input room_light_1
              - !input room_light_2
        - service: light.turn_off
          data:
            entity_id:
              - !input room_light_1
              - !input room_light_2
    - conditions:
        - condition: template
          value_template: "{{ trigger.to_state.state == 'off' }}"
      sequence:
        - service: scene.turn_on
          data:
            entity_id: scene.xxxx
  default: []


      

How can I change scene.xxxx with scene name in !input ‘scene_name’?

Thank you in advance!

I do not have the solution for you, but may be a hint.
In normal automation one can you something like

service_template: input_boolean.turn_{{ states('switch.workstation') }}
data: {}
entity_id: input_boolean.workstation

may-be you can adopt it for your bluepint in a similar way
i.e. (dont know if and how correctly to implement)

- service: scene.turn_on
          data:
            entity_id: scene.{{here-scene-name of scene}}
1 Like

I made some change but 2nd choise does not work:

blueprint:
  name: Inverse sync Ceiling vs Secondary Lights 
  description: Turn off room lights if ceiling light is swiched on (saving status and attributes) and restore status when ceiling light is swiched off.
  domain: automation
  input:
    ceiling_light:
      name: Ceiling light
      description: This is the Ceiling light, will be turned on when the secondary light is turned on.
      selector:
        entity:
          domain: light
    room_light_1:
      name: Room light 1
      description: This is the secondary light, will be turned off when the ceiling light is turned on.
      selector:
        entity:
          domain: light
    room_light_2:
      name: Room light 2
      description: This is the secondary light, will be turned off when the ceiling light is turned on.
      selector:
        entity:
          domain: light
    scene_name:
      name: Scene Name 
      description: Name of the scene that will storage attributes of the room lights
      selector:
        text:
trigger:
  - platform: state
    entity_id: !input ceiling_light
    to: "on"
  - platform: state
    entity_id: !input ceiling_light
    to: "off"
action:
  choose:
    - conditions:
        - condition: template
          value_template: "{{ trigger.to_state.state == 'on' }}"
      sequence:
        - service: scene.create
          data:
            scene_id: !input scene_name
            snapshot_entities:
              - !input room_light_1
              - !input room_light_2
        - service: light.turn_off
          data:
            entity_id:
              - !input room_light_1
              - !input room_light_2
    - conditions:
        - condition: template
          value_template: "{{ trigger.to_state.state == 'off' }}"
      sequence:
        - service: scene.turn_on
          data:
            entity_id: !input scene_name
  default: []

there’s something in the scene…

Error while executing automation automation.inverse_sync_ceiling_vs_secondary_lights: not a valid value for dictionary value @ data[‘entity_id’]

  • Studio - Luce Soffitto Test: Choose at step 1: choice 2: Error executing script. Invalid data for call_service at pos 1: not a valid value for dictionary value @ data[‘entity_id’]
  • Studio - Luce Soffitto Test: Error executing script. Invalid data for choose at pos 1: not a valid value for dictionary value @ data[‘entity_id’]

your scene_name is text and not a entity. This will not work.

I’ve tested it: My solution works! (“data” → “target” in your case)

blueprint:
  name: Inverse sync Ceiling vs Secondary Lights 
  description: Turn off room lights if ceiling light is swiched on (saving status and attributes) and restore status when ceiling light is swiched off.
  domain: automation
  input:
    scene_name:
      name: Scene Name 
      description: Name of the scene that will storage attributes of the room lights
      selector:
        text:
        
mode: queued

variables:
   scene_name: !input scene_name
trigger:
  - platform: time
    at: '11:45:00'
    id: by_time
action:
    #- service: scene.turn_on
    #  data:
    #    entity_id: scene.{{ state_attr(scene_name, 'friendly_name') }}
    - service: scene.turn_on
      target:
        entity_id: scene.{{scene_name}}

Remember: you have to use the internal name of your scene in input-text, not the “friendly_name”.

I didnt get your idea in details, but if you want to store the state of entities, you have probably to use “create” for scens and then, somehow to reload them.

1 Like

Thank you!

now it works:

For all the curious out there

blueprint:
  name: Inverse sync Ceiling vs Secondary Lights 
  description: Turn off room lights if ceiling light is swiched on (saving status and attributes) and restore status when ceiling light is swiched off.
  domain: automation
  input:
    ceiling_light:
      name: Ceiling light
      description: This is the Ceiling light, will be turned on when the secondary light is turned on.
      selector:
        entity:
          domain: light
    room_light_1:
      name: Room light 1
      description: This is the secondary light, will be turned off when the ceiling light is turned on.
      selector:
        entity:
          domain: light
    room_light_2:
      name: Room light 2
      description: This is the secondary light, will be turned off when the ceiling light is turned on.
      selector:
        entity:
          domain: light
    scene_name:
      name: Scene Name 
      description: Name of the scene that will storage attributes of the room lights
      selector:
        text:

variables:
  scene_name: !input scene_name
trigger:
  - platform: state
    entity_id: !input ceiling_light
    to: "on"
  - platform: state
    entity_id: !input ceiling_light
    to: "off"
action:
  choose:
    - conditions:
        - condition: template
          value_template: "{{ trigger.to_state.state == 'on' }}"
      sequence:
        - service: scene.create
          data:
            scene_id: !input scene_name
            snapshot_entities:
              - !input room_light_1
              - !input room_light_2
        - service: light.turn_off
          data:
            entity_id:
              - !input room_light_1
              - !input room_light_2
    - conditions:
        - condition: template
          value_template: "{{ trigger.to_state.state == 'off' }}"
      sequence:
        - service: scene.turn_on
          data:
            entity_id: scene.{{scene_name}}
  default: []

Hi,

I want to make blueprint more flexible so now you can have one of multiple secondary lights.

The issue is on the scene.create part. I doesn’t work anymore:

blueprint:
  name: Marco - Inverse sync Ceiling vs Secondary Lights
  description: Turn off room lights if ceiling light is swiched on (saving status and attributes) and restore status when ceiling light is swiched off.
  domain: automation
  input:
    ceiling_light:
      name: Ceiling light
      default: {}
      description: This is the Ceiling light, will be turned on when the secondary light is turned on.
      selector:
        entity:
          domain: light
    room_light:
      name: Room light
      default: {}
      description: This is the secondary light, will be turned off when the ceiling light is turned on.
      selector:
        entity:
          multiple: true
          domain: light
    scene_name:
      name: Scene Name
      description: Name of the scene that will storage attributes of the room lights
      selector:
        text:
    boolean_name:
      name: Room Name
      description: Name of the room in which are the lights
      default: false
      selector:
        text:
variables:
  scene_name: !input scene_name
  boolean_name: !input boolean_name
trigger:
  - platform: state
    entity_id: !input ceiling_light
    to: "on"
  - platform: state
    entity_id: !input ceiling_light
    to: "off"
action:
  choose:
    - conditions:
        - condition: template
          value_template: "{{ trigger.to_state.state == 'on' }}"
      sequence:
        - service: scene.create
          data:
            scene_id: !input scene_name
            snapshot_entities:
              - !input room_light
        - service: light.turn_off
          data:
            entity_id:
              - !input room_light
    - conditions:
        - condition: template
          value_template: "{{ trigger.to_state.state == 'off' }}"
        - condition: template
          value_template: "{{ is_state('input_boolean.' + boolean_name, 'off') }}"
      sequence:
        - service: scene.turn_on
          data:
            entity_id: scene.{{scene_name}}
  default: []

Error says :

 Error while executing automation automation.gestione_luci_studio: value should be a string for dictionary value @ data['snapshot_entities'] 

can you please help me? Thank you