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

The problem is I don’t know how to enter the homebridge-container and give curl access to it.

It’s usually a folder in the home-directory or somewhere else. Doesn’t the manual specify where they are stored?

Does anyone else see the “Cannot add a bridged Accessory with the same UUID as another bridged Accessory:” error in the logs after a restart of the home bridge service? I’m using HASSIO and am using the Homebridge add-on (yes I too have the curl problem but still looking into that).

To fix I have to delete the cachedAccessories file, but it does this everytime I restart home bridge.

rm accessories/cachedAccessories

[9/3/2017, 7:09:51 PM] Loaded plugin: homebridge-cmdswitch2
[9/3/2017, 7:09:51 PM] Registering platform ‘homebridge-cmdswitch2.cmdSwitch2’
[9/3/2017, 7:09:51 PM] —
[9/3/2017, 7:09:52 PM] Loaded plugin: homebridge-homeassistant
[9/3/2017, 7:09:52 PM] Registering platform ‘homebridge-homeassistant.HomeAssistant’
[9/3/2017, 7:09:52 PM] —
[9/3/2017, 7:09:52 PM] Loaded config.json with 0 accessories and 2 platforms.
[9/3/2017, 7:09:52 PM] —
[9/3/2017, 7:09:52 PM] Loading 2 platforms…
[9/3/2017, 7:09:52 PM] [HomeAssistant] Initializing HomeAssistant platform…
[9/3/2017, 7:09:52 PM] [HomeAssistant] Fetching HomeAssistant devices.
[9/3/2017, 7:09:52 PM] [CMD switch] Initializing cmdSwitch2 platform…
[9/3/2017, 7:09:52 PM] Loading 0 accessories…
[9/3/2017, 7:09:52 PM] [CMD switch] Initializing platform accessory ‘User isHome’…
/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:256
throw new Error("Cannot add a bridged Accessory with the same UUID as another bridged Accessory: " + existing.UUID);
^
Error: Cannot add a bridged Accessory with the same UUID as another bridged Accessory: 3dd34efe-097b-4b8b-a688-352f08cd38d6
at Bridge.Accessory.addBridgedAccessory (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:256:13)
at Bridge.Accessory.addBridgedAccessories (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:282:10)
at Server._handleRegisterPlatformAccessories (/usr/lib/node_modules/homebridge/lib/server.js:437:16)
at Server. (/usr/lib/node_modules/homebridge/lib/server.js:36:10)

The manual says nothing. :frowning:

I’m almost giving up on Hassio for now and going back to a Python Virtual Env install on a Debian.

@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!!!