Cant get camera motion detector to turn off when at home

Can anybody see why this isn’t working?

- id: stop_motion_detect
  alias: 'Stop motion detection when at home'
  trigger:
    platform: state
    entity_id: group.all_phones
    to: 'home'
  action:
    service: switch.turn_off
    entity_id:
      - switch.dafang1_motion_detection
      - switch.dafang2_motion_detection

I’d need to see the configuration of those switches to be able to help.

Im not sure how I can get you those since all switches and sensors are discovered by HA from the camera (Xiaomi Dafang)?

But I might add that the automation for turning on, using the same switches work. Running the automation manually also works. That would point to the entity group.all_phones not being registred as ‘home’, but they are…

Ahhh… then I’m not sure. I’m unfamiliar with that platform, and the docs for it on the Home Assistant site don’t seem to indicate that any switches are made available to turn on/off motion detection.

The next question then is, does group.all_phones every change state to something other than ‘home’? Specifically, have you seen the state of that group be something else and then change to ‘home’?

EDIT: Also, is the automation on?

EDIT2: Another question. Are you sure that something else isn’t turning them right back on after this automation turns them off?

Thanks for your response.

  1. Yes, I checked the status of the group.all_phones when all was away and it was set to Away in the frontend (I guess/hope thats the same as ‘not_home’ in the automation.

  2. Hmm, what do you mean by “automation is on”? Its not commented out…

  3. I don’t know what that could be, but perhaps something in the camera is. Its controlled by MQTT, and perhaps theres something going on while the automation is being run.

All automations can be enabled (on) and disabled (off.) Look at them on the States page. Their state will either be on or off. Also, if the automation is shown in the frontend, they have a toggle to turn them on and off. If they are off, they won’t respond to triggers.

If the automation is on, and the trigger fires (in this case group.all_phones going from any state other than ‘home’ to ‘home’), and the actions work as expected and as verified by manually triggering the automation, then it should be working. You can check the log and/or Logbook to see if the automation has run. You should also be able to look at the history of the switches to see if they went on (or off) when the automation ran.