I am curious why you need to use a directory or HA rest-api. I do something similar but simply use the switch that homekit turns on as the trigger. Do you do it like that to help preserve the state on restart?
I created a blank / dummy command line switch called home and exposed it to homekit through homebridge. Homekit is automated to turn the switch.home on if i’m home and off when I leave. HA can read the state of that switch to determine if homekit see me home or not.
I don’t see the difference beside a slightly different approach? I wanted an entity in HA that represents my status. This could be great if I want to modify the look of the entity. Also I can trigger the status in HomeKit by switching on/off in HA.
If I understood what you do:
HomeKit turns on a command line switch, HA automation reads the status of this.
What I do:
HomeKit turns on an input boolean, HA automation reads the status of it.
I have tiny single step more that is command line to turn on input boolean in HA.
As long as both ways works, it should matter right?
Please share your setup if somebody wants an alternative method (that maybe is working better or is more stable).
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.
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.
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.
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?
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
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!
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