Blueprint Light Color

Hi,
Learning as I go, but can’t figure this one out:

Why does any form of setting of colour of the lights result in a blueprint error:
Something about can’t parse token at line …

Have tried, rgb_color:, hs_color: xy_color:

Lights are hue bulbs via ZHA.

trigger:
- platform: event
  event_type: zha_event
  event_data:
    device_id: !input 'remote'
    cluster_id: 64512

action:
  - variables:
      command        : '{{ trigger.event.data.command }}'
      cur_brightness : '{{ state_attr(light, ''brightness'') | int(0) }}'
      is_turned_on   : '{{ states(light) == ''on'' }}'
  
  - choose:
    - conditions: '{{ command == ''on_press'' }}'
      sequence:
      - choose:
        - conditions: '{{ on_button_mode == ''fixed brightness'' }}'
          sequence:
          - alias: "Turn on light"
            service: light.turn_on
            data:
              entity_id : !input 'light'
              transition: 0
              brightness_pct: !input 'fixed_brightness'

	      **** RGB **** 

        - conditions:
            - '{{ on_button_mode == ''fixed brightness when on'' }}'
            - '{{ is_turned_on }}'
          sequence:
          - action: light.turn_on
            data:
              entity_id : !input 'light'
              transition: 0
              brightness_pct: !input 'fixed_brightness'

	      **** RGB **** 

        default:
        - service: light.turn_on
          data:
            entity_id : !input 'light'
            transition: 1
            brightness_pct: !input 'fixed_brightness'

	      **** RGB ****

This is error message:

Failed to load blueprint: while scanning for the next token found character ‘\t’ that cannot start any token in “xxxxx.yaml”, line 153, column 1

Line 153 is where I inserted:

      rgb_color:
	- 0
	- 0
	- 255

What is that?
It’s probably not valid YAML syntax.

Things are out of context with you not sharing everything.
Makes it VERY hard to give good answers.

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question

Your indentation is not correct. Exactly like the error message says, it contains tabs (‘\t’) before your list items. Only indentation by spaces are allowed in YAML.

This was purely meant to indicate placeholders where I had tried and failed to insert some RGB code.

Genius, swapped tabs for spaces and I’m back in business !

Good. Then mark my post as the correct solution, so I can eventually advance my rank again :wink:

So, spacing fixed, any idea why the colour is not adjusting in either of the below:
Transition and Brightness definitely are working, but the colour remains the same as previously set outside of the blueprint.

rgb_color is populated via color_rgb selector:

          sequence:
          - service: light.turn_on
            data:
              entity_id: !input 'light'
              rgb_color: '{{turn_on_colour | list}}'
              transition: 5
              brightness_pct: !input 'fixed_brightness'

rgb_color is hardcoded

          sequence:
          - service: light.turn_on
            data:
              entity_id: !input 'light'
              rgb_color: [255,255,255]
              transition: 5
              brightness_pct: !input 'fixed_brightness'

So what was the color before/after, and what model bulbs do you have? IKEA Trådfri bulbs have issues executing two simultaneous changes, like changing color and brightness at the same time.

As far as I can see there is nothing weird with the code. Though eventually, someone may chime in and say that the correct way nowadays is to no longer put entity_id under data, but rather put it under target

Tried a couple of re-jigs of order / nesting - none seem to trigger a colour change. But brightness / transition always works perfect.

          sequence:
          - target: 
              entity_id: !input 'light'
            data:
              rgb_color: [255,255,255]
              transition: 0
              brightness_pct: !input 'fixed_brightness'
            action: light.turn_on

Bulbs are all Philips Hue paired via ZHA (no hue bridge involved).

Initially I manually set the bulbs to RED expecting the sequence to turn them on and WHITE - but they remain RED.

So, made some good progress but have come unstuck with an oddity:

This block will control transition and brightness perfectly. But refuses to do anything with the color.

  - choose:
    - conditions: '{{ command == ''on_press'' }}'
      sequence:
          - target: 
              entity_id: !input 'light'
            data:
              rgb_color: '{{ turn_on_colour | list }}'
              transition: 0
              brightness_pct: !input 'fixed_brightness'
            service: light.turn_on

This block will control transition, brightness and colour perfectly, even matching the colour to the selector.

    - conditions: '{{ command == ''on_hold'' }}'
      sequence:
          - target: 
              entity_id: !input 'light'
            data:
              rgb_color: '{{ turn_on_colour | list }}'
              transition: 0
              brightness_pct: !input 'fixed_brightness'
            service: light.turn_on

Only difference between the two is a “press” or “hold” command.
Can’t see why that would make a difference in the grand scheme.
Switch doing the controlling is also a Philips Hue Dimmer Switch.

The not so terrible side affect I’ve now got is, a tap of the on switch with restore the previous colour at the required brightness. A hold of the switch will turn on at the default colour at the required brightness.

EDIT: More progress, double thru to quintuple press all adjust the colour also. Therefore the only press that doesn’t adjust the colour is the “On_Press” aka single press ****

There must be something more going on. I would suspect that either your “on_press” input in this automation executed more actions than you think it does, you have a different automation that also triggers on the same button press, or the your remote is sending more events that you are expecting (i.e. one for button down and another for button up or something like that).

I would start by looking in traces for this automation to see exactly which actions are executed, and also if it runs once or multiple times when the button is pressed. (Which mode is the automation set to by the way?) Then check the device logbook and see what happens when you press the button, does it report one or several events, and which automations trigger.

Just getting back around to this.
Thanks for pointing me in the right direction - I’m learning quite a bit as I go and starting to see the trees in the forest etc.

You were spot on with your thoughts, even though “on_press” seemed to be working (partially), tracing what was actually being sent turned out to be the key.
Seems the command being sent for a single press was i.e. tap on and release was “on_short_release”.

Switches now have spouse approval !!