Motion Automation Not Working

Hello everyone, I have a few devices that I have been working on to get off of my Samsung SmartThings hub and on to my HA install. One of them being the SmartThings motion sensor which paired with that hub I was able to turn on and off my porch light after sundown.

I attempted to set this up with HA and it seems like the entity for the motion sensor does work, by turning on when seeing motion and off when not but when I set up the device to turn on, my LiFX bulb on the porch, the automation does not turn on the light. Not sure if its a config issue or connection issue with the bulb even though I can manually turn on and off. Not sure what to check here so if someone can help me out that would be great.

Ill post the automations.yaml next but I did do the config in the webgui and not in the file.

- id: '1611685629235'
  alias: Porch Motion Light
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.smartthings_motionv4_eaa80001_ias_zone
    attribute: friendly_name
    from: 'off'
    to: 'on'
  condition:
  - condition: sun
    before: sunrise
    after: sunset
  action:
  - type: turn_on
    device_id: cc8621c49a021d835d53f0b9efe7ecdc
    entity_id: light.porch
    domain: light
    brightness_pct: 100
  mode: single
- id: '1611685735386'
  alias: Port Motion Light Off
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.smartthings_motionv4_eaa80001_ias_zone
    attribute: friendly_name
    from: 'on'
    to: 'off'
    for: '60'
  condition:
  - condition: sun
    before: sunrise
    after: sunset
  action:
  - type: turn_off
    device_id: cc8621c49a021d835d53f0b9efe7ecdc
    entity_id: light.porch
    domain: light
  mode: single

Your triggers are wrong because you are following the friendly_name attribute instead of the state for some reason.

Your conditions are wrong because it cannot be both before sunrise and after sunset at the same time.

1 Like

Took off the friendly name, but as for the before sunrise and after sunset, would that just be night time? This is my first time doing an automation in HA that I only want to occur during a specific time which seems like before sunrise and after sunset would work since that describes night time in my opinion.

What would you suggest for night time then?

No, before sunset is midnight -> sun up, after sunrise is sun down -> midnight.

A state condition for the sun being below the horizon is sun down -> sun up

- condition: state
  entity_id: sun.sun
  state: 'below_horizon' 

Or you can use an OR condition and say it’s sunset -> midnight OR midnight -> sunrise

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

Thanks, Ill give this a shot tonight.

1 Like