Automation with multiple entity_id in action

Hey everyone,
I’m trying to create one of my first automations in Hass.io and I’m struggling a little. I’ve read similar posts to what i’m attempting in this forum, but they are a little different or don’t quite get to the issue I’m currently struggling with.

What I’m trying to do is create an automation that turns the motion detection on for all 3 of my blink cameras at a certain time of day. I have it written and running, but when it gets triggered, only 1 of the cameras motion detection is turned on.

Here is the yaml of the version that only turns on 1 cameras motion detection.

  • id: ‘10000000100’
    alias: Activate Cameras
    trigger:
    • at: ‘14:06:00’
      platform: time
      condition: []
      action:
    • data:
      • entity_id: camera.blink_back_yard
      • entity_id: camera.blink_front_yard
      • entity_id: camera.blink_indoor
        service: camera.enable_motion_detection

The only way I’ve been able to get it to work the way I want is if I break it into 3 different automations. Any thoughts or suggestions would be greatly appreciated!

Thanks in advance,
TBD

You are only calling the service camera.enable_motion_detection for the entity camera.blink_indoor. You need to call it for each entity like this:

   - entity_id: camera.blink_back_yard
     service: camera.enable_motion_detection
   - entity_id: camera.blink_front_yard
     service: camera.enable_motion_detection
   - entity_id: camera.blink_indoor
     service: camera.enable_motion_detection

Or, according to the action docs, maybe?

  action:
    service: camera.enable_motion_detection
    data:
      entity_id:
        - camera.blink_back_yard
        - camera.blink_front_yard
        - camera.blink_indoor

EDIT: And for your next topic, please read

Point number 11. :slightly_smiling_face:

5 Likes

Thank you both for your feedback and help. I’ll give those options a try and see if I can get it to work as expected.

As for your comment about reading the “how to help us help you” thread, I did read that but I wasn’t able to get the “code” formatter to work properly. I’ll make sure to play with it longer next time to make sure I get it to display correctly. My apologies.

Thanks again.

1 Like

Ok, so I’ve tried the combinations above and a few others and I still can’t get it to do all three cameras in one action. It loads successfully and I don’t see any errors but I only get one cameras motion detection enabled.

Here is what I have currently…

- id: '10000000100'
  alias: Activate Cameras
  trigger:
  - at: '16:23:00'
    platform: time
  condition: []
  action:
    service: camera.enable_motion_detection
    data:
      entity_id:
        - camera.blink_indoor
        - camera.blink_back_yard
        - camera.blink_front_yard

I did also try…(as suggested, but that was giving me formatting errors in the configurator)

   - entity_id: camera.blink_back_yard
     service: camera.enable_motion_detection
   - entity_id: camera.blink_front_yard
     service: camera.enable_motion_detection
   - entity_id: camera.blink_indoor
     service: camera.enable_motion_detection

Oddly enough, the first example was literally copied from the documentation as you suggested VDRainer, I just changed the info to my information.

That’s because the API call to enable motion detection is internally throttled in the library to prevent your account from being banned by blink. You need a minimum of a 5 second delay between calls (you can do this with scripts) EDIT- and there is no way for you to know that, because it’s not mentioned in the HA docs. I’ll have to add that at some point

With that said, is there any reason you’re trying to individually enable/disable motion detection per camera rather than just arming/disarming the whole system? Note that with Blink, even if motion detection is enabled for a camera, it will only detect motion if the sync module is armed. If you know that already, awesome, just want to make sure it’s clear.

Thanks fronz, that actually makes a lot of sense to what i’m seeing on my end.

As for the comment about the “whole system”, yes I did know that. My outdoor cameras often pick up items being blown around by the wind and I will occasionally turn off the motion detection on a single camera and then forget to enable it again. So, this was an idea I had to make sure they were re-enabled nightly.

My second phase approach was going to be to try “actionable push notifications” that would give me the ability to “snooze” a single camera for say 30 minutes. I was struggling with that implementation as well though as I couldn’t get the “action” buttons to show up on the push notification yet.