Help needed creating a rule please

Hello all,
I have been struggling to create what I’m guessing should be a simple rule. I have two motion sensors. I simply want a rule that monitors the status of each motion detector and when both of them have not detected motion for five minutes I would like to trigger an action to switch off lights.

No doubt I am just not doing something right I just can’t seem to get this to work.

Help please :pray:

I’d suggest combining the sensors as a group which creates a binary sensor. This is accomplished by using the Helper option.

Then create an Automation using that binary sensor…

Automation Example

description: ""
mode: restart
triggers:
  - entity_id:
      - binary_sensor.your_device
    from: "on"
    to: "off"
    trigger: state
    for:
      hours: 0
      minutes: 5
      seconds: 0
conditions: []
actions:
  - target:
      entity_id:
        - light.your_light
      device_id: []
      area_id: []
    data: {}
    action: light.turn_off
2 Likes

So, I created my automation per your instructions and I would say I am 90% sure I have it right. I have created an entity which is made up of the two motion sensors and I have set the trigger that when that entity goes from an on-state to an off state that it should trigger my actions.

I know this should work and I get it but for some reason it’s just not triggering my actions. I’ve made sure there is no motion in there and I know that with this configuration that you have advised that both sensors need to be in an off or not detecting the state to create the action.

Let’s get that 10% out of the way then.

Show us what you did to create this entity and how it’s referenced in your automation.

Thanks

alias: "Lounge living room and kitchen off "
triggers:

  • trigger: state
    entity_id:
    • binary_sensor.kitchen_living_motion
      from: “on”
      to: “off”
      for:
      hours: 0
      minutes: 1
      seconds: 0
      conditions:
      actions:
  • action: light.turn_off
    target:
    area_id:
    - living_room
    - kitchen
    data: {}
  • type: turn_off
    device_id: ac2fd3790beb4fd842576fb1e26b4c56
    entity_id: e0d07a4950343e7aaa412d43bc0371f0
    domain: switch
  • action: light.turn_off
    metadata: {}
    data: {}
    target:
    label_id: lounge_lamp
  • type: turn_off
    device_id: 67a6bd7c08457f0f3ddd4f6794219b3d
    entity_id: ccfa27e1d04464b82ecd532188f5a0e9
    domain: switch
    mode: restart
  1. Please format your code properly.
  2. Can you confirm that binary_sensor.kitchen_living_motion is a helper group containing only your 2 motion sensors?
  3. Tell us exactly which entities you would like to switch off. Your current automation’s actions are all over the place - it’s trying to switch off by area, by 2 switch devices, and by label.

I suggest you start off simple by only switching off 1 entity in your actions. It will make it easier to check the automation’s trace if something doesn’t work.

2 Likes

Sorry for delay in getting back. I managed to find out what was preventing my rule from running. So when I went to the top right drop down and said to run rule the rule, manually, it would run all the things that I wanted it to run in the list but it just would not trigger from my two motions sensors stopping detecting motion.

Most likely someone will tell me this should work and I would be interested in that but it turns out that the two motion sensors I was using where different brands. One was from smart things and the other was Third Reality. Both would work in their own right separately but not when being used in a rule monitoring for the status of both of them.

I instead connected another third reality instead of the smartthings and immediately, the rule began to work so I’m guessing from the little research I did that it could be to do with the different cool down times on each device perhaps.

For now, my rule is working and I just wanted to say thank you for the help provided here.

Particularly it has been great to learn about creating a helper which is a much better way than the way I had been constructing my rule previously.

Thank you

This should make absolutely no difference when triggering and automation. Using devices from different manufacturers is literally the reason HA exists.

If you’re still interested in fixing the issue, please let us know more about your 2 motion sensors and we’ll help you figure it out.

1 Like