Dim two LiFx lamps to 30% at midnight

Hi all,

I’m super new to Home Assistant, so I don’t really know my way around everything just yet, especially the YAML editor.

I’m trying to set up an Automation to dim two LiFx lamps to 30% at midnight every night.

The two LiFx lamps will already be powered on before midnight because I have an Automation switching them both on when the sun sets each day.

The two LiFx lamps are labelled Sitting Room Lamp and Living Room Lamp.

The closest Action I can find is a preset called ‘Decrease Living Room Lamp brightness’ but from what I’ve read in the forums this will only decrease the brightness by 10% from their initial brightness of 100%.

Is there a way I can set them both to 30% brightness each midnight?

Any help appreciated, thanks.

I have an automation to turn two lamps on at 5:30am in our house. One is a colored bulb, one is just white, fwiw.

action:
  - data:
      brightness_pct: '80'
      color_name: white
      entity_id: light.family_room_lamp
    service: light.turn_on
  - data:
      brightness_pct: '50'
      entity_id: light.front_hall_lamp
    service: light.turn_on

Even though a little counter-intuitive - and even though the light’s already ‘on’ - you should light.turn_on and set the brightness_pct: '30' - this has the added benefit of turning it on even if it was off prior.

Also, this is ‘only’ the action portion of my automation - but you can recreate this same thing in the editor I believe.

/developer-tools/service is a great spot to go to ‘test’ these actions out in real-time.

Thanks for the tip.

I’ve got the following so far:

device_id: lotsofnumbersandletters
domain: light
entity_id: light.living_room_lamp
action:
  - data:
      brightness_pct: '30'
      color_name: white
      entity_id: light.living_room_lamp
    service: light.turn_on

I’m guessing I’ve gone wrong somewhere because when I try to save it I get the following error:

Message malformed: extra keys not allowed @ data[‘action’]

Where am I going wrong?

Everything under action: (including action:) looks OK, but I don’t know what the lines above are supposed to do ?

I feel like I’m missing something fundamental here, so I’ll try to show what I’m doing.

In the Automations > Actions menu I’m selecting:

Action Type: Device
Device: Living Room Lamp
Action: Decrease Living Room Lamp Brightness

At this point I select to edit as YAML, which already gives the following code:

type: brightness_decrease
device_id: lotsofnumbersandletters
entity_id: light.living_room_lamp
domain: light

If I delete all of the code and paste in the following:

action:
  - data:
      brightness_pct: '30'
      entity_id: light.living_room_lamp
    service: light.turn_on

Then hit save, it throws up the following error:

Message malformed: extra keys not allowed @ data[‘action’][0][‘action’]

I’m sure I’m missing something obvious but I can’t figure out what.

Use the Automation Editor to compose your automation.

Go to Configuration > Automations then click the + icon to create a new automation. You will then be presented with this screen:


Supply a name for the automation.

For the Trigger Type, select: Time
For at enter: 00:00

For Actions, set Action Type to: Call Service
Set Service to: light.turn_on
Set entity to the names of the two lamps. For example: light.this_lamp, light.that_lamp
Set Service Data to: brightness_pct: 30

Click the file icon to save the automation.


NOTE
If I enable “Edit as YAML” for both the Trigger and Action, the resulting screen looks like this:

1 Like

That worked! :smiley: :smiley:

Thanks Taras, I’d have been stuck on that for days without your help lol.

As part of my frustrated fault finding I’ve discovered that the same effect can also be achieved using Scenes.

Thanks again everyone, sorry for being such a noob lol.

1 Like

Yes, you can create a scene to set the lights. Then the automation can trigger at midnight and its Action can call the scene.turn_on service and supply the entity_id of the scene you created.

1 Like