Turn on smart plug on camera motion detect AND I'm not at home

Hello there,

I created an automation which ignores my condition (not at home) and I can’t understand why.

I have three cameras. If one of them detects motion (sensor) and the condition “not at home” is true the shelly plugs should be turned on. But my problem is that the shelly plugs are switched on if one of the cameras detect motion ALTHOUGH I’m at home.

I use the Home Assistant app on Android for presence detection and in the HA frontend I can see my smartphone’s position within the home zone on the map.

The automation is created in the GUI and here is the output of automations.yaml:

// ...
- id: '1644213744609'
  alias: Alarm
  description: ''
  trigger:
  - type: motion
    platform: device
    device_id: a69852a9bf788e5308e42b386afe3a89
    entity_id: binary_sensor.tapo_c200_7d44_motion
    domain: binary_sensor
  - type: motion
    platform: device
    device_id: e72328e21b53e692c3951669fc8aebf7
    entity_id: binary_sensor.tapo_c100_d03e_motion
    domain: binary_sensor
  - type: motion
    platform: device
    device_id: 8cfd47b2e95f6690ec2771d9ae73d37b
    entity_id: binary_sensor.tapo_c200_fb74_motion
    domain: binary_sensor
  condition:
  - condition: device
    device_id: 22ba330703c01e43189c066e94cd8c77
    domain: device_tracker
    entity_id: device_tracker.samsung_a32_sm_a325f
    type: is_not_home
  action:
  - device_id: 22ba330703c01e43189c066e94cd8c77
    domain: mobile_app
    type: notify
    message: Alarm - motion detected
  - type: turn_on
    device_id: f11146421ec6d5a750c02d24c0c201c2
    entity_id: switch.shelly_1
    domain: switch
  - type: turn_on
    device_id: 0848e5e092453f0d8cbcc2e9cdb5ccfb
    entity_id: switch.shelly_plug_s
    domain: switch
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - type: turn_off
    device_id: f11146421ec6d5a750c02d24c0c201c2
    entity_id: switch.shelly_1
    domain: switch
  - type: turn_off
    device_id: 0848e5e092453f0d8cbcc2e9cdb5ccfb
    entity_id: switch.shelly_plug_s
    domain: switch
  mode: single

How can I solve this problem?

Thank you.

Should be:

condition:
  - condition: device
    device_id: 22ba330703c01e43189c066e94cd8c77
    domain: device_tracker
    entity_id: device_tracker.samsung_a32_sm_a325f
    type: not_home

Also it’s generally better to trigger using state not device.

1 Like

Thanks, but this is not working. In the GUI I see “unknown condition”.

is_not_home comes from creating this condition in the frontend, so this should be okay. But it doesn’t work.

I’m in the zone. The biggest zone is the default home-zone. I couldn’t change the radius of this so I created a smaller zone inside called “myHome”. I’m in both zones.

The latest HA update changed some of the behavior of devices using device_tracker.

Like rossk mentioned, try it with an entity instead:

condition:
  - condition: state
    entity_id: device_tracker.samsung_a32_sm_a325f
    state: not_home

1 Like

Ah, I understand now. Thanks. It’s working. But the radius of the home zone is very big. As you can see in the image in my last post there are 7 houses in the zone. I want to activate the alarm when I leave my house and go to the neighbours. That’s why I created the smaller zone “myHome”.

Thank you all.

I found a solution in the docs. I could override the radius of the home-zone in configuration.yaml (not possible in GUI). Zone - Home Assistant

And I deleted the smaller self-created zone “MyHome”.

1 Like