Stuck with an automation rule

Hi,

I have a current rule where by if I leave the house ‘home’ to 'not_‘home’ my lights will turn off. I am using owntracks with it set to major movements so I think thats every 5 mins or 500m something like that any way. The current rule is

alias: Turn off Light
initial_state: True
hide_entity: False
trigger:
  platform: state
  entity_id: device_tracker.phones_rosss_iphone
  from: 'home'
  to: 'not_home'
condition:
  condition: state
  entity_id: input_boolean.light_tracking
  state: 'on'
action:
  - service: light.turn_off
    entity_id: group.bedroom_lights
  - service: notify.pushover
    data:
      title: ""
      message: "Left Home! Lights OFF!"

The issue i’m having is, my place of work is only a 5/7 min walk away from ‘home’. I have a work zone setup within HA to HA knows i’m at work. Issue is that owntracks doesn’t update before I enter the ‘work’ zone so because my automation rule is from ‘home’ to ‘not_home’ the rule isn’t triggering because owntracks isn’t updating quick enough and the zone is going from ‘home’ to ‘work’ due to me being so close to work.

I cant see from the HA website that there is a rule to say if going from home to not home OR Work - Then run my automation. Or has any one got a better way of doing this?

My current way around this is that I have built another automation rule that says if my lights are still on by 7:15am this means that the tracking automation didnt work so turn the lights off regardless of where I am so long as my ‘Work Day’ sensor is True so that this only happens on days im at work and will definitely be out of the house.

You can try omitting the to argument, so it triggers on from home, but to anything. (Not entirely sure that you can have “from” without “to”)

trigger:
  platform: state
  entity_id: device_tracker.phones_rosss_iphone
  from: 'home'

Otherwise just add an additional trigger.

trigger:
  - platform: state
    entity_id: device_tracker.phones_rosss_iphone
    from: 'home'
    to: 'not_home'
  - platform: state
    entity_id: device_tracker.phones_rosss_iphone
    from: 'home'
    to: 'work'

That should work :slight_smile:

1 Like

I believe you can have a from without the to. I did that before but I got spotty performance with it.

I will try the second option…

Will they be separate triggers though, i.e only one of them has to match or do they both have to match before the automation runs? Or will I have to separate those triggers out into two separate automations?

Yes, for triggers, only one of them have to match for the automation to trigger.

Perfect Ill add that in now and try it tomorrow :slight_smile:
Thanks for your help!

1 Like

This worked, just tried it with the multiple trigger :slight_smile:

Thanks again.

Great! :slight_smile: