Milight automation not working

I have been trying to set up a sunrise lights on automation, but I can’t get it to do anything other than turn on the lights. It stays the previous color, and I can’t get it to change color or go to white mode, or change the brightness. If I try and specify any parameter- from which light all the way to a specific light parameter- the only thing it does is turn on some of the lights (but in the wrong zone and sometimes only specific lights in a certain zone, which is weird because if a zone is activated all lights in that zone are a slave to the commands of that zone, yet they even switch which ones turn on, sometimes 2 lights, sometimes 3 lights…). I have no idea how to fix this, as the lights are controllable just fine from the UI, so I don’t know what to do from here.

automation.yaml:

- id: '1540415715656'
  alias: Sunrise Lights
  trigger:
  - event: sunrise
    offset: -01:15:00
    platform: sun
  condition:
  - before: 07:00:00
    condition: time
  action:
  - service: light.turn_on
    data:
      entity_id: light.lamp
      brightness: 255
      #rgb_color: [255, 255, 255]
      #color_name: blue

This automation seems to work for me…

- id: '1505977024304'
  alias: Turn Lounge Light On Elevation < 25° & after 4PM
  trigger:
  - platform: numeric_state
    below: 25
    entity_id: sun.sun
    value_template: '{{ state.attributes.elevation }}'
  - platform: time
    at: '16:00:00'
  condition:
  - condition: time
    after: '16:00:00'
    before: '19:00:00'    
  - condition: template
    value_template: '{{states.sun.sun.attributes.elevation < 25}}'
  action:
  - service: light.turn_on
    data:
      brightness_pct: 75
      entity_id: light.lounge
      kelvin: 3100

I’m using brightness_pct - you could use 100 for that instead of brightness 255. I also think your times need to be in quotes because they are a string.

I’m using kelvin to set the colour temp which only works in white mode too.

Also, I had a maddening problem ages ago where my lights kept changing to blue when I switched them on no matter what I did - turned out I had another automation that changed the colour to blue when the state changed to on… it was my own stupid fault from before I fully understood how automations worked and I was following a guide…

I also have other issues with these lights not responding the first time I turn them on/off and I have another automation that turns them on another 2 times after a delay. (also off 2 times if I’m turning them off) That automation is here:

- id: '1532478833426'
  alias: Lights Off Failsafe
  initial_state: 'on'
  trigger:
  - platform: state
    from: 'on'
    to: 'off'
    entity_id: light.lounge, light.dining, light.desk, light.office
  condition: []
  action:
  - delay: '00:00:02'
  - service: light.turn_off
    data_template:
      entity_id: >-
        {%- if (as_timestamp(now()) - as_timestamp(states.light.lounge.last_changed) < 5) and (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed) < 5) -%}
        light.lounge, light.desk
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.office.last_changed) < 5) and (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed) < 5) -%}
        light.office, light.desk
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed) < 5) -%}
        light.desk
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.office.last_changed) < 5) -%}
        light.office
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.lounge.last_changed) < 5) -%}
        light.lounge
        {%- else -%}
        light.dining
        {%- endif -%}
  - delay: '00:00:02'
  - service: light.turn_off
    data_template:
      entity_id: >-
        {%- if (as_timestamp(now()) - as_timestamp(states.light.lounge.last_changed) < 10) and (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed) < 10) -%}
        light.lounge, light.desk
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.office.last_changed) < 10) and (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed) < 10) -%}
        light.office, light.desk
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed) < 10) -%}
        light.desk
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.office.last_changed) < 10) -%}
        light.office
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.lounge.last_changed) < 10) -%}
        light.lounge
        {%- else -%}
        light.dining
        {%- endif -%}
- id: '1532478833427'
  alias: Lights On Failsafe
  initial_state: 'on'
  trigger:
  - platform: state
    from: 'off'
    to: 'on'
    entity_id: light.lounge, light.dining, light.desk, light.office
  condition: []
  action:
  - delay: '00:00:02'
  - service: light.turn_on
    data_template:
      entity_id: >-
        {%- if (as_timestamp(now()) - as_timestamp(states.light.lounge.last_changed) < 5) and (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed) < 5) -%}
        light.lounge, light.desk
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.office.last_changed) < 5) and (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed) < 5) -%}
        light.office, light.desk
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed) < 5) -%}
        light.desk
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.office.last_changed) < 5) -%}
        light.office
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.lounge.last_changed) < 5) -%}
        light.lounge
        {%- else -%}
        light.dining
        {%- endif -%}
      brightness_pct: 75
      kelvin: 3100
  - delay: '00:00:05'
  - service: light.turn_on
    data_template:
      entity_id: >-
        {%- if (as_timestamp(now()) - as_timestamp(states.light.lounge.last_changed) < 10) and (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed) < 10) -%}
        light.lounge, light.desk
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.office.last_changed) < 10) and (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed) < 10) -%}
        light.office, light.desk
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.desk.last_changed) < 10) -%}
        light.desk
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.office.last_changed) < 10) -%}
        light.office
        {%- elif (as_timestamp(now()) - as_timestamp(states.light.lounge.last_changed) < 10) -%}
        light.lounge
        {%- else -%}
        light.dining
        {%- endif -%}
      brightness_pct: 75
      kelvin: 3100

See I input what I wanted into the automation template under settings so I could use it as a template, but it just isn’t listening to my data. The code will run but my data section doesn’t to matter. Like currently, I’ll set the lights to white then turn them off, then activate the automation and the lights will turn on, but they go back to white even though I have in my data for them to turn blue. Or vice versa, l’ll set them to blue and turn them off and run the script for them to come on as white, and they just turn on blue. Nothing in the data section is working.

Try removing the spaces from RGB color - My scenes work without spaces… dunno if that’s important or not.

Do you have the right bridge type configured and the right bulb type?

Yes, I can even get it to work via google home voice commands, including changing the colors. As for the spaces in rgb, it had no effect.

did you try putting the times in ’ ’ ? (Although I don’t see how that would stop the colours being right if it triggers…) Are you sure there is no other automation or scene being triggered for that light??