Philips Hue bedroom wake-up script behaving erroneous

Hi all,

I have an automation up and running to switch on my bedroom lights when my alarm goes off in the morning. It works perfectly, however, the lights are directly fully bright switched on.
A couple of friends of mine have a Philips Wake-up light that has caught my attention and I would like to make something similar, but then with my main bedroom light.

I did found some scripts on the world wide web and here on the forum (I have seen so many now that I do not know exactly who to credit for which part, sorry!!)
When tweaking it to my installation, it really works erroneous…

The configurator states that I have a “bad indentation of a mapping entry at line 10, column 20:”
However, when I trigger the script, one of my 2 Philips white ambiance bulbs cycle’s the complete script, whereas the other one just turns on fully bright.

Both bulbs are switched on by a Shelly 1 behind my wall switch as the only time I use the adjustabillity of the bulbs is when I want to wake up.
So the bulbs themselves are “programmed” to a standard setting when they are power back up again.

This is the script I have so far:
(the delay and transition times are indeed short, but that is for testing purposes instead of waiting the eventual 20 minutes to go through the script)

#
# WAKE-UP LIGHT SCRIPT
#
  sunrise:
    sequence:
      - service: switch.turn_on
        data:
          entity_id: switch.shelly_shsw_1_ba60e
      - service: light.turn_off
          entity_id: light.bedroom_ceiling_1, light.bedroom_ceiling_2
      - service: light.turn_on
        data:
          entity_id: light.bedroom_ceiling_1, light.bedroom_ceiling_2
          xy_color: [0.67,0.39]
          brightness: 1.0
      - delay:
          seconds: 1.0
      - service: light.turn_on
        data:
          entity_id: light.bedroom_ceiling_1, light.bedroom_ceiling_2
          xy_color: [0.65,0.41]
          brightness: 85
          transition: 60
      - delay:
        seconds: 60.0
      - service: light.turn_on
        data:
          entity_id: light.bedroom_ceiling_1, light.bedroom_ceiling_2
          xy_color: [0.60,0.40]
          brightness: 170
          transition: 60
      - delay:
          seconds: 60.0
      - service: light.turn_on
        data:
          entity_id: light.bedroom_ceiling_1, light.bedroom_ceiling_2
          xy_color: [0.48,0.40]
          brightness: 255
          transition: 60

Could someone here shed some “light” on my script and help a fellow member out?

Tbh the script looks fine except for one thing which I haven’t seen before in the few years I use HA.

You define multiple entities on the same line divided by a comma. I haven’t seen this before, but I think this might be the problem.

      - service: light.turn_off
          entity_id: 
            - light.bedroom_ceiling_1
            - light.bedroom_ceiling_2

Could you try it this way please? (you need to do it for the others as well).

Sidenote: You can just change the topic of a thread without the need of starting a new one. And coming from Eindhoven (Hometown of Philips), Phillips is written with a single L :rofl: XD.

indentation on entity_id is wrong, needs 2 spaces removed.


      - service: light.turn_off
        entity_id: 
        - light.bedroom_ceiling_1
        - light.bedroom_ceiling_2

EDIT: or you could put it in the data section instead of removing the spaces…


      - service: light.turn_off
        data:
          entity_id: light.bedroom_ceiling_1, light.bedroom_ceiling_2

@jimz011 You can specify multiple entities in a list like OP did. The indentation was just wrong as petro said.

Also @Falcon , the second delay indentation is wrong. seconds: 60.0 needs to be moved over two spaces. You also don’t need the decimal.

1 Like

Well, I have an automation that looks like this (end part only)

  action:
    service: light.turn_on
    entity_id: 
      - light.nachtkastje_jimmy
      - light.nachtkastje_stephanie
      - light.vloerled
      - light.bedled
      - light.slaapkamer_bed
      - light.slaapkamer_kast

Which works absolutely fine.

I said to OP that I haven’t seen separations with comma’s before (I thought list was something that I just showed in the code above). So please correct me if I am wrong.

      - service: light.turn_off
          entity_id: light.bedroom_ceiling_1, light.bedroom_ceiling_2

is the last part separated with comma’s called a list? If yes I have learnt something today XD

Many thanks so far guys, the HA Configurator now also does not give me any warnings anymore that there is a fault in the code :smiley:

So, I have adjusted the indentations however, now no lights will turn on anymore…
Not even the switch, providing both bulbs the power they need to shine.
It just stays dark…

My script now looks like this:

#
# WAKE-UP LIGHT SCRIPT
#
  sunrise:
    sequence:
      - service: switch.turn_on
        data:
          entity_id: switch.shelly_shsw_1_ba60e
      - service: light.turn_off
        entity_id:
          - light.bedroom_ceiling_1
          - light.bedroom_ceiling_2
      - service: light.turn_on
        data:
          entity_id: light.bedroom_ceiling_1, light.bedroom_ceiling_2
          xy_color: [0.67,0.39]
          brightness: 1.0
      - delay:
          seconds: 1.0
      - service: light.turn_on
        data:
          entity_id: light.bedroom_ceiling_1, light.bedroom_ceiling_2
          xy_color: [0.65,0.41]
          brightness: 85
          transition: 60
      - delay:
          seconds: 60.0
      - service: light.turn_on
        data:
          entity_id: light.bedroom_ceiling_1, light.bedroom_ceiling_2
          xy_color: [0.60,0.40]
          brightness: 170
          transition: 60
      - delay:
          seconds: 60.0
      - service: light.turn_on
        data:
          entity_id: light.bedroom_ceiling_1, light.bedroom_ceiling_2
          xy_color: [0.48,0.40]
          brightness: 255
          transition: 60

@Tediore: I did decimal the seconds as I was in the intention that HA also works with tenths of seconds?
I did this so I could tweak the time between the Shelly 1 switching on and the 2 Philips hue bulbs sending the command to turn of so I have the shortest amount of time that the lights give a flash before begining the script.

why would you say that? Using the 2 spaces is perfectly fine, as long as you do that consistently. I have 2 spaces in my complete configuration and it delivers perfectly.

No, using the comma separated list works fine also, and is a completely valid yaml…

btw, as long as no extra data is required, you can leave the data key out, and use

service: light.turn_off
entity_id: light.bedroom_ceiling_1, light.bedroom_ceiling_2

or

service: light.turn_off
entity_id:
  - light.bedroom_ceiling_1
  - light.bedroom_ceiling_2

Ah ok, see I did learn something today :joy:

because this was in his config.

      - service: light.turn_off
          entity_id: light.bedroom_ceiling_1, light.bedroom_ceiling_2
          ^
   should be 2 spaces backwards.
1 Like

See, now I was agreeing with Marius’s, right up to the point where you said this…
And now I agree with you.
(the agreeing but is easy, it’s the spotting what lands you in the ‘sugar’ that’s hard)

Be careful, you can’t mix domains with this
Though sometimes that can work if you call home assistant.turn_on instead
Test first.

I am really sorry, I missed that completely. Should have known better… makes my reply look silly…