Blueprint not working when adding a condition using existing entity input

Hi, I have a fairly simple blueprint which allows me to turn a light on and off with a selected switch, which works fine.

blueprint:
  name: light switch
  description: light switch
  domain: automation
  input:
    switch:
      name: Switch
      selector:
        device:
          filter:
            - integration: zha
              model: "RODRET Dimmer"
    light:
      name: Light
      selector:
        target:
          entity:
            domain: light
trigger:
  - device_id: !input switch
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: turn_on
    id: "on"
  - device_id: !input switch
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: turn_off
    id: "off"
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - "on"
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              transition: 0
              brightness_pct: 100
            target: !input light
      - conditions:
          - condition: trigger
            id:
              - "off"
        sequence:
          - service: light.turn_off
            metadata: {}
            data:
              transition: 0
            target: !input light
mode: single

I have one small issue which is that one of my bulbs seems to have an issue which is whenever i send press the off button again when it’s already off it comes back on again but dimly. To fix this bug, I can put in an extra condition which checks to see if the light is on before telling to turn off. I managed to get this to work in a manual automation but when I put it in the blueprint I can’t get it to work. If I add this extra condition:

- conditions:
  - condition: trigger
    id:
      - "off"
  - condition: state
    entity_id: !input light
    state: "on"
    enabled: true

I get

Automation Living Room Light failed to set up
The blueprinted automation "Living Room Light" (automation.living_room_light) failed to set up.

Error:Entity entity_id is neither a valid entity ID nor a valid UUID for dictionary value @ data['action'][0]['choose'][1]['conditions'][1]['entity_id']. Got {'entity_id': 'light.living_room_bulb_light'}.

To fix this error, edit the automation to correct it, then save and reload the automation configuration.

And if I do:

- conditions:
  - condition: trigger
    id:
      - "off"
  - condition: state
    target:
      entity_id: !input light
    state: "on"
    enabled: true

I get

Automation Living Room Light failed to set up
The blueprinted automation "Living Room Light" (automation.living_room_light) failed to set up.

Error:extra keys not allowed @ data['action'][0]['choose'][1]['conditions'][1]['target']. Got {'entity_id': {'entity_id': 'light.living_room_bulb_light'}} required key not provided @ data['action'][0]['choose'][1]['conditions'][1]['entity_id']. Got None.

To fix this error, edit the automation to correct it, then save and reload the automation configuration.

Can anyone tell me what I’m doing wrong and how to fix this please?

Targets and entities my seem the same, but are not the same thing.
Target Selector & Entity Selector Errors.

Thanks, will check this out!

OK, so I think I understand the issue, although I don’t fully understand why there has to be three ways to reference things (devices, entities and targets). Anyway, as far as I understand targets (which link to entities) are what services call, but a target is not actually an entity, this is why I can’t use it in a condition. So I am slightly confused about the solution here but I’m guessing these are some potential options:

  • Find a way to turn on a light without using a target
  • Somehow extract the actual entity_id from the target
  • Create two inputs of essentially the same thing but one is an entity and one is a target ( which seems mad )

I found a way to make it work! Not sure if it’s the best way but it works!

blueprint:
  name: light switch
  description: light switch
  domain: automation
  input:
    switch:
      name: Switch
      selector:
        device:
          filter:
            - integration: zha
              model: "RODRET Dimmer"
    light:
      name: Light
      selector:
        entity:
          filter:
            - domain: light
trigger:
  - device_id: !input switch
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: turn_on
    id: "on"
  - device_id: !input switch
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: turn_off
    id: "off"
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - "on"
        sequence:
          - service: light.turn_on
            metadata: {}
            data:
              transition: 0
              brightness_pct: 100
              entity_id: !input light
      - conditions:
          - condition: trigger
            id:
              - "off"
          - condition: state
            entity_id: !input light
            state: "on"
            enabled: true
        sequence:
          - service: light.turn_off
            metadata: {}
            data:
              transition: 0
              entity_id: !input light
mode: single        

Thanks again for your help! @Sir_Goodenough

If one of the suggestions listed solves your problem, please consider clicking the solution button to close the thread. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.