Automation help with binary alarm sensors

Hello all,

I have two automations that I have written that have been working fine for the longest time, but as of a month ago some different behaviors started happening. I have a Vista 20p alarm panel and I have plugged in a A2DUSB to my Raspberry Pi. I can read all my sensor states and see them as binary sensors and have created automations to turn lights on and off based on the sensors.

What’s happened in the last month is that the lights keep turning on and off when the automation is active. For example, if the garage door sensor goes to on, turn on the garage lights. When that’s active, the lights would turn off and on. I finally figured out that what was tripping it was my motion sensor on my main floor. If someone is home upstairs and I come home, as soon as they move the light turns off, but then the light turns back on again. If they move, it turns off. You can imagine this gets annoying when you are in a very dark garage.

I am stumped as to find a way around this. I tested the sensors and sure enough see the garage door sensor go to OFF when the motion sensor triggers, and then goes back on when that sensor clears. Is there a way to write the automation to ignore a specific event? I’ve had this running for about 5 years and this is suddenly coming up. I am losing my WAF very quickly!

Here’s my alarm panel log. 01 are the doors and 05 is the motion sensor

12/16/2019 6:33:10 PM [0000000110000000----],001,[f70000071001000028020000000000],"FAULT 01 "
12/16/2019 6:33:14 PM [0000000110010000----],008,[f70000071008004c28020000000000],"SYSTEM LO BAT "
12/16/2019 6:33:18 PM [0000000110000000----],001,[f70000071001000028020000000000],"FAULT 01 "
12/16/2019 6:33:19 PM [0000000110000000----],005,[f70000071005000028020000000000],"FAULT 05 "
12/16/2019 6:33:23 PM [0000000110010000----],008,[f70000071008004c28020000000000],"SYSTEM LO BAT "
12/16/2019 6:33:26 PM [0000000110000000----],001,[f70000071001000028020000000000],"FAULT 01 "
12/16/2019 6:33:27 PM [1000000110010000----],008,[f70000071008005c28020000000000],"SYSTEM LO BAT "
12/16/2019 6:33:31 PM [0000000110000000----],005,[f70000071005000028020000000000],"FAULT 05 "
12/16/2019 6:33:35 PM [0000000110010000----],008,[f70000071008004c28020000000000],"SYSTEM LO BAT

        "

Yes it’s possible, add the state of that sensor as a condition to the automation.

It’s much easier to help you if you share the automation and provide the entity_id of the additional sensor you’re wanting to use…

Appreciate the reply. I hope the shared flow below will help. The entity id that is throwing off this automation is the binary_sensor.motion_sensor

[
    {
        "id": "303a5808.0a5f18",
        "type": "tab",
        "label": "Automated Lights",
        "disabled": false,
        "info": ""
    },
    {
        "id": "301c0355.a82b9c",
        "type": "api-call-service",
        "z": "303a5808.0a5f18",
        "name": "Turn on Garage Lights",
        "server": "14d717b0.da6868",
        "service_domain": "light",
        "service": "turn_on",
        "data": "{\"entity_id\":\"light.garage_main_lights\"}",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "x": 700,
        "y": 40,
        "wires": [
            []
        ]
    },
    {
        "id": "1ee05bc7.f23fa4",
        "type": "server-state-changed",
        "z": "303a5808.0a5f18",
        "name": "Garage Door State Change",
        "server": "14d717b0.da6868",
        "entityidfilter": "binary_sensor.garage_doors",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "output_only_on_state_change": true,
        "x": 310,
        "y": 80,
        "wires": [
            [
                "d254ca39.9ab408"
            ]
        ]
    },
    {
        "id": "d254ca39.9ab408",
        "type": "switch",
        "z": "303a5808.0a5f18",
        "name": "on or off",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "on",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "off",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 500,
        "y": 80,
        "wires": [
            [
                "301c0355.a82b9c"
            ],
            [
                "bde63c11.7b622"
            ]
        ]
    },
    {
        "id": "3e1f2256.f0ce0e",
        "type": "api-call-service",
        "z": "303a5808.0a5f18",
        "name": "Turn off Garage Lights",
        "server": "14d717b0.da6868",
        "service_domain": "light",
        "service": "turn_off",
        "data": "{\"entity_id\":\"light.garage_main_lights\"}",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "x": 680,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "bde63c11.7b622",
        "type": "delay",
        "z": "303a5808.0a5f18",
        "name": "",
        "pauseType": "delay",
        "timeout": "30",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 680,
        "y": 100,
        "wires": [
            [
                "3e1f2256.f0ce0e"
            ]
        ]
    },
    {
        "id": "82876baf.90fa68",
        "type": "comment",
        "z": "303a5808.0a5f18",
        "name": "Light changes",
        "info": "",
        "x": 110,
        "y": 40,
        "wires": []
    },
    {
        "id": "14d717b0.da6868",
        "type": "server",
        "z": "",
        "name": "Home Assistant"
    }
]

The above automation was done in nodered. I have another one with sensors that I still have running under the regular automation scripts. The issues within this one is if the door is open, the light turns on, but if the motion sensor goes then the light turns off. As soon as that sensor clears, the light turns back on again.

- id: '1515482266167'
  alias: Outside Lights Back Door ON
  trigger:
  - entity_id: binary_sensor.doors
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - after: sunset
    condition: sun
  action:
  - data:
      brightness: '255'
      entity_id: light.back_porch_light
    service: light.turn_on
  - data:
      brightness: '255'
      entity_id: light.back_porch_light_2
    service: light.turn_on
- id: '1515483677445'
  alias: Outside Lights Backdoor OFF
  trigger:
  - entity_id: binary_sensor.doors
    from: 'on'
    platform: state
    to: 'off'
  condition: []
  action:
  - data:
      entity_id: light.back_porch_light
    service: light.turn_off
  - data:
      entity_id: light.back_porch_light_2
    service: light.turn_off
- id: '1515549462569'

The NodeRed flow would be better asked about in the #third-party:node-red section of the forum.

Do you have another automation that turns the light off if the motion sensor turns off?

Hey Tinkerer. No. The point of this automation is to turn on, and leave on, the light outside if the door opens. The light then turns off when the door closes. I want it to ignore the motion sensor going on an off. When the motion sensor goes on it turns off the light and when the motion sensor turns off, the light is turning back on if the door is open. I just want the light to be on until the door closes.

Well, I can’t comment on whatever you’re doing with Node Red, but Home Assistant is only turning the light off turns it off when binary_sensor.doors goes off. If that’s turning the lights off when the motion sensor turns off, it suggests that that sensor is turning off binary_sensor.doors

Yes. So from what I’ve gathered on what’s going on here, the motion sensor interrupts the reading of the binary_sensor.doors. From the log in my original post the system reports the doors as ON when I open the door, but when motion occurs it flips it to OFF for the doors, most likely because it can only read the one status from the same device. When the motion sensor goes from on to off the doors report on again. I was hoping to find a way to evaluate, or ignore the motion sensor state, while the door closed automation is running.

What I have found as a temporary work around is that I am setting a delay on the automation of 1 minute. This gives me enough time to let the dog out and if I accidentally trip the motion sensor it doesn’t turn off right away. I am hoping to figure out how to make this work though without a workaround!

That sounds like a really rubbish set of sensors… The right approach here is to replace them with something not so broken.

Until then, maybe add a condition check of the motion sensor being off (as mentioned originally)?

condition:
  - condition: state
    entity_id: binary_sensor.motion_sensor_goes_here
    state: 'off'
    for: '00:01:00'

You’d likely need to add the motion sensor as a second trigger, so that it turns off of you’ve closed the door during that minute.