Help with Motion Detection and Presence

If anyone would be so kind, I need a little help setting up an automation for a motion sensor I have installed. Basically, I just want the text alerts to just be sent when no one is home and after sunset. I will set it up to send via SMS.

So, if no one is home, send SMS on motion detection. If it’s after sunset (ends at sunrise) regardless of who is home, send SMS on motion detection.

Unless there is a better or more efficient way to do this.

Trigger: motion detected
Condition:
OR:
Conditions:
Sun: below horizon
Group.all_devices: not home
Action: send SMS

Does that help? I can write out the yaml when I’m at a computer if needed.

Let me see if I can work it out. It gives me a framework to start with.

1 Like

Okay, so this is what I got. I have not tested it yet though, but just a preliminary check, it is screaming about the platform states in the trigger.

- id: FrontDoorMotion
  alias: Front Door Motion
  initial_state: 'on'
  trigger:
    - platform: state
	  entity_id: binary_sensor.aeotec_zw100_multisensor_6_sensor
	  state: on
    - platform: state
      entity_id: device_tracker.jsgnfive
	  state: 'not_home'
	- platform: state
	  entity_id: device_tracker.ssgnfive
	  state: 'not_home'
  condition:
    condition: or
    conditions:
    - condition: state
      entity_id: sun.sun
      state: below_horizon
  action:
  - service: notify.sms_a
    data:
      title: FRONT-DOOR
      message: Motion has been detected at the front door.
  - service: notify.sms_b
    data:
      title: FRONT-DOOR
      message: Motion has been detected at the front door.

You need to move the device trackers under conditions, and change “state” on the multisensory to “to”

Ahhh, well let me give that a shot. Thanks.

So I have this now. I tested it and it triggered. I just need to check it in the morning to see if it still triggers with one of us home and then when we are both away.

- id: FrontDoorMotion
  alias: Front Door Motion
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.aeotec_zw100_multisensor_6_sensor
      to: 'on'
  condition:
    condition: or
    conditions:
    - condition: state
      entity_id: sun.sun
      state: below_horizon
    - condition: state
      entity_id: device_tracker.jsgnfive
      state: 'not_home'
    - condition: state
      entity_id: device_tracker.ssgnfive
      state: 'not_home'
  action:
  - service: notify.sms_a
    data:
      title: FRONT-DOOR
      message: Motion has been detected at the front door.
  - service: notify.sms_b
    data:
      title: FRONT-DOOR
      message: Motion has been detected at the front door.

With that, it will trigger if the sun is down, or if either of you is away, if you want it to be when both of you are away, you’ll need to put an and condition above your two devices trackers, or (recommended) put the devices you want in a group, and track the state of that group.

I need to do more such automations. I really need the practice, LOL

yeah, it takes some getting used to, most of my own automations are fairly straightforward, but I took a couple programming classed in college, ad the logic seems to come back pretty easily, which makes spotting flaws in these much easier.
Good luck!

Like this, I assume:

- id: FrontDoorMotion
  alias: Front Door Motion
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.aeotec_zw100_multisensor_6_sensor
      to: 'on'
  condition:
    condition: or
    conditions:
    - condition: state
      entity_id: sun.sun
      state: below_horizon
    - condition: state
      entity_id: group.all_devices
      state: 'not_home'
  action:
  - service: notify.sms_a
    data:
      title: FRONT-DOOR
      message: Motion has been detected at the front door.
  - service: notify.sms_b
    data:
      title: FRONT-DOOR
      message: Motion has been detected at the front door.

That should do it!

Thank you, sir. I very much appreciate your help and patience. I reloaded automations and did not get any errors, so we will see how it all goes.