#Door sensor and light that changes color and brightness depending on time

1 messages · Page 1 of 1 (latest)

grand root
#

I have a bathroom with a magnet sensor and during the day I want normal lighting. Between 23:00 and 07:00 I want dimmed light with another color so I don't get flashbanged during the night. I also need the light to stay for a bit while on the toilet.

I tried setting it up with one automation, but I can't get it to work. Do I need to do it in 2 separate automations? I have close to zero understanding of yaml, and I use chatgpt to do the code. I kinda understand the code when it spits it out...

jade maple
#

Share what you've got so far

covert star
#

Tagging along.. I have similar issue as this.

jade maple
#

and most times you can either combine or split the automations, it's more dependent on your preference

covert star
jade maple
#

I'd suggest starting your own, even if it's similar. That way you can share what you've got so far

grand root
#

This for open the door:
alias: Turn On Light When Door Opens
trigger:

  • platform: state
    entity_id:
    • binary_sensor.lumi_lumi_magnet_agl02_opening
      from: "off"
      to: "on"
      action:
  • choose:
    • conditions:
      • condition: time
        after: "23:00:00"
        before: "07:00:00"
        sequence:
      • service: light.turn_on
        data:
        brightness_pct: 35
        target:
        area_id: toalett_oppe
    • conditions: []
      sequence:
      • service: light.turn_on
        data:
        brightness_pct: 85
        target:
        area_id: toalett_oppe
#

For closing:
alias: Turn Off Light 20 Minutes After Door Closes
trigger:

  • platform: state
    entity_id:
    • binary_sensor.lumi_lumi_magnet_agl02_opening
      from: "on"
      to: "off"
      for:
      hours: 0
      minutes: 0
      seconds: 20
      action:
  • delay:
    hours: 0
    minutes: 20
    seconds: 0
    milliseconds: 0
  • service: light.turn_off
    target:
    area_id: toalett_oppe
    data: {}
wintry nimbusBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

jade maple
#

You'll want to format that as code so that it's readable

grand root
#

seconds is just for testing

jade maple
#

And what is it actually doing

grand root
jade maple
#

How is this behaving incorrectly?

grand root
#

It has stopped working. The lamp only works when I manually toogle it on the phone

jade maple
#

Take a look at your traces

#

Is it triggering?

grand root
#

Yep

jade maple
#

And how is it proceeding? Any errors?

grand root
#

it stops on the timer it seems

jade maple
#

You're talking about the second one? Turn off?

grand root
#

yes

#

delay: 120
done: false

#

now it works?

#

only thing I changed was the timer..

#

But, the dimming, does that seem correct?

#

On the open the door automation, on "Then do", does it first execute option 1, if not met the conditions it skips to option 2?

jade maple
#

I'm not entirely sure what you're referring to, but the choose action will evaluate each set of conditions in order and execute the actions associated with the first set of conditions that are true