Start Vacuum when nobody is home

Hi there

I’m struggling to find a solution to this automation; basically I want hassio to send a notification to my phone when nobody is at home asking if he can start the vacuum.

alias: 'vacuum: nobody home'
trigger:
  - platform: state
    to: not_home
    entity_id: device_tracker.iphone_12_di_luca_2
condition:
  - condition: state
    state: not_home
    entity_id: device_tracker.iphone
action:
  - service: notify.mobile_app_iphone_12_di_luca
    data:
      title: Vacuum
      message: 'Seems nobody is home, can I start cleaning?'
      data:
        push:
          category: activate_vacuum
mode: single

The fact is that basically it isn’t working. I think that the problem is the trigger since when I’m at work and my wife is home it won’t start, perfect. But if she leaves home it won’t start either!
The idea is that only when the last person leave the home, then it should send the notification!

Any solution?
Thanks in advance :grin:

So is it the notification that isn’t working or is it the push-to-start that isn’t working?

The notification is working, the problem is the trigger! It basically never send this notification.
But if I set both person “not_home” and I manually start the automation, then I get the notification and I can trigger the vacuum (there is of course another automation listening to that event)!

Well, the trigger is for device_tracker.iphone_12_di_luca_2 being “not_home” and if that passes then it also is looking for a condition of device_tracker.iphone to also be “not_home”. Is this the intent? They are two different devices, and if the “#2” device doesn’t cause the trigger then the condition won’t be analyzed and if it does cause the trigger and the other phone is not set to “not_home” then your automation won’t run.

Let’s make an example: i leave in the morning (device_tracker.iphone_12_di_luca_2) and my wife (device_tracker.iphone) is home, in this case the automation won’t start since the condition isn’t true, and this is fine for me!
But, if during the day my wife leaves home, I want the automation to start and send the notification, but this isn’t happening!
It can happen also the opposite situation!

It seems like your automation should be set up to trigger when either of the two phones
change to not_home and then use conditions with an AND to determine if both phones are
not_home to then fire the automation. The way you have it set up the automation fires ONCE and that is when YOU leave, and since your wife is home then it stops, but it never fires again because the state hasn’t changed since you left home. This would be more of what you want:

alias: New Automation
description: ''
mode: single
trigger:
  - platform: state
    entity_id: device_tracker.iphone_12_di_luca_2
    to: not_home
  - platform: state
    entity_id: device_tracker.iphone
    to: not_home
condition:
  - condition: state
    entity_id: device_tracker.iphone_12_di_luca_2
    state: not_home
  - condition: and
    conditions:
      - condition: state
        entity_id: device_tracker.iphone
        state: not_home
2 Likes

The above would fire any time you or your wife’s phone goes to “not_home”, and then the condition checks that the other person is also not home and if that is true then the automation actions run.

1 Like

It works! Thanks so much!!! I tried from the developers tool so far, but seems working, tomorrow I test it on field!

Last question, maybe you have the solution. Is it possible to send the actionable notification to both phones? Or it should go only to one person?

Just add another service to the action (and replace what I put there with the name of the second phone entity):

action:
  - service: notify.mobile_app_iphone_12_di_luca
    data:
      title: Vacuum
      message: 'Seems nobody is home, can I start cleaning?'
      data:
        push:
          category: activate_vacuum
  - service: notify.mobile_app_iphone
    data:
      title: Vacuum
      message: 'Seems nobody is home, can I start cleaning?'
      data:
        push:
          category: activate_vacuum
1 Like

Thanks so much for your help!

As a general tip.
I created a boolean : house occupied.
All The phones effect this boolean.

This boolean can then be used for any automation as trigger or condition. This way you need to create the triggers only 1x

1 Like

Yes, can be an option, you can do the same with Groups, this will be “true” when all the person are not_home, correct?

That’s how mine is set up too.

Yeah, should act the same.
Boolean can be manually changed through GUI though.
Im using this for multiple cases.
Day-night
Motionsensor on-off