Homekit location to trigger automations in Home-assistant, using a software switch. Requires no Homekit-hardware!

Hi guys! I really liked this idea, mostly because whatever I do I don’t seem to make device tracking with ping, nmap or snmp reliable…

I don’t get it however. It works brilliant for me, but when I told my kids to do the same it doesn’t any more. The automations in iOS home app doesn’t distinguish between me and my kids.

Am I doing something wrong?

Regards,
Johan

Hi Johan, did you create separate files for your children? HomeKit doesn’t support multiple users for location triggers. (Ios11 introduces this).

What you need is to redo the steps in step one for each of your children and have unique trigger rule in HomeKit for each child. The scripts above should be named uniquely also.

This is a really good idea. Since I’m already using homebridge-homeassistant, I actually ended doing what RobDIY suggested, and created an input_boolean in HA that is exposed in HomeKit. (With the REST api setup, I had 2 switches in HomeKit, and if I hit the cmd switch, both turned on).

I set up an automation in the Home App to switch the boolean to on when I arrive home, and off when I leave. So far it is working great. Now I want to set up the same for my wife.

My question is this. In the Home App, my wife isn’t able to set up automations, since she is not the ‘owner’ of the HomeKit setup. Does the Eve app allow other users to set up automations based on their location?

EDIT: I just saw you answered that question in the previous post… iOS11. Whoops!

I prefer to be able to set the state in home-assistant, especially for restart. I think it’s great when using appdaemon too.
Anyway, it’s the same logic and really doesn’t matter.

As I said, you don’t need iOS 11. You can just trigger different inout_boolean.:

  • X’s home app triggers X_isHome
  • Y’s home app triggers Y_isHome

Then you can put both input_boleans in a group and set rules based on the state of the group. If somebody is home, then the group is set to on. If both is away, the groups state is off.

Glad you liked it!

1 Like

You are right. I realized that I needed to grant my wife the ability to edit in the Home app. Now she has the ability to create automation, and we got a new trigger added for her.

So far it is working well, and seems much faster than other methods.

You can use the same concept to control any homekit device from HA. I use it for a schlage sense lock.,

or magnet sensor

Yes, I wrote that a couple of post up. I’m using it for my elgato eve door sensor.

No, I actually followed RobDYIs method. But I think you’re correct, that doesn’t really work for more than one person per “Homekit home”…

Thanks, will try your method during the weekend!

/Johan

I just setup everything with the input_boolean method too… need to try how well it works. In any case, why you think it won’t work for more than one person per HomeKit home?

Ios10 doesn’t support multi-user automation, it’s a limitation in ios10. It’s fixed in ios11.

If you have ios10 and multiple users, use this:

ah! I’m on iOS11 already… checking the Home.app from Apple it was letting me create multiple automations with different users so I was wondering why it won’t work hehe

Hmm, I don’t have ios11 but it should work according to the news from WWDC.

It’s a beta so hopefully they’ll fix it soon.

Anyway, my method would work in ios 11 too :wink:
Just follow the steps in the link above.

I’ve followed the other method but this command is not working

curl -X POST -H "Content-Type: application/json" -d '{"entity_id":"input_boolean.USERishome"}' "http://IP-to-HA:8123/api/services/input_boolean/turn_on"```

My HA setup has an API password so I get a 401: Unauthorized error. How do you add the password to this command? 

Thanks!

Ok I found the answer here https://home-assistant.io/developers/rest_api/

So from the original command you have to add

-H "x-ha-access: PASSWORDHERE"

Entire command would look like this

curl -X POST -H "x-ha-access: PASSWORDHERE" -H "Content-Type: application/json" -d '{"entity_id":"input_boolean.USERishome"}' "http://IP-or-host:8123/api/services/input_boolean/turn_on"

Yep, exactly.

@RobDYI please share your config

I can do it, I’m testing both approaches:

input_boolean.yaml

jonatanhome:
    name: Jonatan home
    initial: on
    icon: mdi:home

Then on Home.app (or other app that uses your HomeKit info) create 2 automations that turn on the switch when you arrive home and turn it off when you leave

3 Likes

Homebridge install instructions are here so that HA is exposed to homekit.

1 Like

Could you (or anyone else) show me you config.json file, I how you have the code for more than 1 person?

I had it running OK just for myself, but now I’ve added a second person their switch doesn’t work right :neutral_face:

Here’s the code I’m using, hoping I just have the formatting wrong or something

{
   "bridge":{
      "name":"Homebridge",
      "username":"WHATEVER",
      "pin":"031-45-154",
      "port":51826
   },
   "accessories":[

   ],
   "platforms":[
      {
         "platform":"cmdSwitch2",
         "name":"CMD switch",
         "switches":[
            {
               "name":"Jono is Home",
               "on_cmd":"/home/pi/.homebridge/JonoHome.sh",
               "off_cmd":"/home/pi/.homebridge/JonoAway.sh",
               "state_cmd":"/home/pi/.homebridge/JonoStatus.sh",
               "polling":"true"
            },
            {
               "name":"Jancy is Home",
               "on_cmd":"/home/pi/.homebridge/JancyHome.sh",
               "off_cmd":"/home/pi/.homebridge/JancyAway.sh",
               "state_cmd":"/home/pi/.homebridge/JancyStatus.sh",
               "polling":"true"
            }
         ]
      }
   ]
}

BTW, I added my HA password in a slightly different way (which is the same that I use for some IFTTT recipes triggering Home Assistant lights, scenes, scripts etc. via Alexa and Google Home).

curl -X POST -H "Content-Type: application/json" -d '{"entity_id":"input_boolean.jono_home"}' "https://PI-IP-ADDRESS:8123/api/services/input_boolean/turn_on?api_password=MY-HA-PASSWORD"

Age you adding a special rule and automation in each device?

See post 14 for more info. Each device to be needed to set with own rules and automations. This is due to that ios10 doesn’t support multi-user rules.

This will supported in ios11.