Motion detection with Hue

Hello all :slight_smile:

I am new with the Home Assistant, I slowly integrated my Hue System first, and now I have a problem with the following configuration and I hope you can help me.

on the garage we have a motion detection and two lamps, all from Philips Hue. I have make a config, that works after the sunset, and will stop after sunrise. After an motion ist detectetd, the two lamps going on, after 3 min lights down. After 20:30 (the actually sunset time) it really works fine, after 23:00 the log said

"- Triggered by the state of binary_sensor.garage_bewegungsmelder_motion at 27. August 2022 um 23:05:22

  • Test sun condition
  • Stopped because a condition failed a…"

Thank you very much,
Chris

Could you post the yaml code from your automation. I think this will help us to see what’s happening.

Hi, I thinkl thats it?!
Thank you.

  • id: ‘1661441539509’
    alias: Garagen Hof Licht Bewegung an
    description: ‘’
    trigger:
    • type: motion
      platform: device
      device_id: 0870e29ac67b2789caa09201c7b2fe7e
      entity_id: binary_sensor.garage_bewegungsmelder_motion
      domain: binary_sensor
      for:
      hours: 0
      minutes: 0
      seconds: 0
      condition:
    • condition: sun
      after: sunset
      action:
    • type: turn_on
      device_id: 5c32dbb16aa5a5e83ecdf1e6a901abd2
      entity_id: light.hof_garage_links
      domain: light
      brightness_pct: 100
    • type: turn_on
      device_id: e0a12642eb4bc77eac45949d005a907f
      entity_id: light.hof_garage_rechts
      domain: light
      brightness_pct: 100
    • delay:
      hours: 0
      minutes: 3
      seconds: 0
      milliseconds: 0
    • type: turn_off
      device_id: e0a12642eb4bc77eac45949d005a907f
      entity_id: light.hof_garage_rechts
      domain: light
    • type: turn_off
      device_id: 5c32dbb16aa5a5e83ecdf1e6a901abd2
      entity_id: light.hof_garage_links
      domain: light
      mode: single

I think your Condition may be better to include ‘after’ and ‘before’ sunrise, like this:

condition: sun
after: sunset
before: sunrise

otherwise the automation will only work until midnight.

I’m guessing that the time shown in the trace may really be 00:30 so, after midnight. I may be wrong as I doubt the developers have made such an error.

Also, please put your yaml code in using the code insert tool. It’s not a big problem but neatly formatted code is easier to read.

Hi and thank you, I try it tonight and give you feeback :slight_smile:

Chris

1 Like

According to the documentation for Sunrise/Sunset Condition, you cannot combine the after and before options in one condition.

Therefore, to cover time between sunset and sunrise one need to use after: sunset and before: sunrise as 2 separate conditions and combine them using or.

condition:
  condition: or
  conditions:
    - condition: sun
      after: sunset
    - condition: sun
      before: sunrise

A simpler way to specify ‘when dark’ is to use a Sun State Condition.

condition:
  condition: state
  entity_id: sun.sun
  state: below_horizon
1 Like

Hi at all,

I have try this code:

condition:
  condition: state
  entity_id: sun.sun
  state: below_horizon

I hope that is the code insert tool :wink:

It looks that this works fine, thank you!

Next step is an function with an switch, to toggle on an continous light, and disable the motion detection, and backward if the party is over.