My automation triggers when i think it shouldn't...what have I done wrong?

Hi,

i am trying to create an automation that activates a script (script.intruder_alarm) when any one of a group of hue lights (group.alarm) is switched on when no-one is home (group.all_devices).

The automation below does call the correct script once any of the lights in group.alarm are switched on, but does so even when we are home. Why is this -what am I not understanding about the condition?

  • alias: “intruder alarm”
    trigger:
    • platform: state
      entity_id: group.alarm
      from: ‘off’
      to: ‘on’
      condition:
      condition: state
      entity_id: group.all_devices
      state: ‘not_home’
      action:
      service: script.turn_on
      entity_id: script.intruder_alarm

Also, I was wondering why sometimes entity_ids and states are surrounded by ‘quotes’ and sometimes not (e.g. https://home-assistant.io/getting-started/scripts-conditions/ )?

Thanks in advance for any help.
Tom

p.s. the formatting has gone weird when I posted - the trigger, condition and action headings are equally indented in my config file.

  - alias: "intruder alarm"
trigger:
    platform: state
    entity_id: group.alarm
    from: 'off'
    to: 'on'
condition:
    condition: state
    entity_id: group.all_devices
    state: 'not_home'
action:
    service: script.turn_on
    entity_id: script.intruder_alarm

aha! thanks very much!
`

Have you watched the state of group.all_devices (use the states dev tool) to confirm that group.all_devices is not, in fact, “not_home”? There can be a lag depending on the method of presence detection you use.

and also, depending on the method of presence detection you are using, you may get false away/not-home states. What method of presence detection are you using?

OK so after a bit more testing I have narrowed the issue down, its seems weird to me:

In isolation, the ‘intruder alarm’ automation in fact works perfectly, and follows the rules as expected. I use nmap scanner and GPS logger for presence detection and it works well.

The issue seems to be with HTTP Post requests from my phone using Tasker. I use tasker to activate a ‘wake up’ script 20 minutes before my alarm goes off, which turns on lights etc. As soon as the http post request is sent, my ‘intruder alarm’ automation activates, even though i am home. I tried activating a different script too, and the same thing happens.

Strangely, if i activate the ‘wake up’ script via homeassistant UI, the ;‘intruder alarm’ does not activate. So it seems to be specific to the http post request.

Even stranger (to me) is that sending other http post requests from tasker (e.g. to toggle a light on and off) does not activate the ‘intruder alarm’. So it seems specific to an http post to turn on a script.

Any ideas why?

When I first tried to use tasker with hass and had it configured wrong it turned everything on under that same domain - is it possible your intruder alarm is also on a script and you might have a similar tasker config error?

EDIT: Here was what I messed up.

Thank you BarryHampants.

That was it. My bad!

SOLVED!