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

@mbonani Don’t give up hope yet, I have the same problem and am determined to find a fix. :slight_smile:

I’ve added a few commands to the status.sh script to try and work out where the environment runs. e.g.

whoami >> /config/homebridge/username.txt
echo $PATH >> /config/homebridge/output.txt
echo $HOME >> /config/homebridge/output.txt
echo $USER >> /config/homebridge/output.txt
ls /usr/bin >> /config/homebridge/output.txt
hostname -i >> /config/homebridge/output.txt

The ls output shows there’s no curl command, and interestingly the “hostname -i” shows a very different IP to the one shown at the command prompt after SSH’ing to hassio.

I don’t understand the architecture or how docker works (in general and in hassio), but there will be a solution to this somewhere!

b.t.w, as you also have hassio, if you restart home bridge and look at the logs (all within the Homebridge section of Installed Addons), do you have the same error I see in my previous post?

Yes, I have the same error when I restart the homebridge addon. Deleting the cachedAccessories file is the only way to have it working again.

Good news!

Good news indeed!!

Now onto the next problem… UUID duplication.

Please add this info there too.

I’ve posted a new issue on homebridge (https://github.com/hassio-addons/addon-homebridge/issues/13) and cmdswitch2 (https://github.com/luisiam/homebridge-cmdswitch2/issues/8#issuecomment-327000803) with the hope that either developer will be able to help.

1 Like

So I’m using the Eve app, but I must be a bit confused on how to have the Eve app set the input boolean as away. Eve only works when I am at my home - while my iPhone is on my WiFi. As soon as I leave and I am on the cellular network, Eve can no longer communicate back to my input_boolean to turn it off to signify that I am no longer home.

I think I’m missing something here :confused:

Just looking into this as everything else ive tried is unreliable. Why not just expose a switch and create an utomation to flip that switch on when home/away? then an automation to set home within ha?

This is what I am doing. I don’t have anything enabled on homebridge except the HA plugin, and a couple input booleans for my wife and myself (among other devices) exposed via HA. I didn’t find it necessary to do anything with the command line. It has been by far the most reliable presence detection method I’ve tried. Right now, I’ve had to make my wife an admin of the Home setup, and setup the geofence for her switch from her phone manually. But in iOS11, is should be possible to set up the automation for other home members from one device.

1 Like

Nice I’m struggling. Maybe you could help. I’ve got homebridge running and it looks like it sees all my sensors and everything even though I only have input Boolean specified. Then how are you using an input Boolean to change home away status in ha. If you don’t mind sharing your config JSON and how your changing that you would be my personal hero lol

edited to add: I’m not really using home/away in HA. You can set up template sensors to mimic a home/away status, but really it is the on/off status of the input booleans/group referenced below.

Flipping the switch is done in the Home app (or Eve, if you are using that). In the Home app, these are the steps:

  1. Tap on Automation, and then the plus button to add a new automation
  2. Select the when I Arrive option
  3. Choose home as the location, and on the next screen, select your input boolean. On the last screen select to turn it on
  4. Follow the same steps to create a when I leave automation, but at the end, turn off the switch
  5. Repeat for each person in the home on their iOS device (you may have to make them an admin for your your Home setup

In HA, since there are 2 of us, I placed both input booleans in a group. When one boolean is on, the group is on. When both booleans are off, the group is off. I then have my presence defendant automations triggered off the group.

Hope that helps. There’s nothing too special in my home bridge config.json, but here it is just in case

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:30",
        "port": 46842,
        "pin": "redacted"
    },

    "description": "This configuration is for HomeAssistant.",

    "platforms": [
        {
            "platform": "HomeAssistant",
            "name": "HomeAssistant",
            "host": "redacted",
            "password": "redacted",
            "supported_types": ["alarm_control_panel","cover", "device_tracker", "fan", "input_boolean", "light", "lock", "scene", "switch"],
            "logging": true
        }
    ]
}
1 Like

I have to do this. The HA app is rubbish at location services.

thank you! I got all that in and automations that work to turn on and off the IB. Now what are you using for device tracker in your configuration.yaml ?

I have own tracks as the platform now, but disabled mqtt so i can rely on this. Im not sure what to put into platmor, if i can specify an input boolean there? Ive searched all over and that seems to be skipped so im guessing its easy im just not catching it…

Think I’m being dum. Leave owntracks as platform and remove the mqtt config so my device stays there then use an automation to set state to the device to home or away. Correct? I’m Gussie g the automation needs to say action - event enter - phone Id .? Imma try here shortly.

I’m not actually using a device_tracker. Just using the booleans. I set a template sensor to say home/not home (example below). But that is just for aesthetics.

  - platform: template
    sensors:
      mike_home_sensor:
        friendly_name: 'Mike'
        value_template: >
          {% if is_state('input_boolean.mike_home', 'on') %}
            home
          {% else %}
            not home
          {% endif %}
1 Like

thank you!!!

Glad to help. You don’t have to use the template in automations. I use the group that contains my wife and I’s booleans as the trigger, but you could just as easily use the state of an individual boolean. Here is an example

- alias: 'Arm Alarm when noone is home'
  trigger:
    - platform: state
      entity_id: group.home_booleans
      from: 'on'
      to: 'off'
  action:
    - service: alarm_control_panel.alarm_arm_away
      entity_id: alarm_control_panel.security
      data:
        code: !secret pin
1 Like

How does this set your status to home though? doesnt a device tracker have to report home?

Step 4 is what I don’t get. Once I leave, my iPhone is no longer connected to my HA homebridge and it can’t turn off the switch (I know, I’m dense :slight_smile: )

Thanks,
Tom

you need an apple tv for homekit automations to work outside

1 Like