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

Thanks, I’ll give it another try.

Thank you Jonatan, I’m testing it today.

I must say that I found this to be working pretty good and is very reliable. Well worth to get it working.

When I try to save the file with input_boolean in Home assistant I get this error, I appreciate any help.

2017-08-23 00:51:56 ERROR (SyncWorker_0) [homeassistant.util.yaml] YAML file /Users/memo/.homeassistant/configuration.yaml contains duplicate key “group”. Check lines 63 and 85.
2017-08-23 00:51:56 ERROR (SyncWorker_0) [homeassistant.util.yaml] YAML file /Users/memo/.homeassistant/configuration.yaml contains duplicate key “automation”. Check lines 64 and 119.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up introduction
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain introduction took 0.1 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up recorder
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up http
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain recorder took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain http took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up history
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up websocket_api
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up api
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain history took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain websocket_api took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain api took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up frontend
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain frontend took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up sensor
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up group
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up sun
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up updater
2017-08-23 00:51:56 ERROR (MainThread) [homeassistant.config] Invalid config for [input_boolean]: [USERishome] is an invalid option for [input_boolean]. Check: input_boolean->input_boolean->USERishome. (See /Users/memo/.homeassistant/configuration.yaml, line 14). Please check the docs at https://home-assistant.io/components/input_boolean/
2017-08-23 00:51:56 ERROR (MainThread) [homeassistant.setup] Setup failed for input_boolean: Invalid config.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up discovery
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up binary_sensor
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain sensor took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain group took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain sun took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain updater took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain discovery took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up zone
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain binary_sensor took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up conversation
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up config
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up tts
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up logbook
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up media_player
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain zone took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up light
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up switch
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up automation
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up zeroconf
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain conversation took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain config took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain tts took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain logbook took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain media_player took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up device_tracker
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain light took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain switch took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain automation took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain zeroconf took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain device_tracker took 0.0 seconds.
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setting up ios
2017-08-23 00:51:56 INFO (MainThread) [homeassistant.setup] Setup of domain ios took 0.0 seconds.
Failed config
input_boolean:
USERishome: [source /Users/memo/.homeassistant/configuration.yaml:15]
icon: mdi:home
name: Home

General Errors:
- Setup failed for input_boolean: Invalid config.

Successful config (partial)
input_boolean:

Can you share all the code you use?

Has anyone managed to configure this on Hassio?

Well I am wondering whether it’s possible to use a simple MQTT “dummy” sensor.

You can create as much MQTT sensors as you wish without dealing with command line stuff and shells and scripts.

Is the homebridge plugin fixed for hassio? If so I can’t see why it wouldn’t work.

This one is working fine.

I just don’t know the right place to put the scripts for cmdswitch2.

Isn’t there any documentation stating where to put the config-file?

I mean the scripts for “on_cmd”, “off_cmd” and “state_cmd”.

No matter where I put them, there’s always a ‘not found’ error.

Do you have ssh to hassio? Can you write
ls /path-to-cmds/

Also check that homebridge hass correct permissions for that path

I moved the scrips to /config/homebridge, now they can be found

# ls -la /config/homebridge
total 32
drwxr-xr-x    4 root     root          4096 Aug 26 09:10 .
drwxr-xr-x    7 root     root          4096 Aug 26 09:22 ..
drwxr-xr-x    2 root     root          4096 Aug 26 09:21 accessories
-rw-r--r--    1 root     root          1002 Aug 26 09:18 config.json
-rwxr-xr-x    1 root     root           189 Aug 23 16:41 mbonani_away.sh
-rwxr-xr-x    1 root     root           188 Aug 23 16:41 mbonani_home.sh
-rwxr-xr-x    1 root     root           142 Aug 23 16:42 mbonani_status.sh
drwxr-xr-x    2 root     root          4096 Aug 25 20:52 persist

But now I have an error with curl

[8/26/2017, 9:21:28 AM] [CMD switch] Initializing cmdSwitch2 platform...
[8/26/2017, 9:21:28 AM] Loading 0 accessories...
[8/26/2017, 9:21:28 AM] [CMD switch] Initializing platform accessory 'Mauricio is Home'...
[8/26/2017, 9:21:28 AM] [CMD switch] Failed to determine Mauricio is Home state.
[8/26/2017, 9:21:28 AM] [CMD switch] /config/homebridge/mbonani_status.sh: line 1: curl: not found

curl exists

# which curl
/usr/bin/curl

I changed curl to /usr/bin/curl in the scripts but

[8/26/2017, 9:29:39 AM] [CMD switch] Initializing cmdSwitch2 platform...
[8/26/2017, 9:29:39 AM] Loading 0 accessories...
[8/26/2017, 9:29:39 AM] [CMD switch] Initializing platform accessory 'Mauricio is Home'...
[8/26/2017, 9:29:39 AM] [CMD switch] Failed to determine Mauricio is Home state.
[8/26/2017, 9:29:39 AM] [CMD switch] /config/homebridge/mbonani_status.sh: line 1: /usr/bin/curl: not found

The scripts work fine where they are

# pwd
/config/homebridge
# ./mbonani_status.sh 
{"attributes": {"friendly_name": "Mauricio at home"}, "entity_id": "input_boolean.mbonani_home", "last_changed": "2017-08-26T11:57:19.829657+00:00", "last_updated": "2017-08-26T11:57:19.829657+00:00", "state": "on"}

Can you ssh to hassio and try
curl google.com

I think curl should be placed in the homebridge container. I haven’t used hassio, but in my server where I use docker and want to install a new script, I do it to the container.

Try this

cp /path-to/curl /path-homebridge-container-root/

And when running the curl-command:
/path-homebridge-container-root/curl yoururl-etc

core-ssh:~# curl google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

I definitely need to learn how to manage docker and containers. This still confuses me.

BTW, a change in the homebridge container wouldn’t be overwritten in an addon update?

The curl response tou pasted suggest you have curl working in your system, but the homebridge-container doesn’t have access to it.

I don’t how similar hassio is to a docker-setup, but the file should be there even if you update the container. I don’t upgrade homebridge often though, if it’s stable why fix it?

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.