Reliable Alternative To Geofencing

Richdem

Getting the hang of it
Joined
May 12, 2015
Messages
107
Reaction score
39
Hi All,

Over the last couple of years I had tried many things to get Geofencing to reliable work on my Android devices. When I did get it working it seemed hit & miss at best.

Recently I moved my smart home devices over to Home Assistant which is a brilliant and free open source piece of software for controlling a multitude of smart home products. There is a bit of a learning curve but this is one powerful tool. I have now managed to get my Blue Iris profiles to change reliably & consistently based on who is home using presence detection in Home Assistant.

If anyone is using Home Assistant here is basically what I did to get it working:

1) Setup presence detection using my Asus Router to determine who is home/away by what devices are connected (Asuswrt) There are other methods of presence detection but this was the easiest to setup

2) Create 2 switches in Home Assistant for "Home" & "Away" using the following Reddit post ()

These switches basically send an http command to Blue Iris and switch profiles from Home to Away

3) Create a family group with myself & my wife

4) Create an automation that basically calls the switch I created above to change the profile in Blue Iris. By using the family group in the trigger the profile will only change to away when both myself & my wife leave (We use our cell phones as device trackers in HA) When either of us return the profile changes to Home. The really cool thing is that you can also create other automation's to trigger based on whether or not you are at home. I have been using this for about a week now and it has been super reliable. I also found out from another post how to create Android notifications to be sent so now when the profile in Blue Iris changes I get a notification from Home Assistant.

I thought I would share this as it may help you if you are using Home Assistant & Blue Iris. The steps above may seem like they are not for the faint hearted, I have only been using Home Assistant for a couple of weeks and there are tons of good tutorials online and a great support community much like this one

Richard
 
Last edited:

nydegger

n3wb
Joined
Feb 2, 2016
Messages
25
Reaction score
0
Hi Richard,

I am new to Home Assistant, and was hoping to get this working as an alternative to BI Geofence as it is not reliable for me either.
I have tried to follow the instructions and Reddit post but am having no luck.
Can you help?
 

Richdem

Getting the hang of it
Joined
May 12, 2015
Messages
107
Reaction score
39
Hi Richard,

I am new to Home Assistant, and was hoping to get this working as an alternative to BI Geofence as it is not reliable for me either.
I have tried to follow the instructions and Reddit post but am having no luck.
Can you help?
I will try my best to help, I am still very much learning HA

Can you list what you have managed to do successfully and what you cannot get too work?
 

nydegger

n3wb
Joined
Feb 2, 2016
Messages
25
Reaction score
0
Thanks, Honestly I had not heard of HA until I ran across your post.
I ordered the Pi and got it loaded up yesterday.
I have a Linksys Router and was successful in getting HA configured for presence detection and the known_devices.yaml file created. I have edited it and set only the devices I want tracked.
I am also assuming all of the configuration is done thru the configuration.yaml file and automations.yaml, maybe I am wrong.
When I go to "Configuration">"Configuration Validation" I get allot of errors. (I will add them to the bottom)

I have edited the configurations.yaml file with the following:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
secrets: !include secrets.yaml
device_tracker:
- platform: linksys_smart
host: 192.168.1.1
new_device_defaults:
track_new_devices: true
hide_if_away: false
switch:
- platform: command_line
switches:
blue_iris:
command_on: !secret blue_iris_profile_on
command_off: !secret blue_iris_profile_off
friendly_name: Camera Recording

I also added the following to the automations.yaml file:

- alias: Camera Recording on
trigger:
platform: state
entity_id: 'group.people'
from: 'home'
to: 'not_home'
action:
- service: switch.turn_on
data:
entity_id: switch.blue_iris
- alias: Camera Recording off
trigger:
platform: state
entity_id: 'group.people'
from: 'not_home'
to: 'home'
action:
- service: switch.turn_off
data:
entity_id: switch.blue_iris

I also added the following to the secrets.yaml file: replaced XXX with my info.

blue_iris_profile_on: 'curl -k "http://XXX/admin?profile=1&lock=2&user=XXX&pw=XXX"'
blue_iris_profile_off: 'curl -k "http://XXX/admin?profile=0&lock=2&user=XXX&pw=XXX"'


Configuration Validation Errors:
Invalid config for [automation]: [platform] is an invalid option for [automation]. Check: automation->platform. (See /config/configuration.yaml, line 13). Please check the docs at Automation
Invalid config for [automation]: [service] is an invalid option for [automation]. Check: automation->service. (See /config/configuration.yaml, line 13). Please check the docs at Automation
Invalid config for [automation]: [platform] is an invalid option for [automation]. Check: automation->platform. (See /config/configuration.yaml, line 13). Please check the docs at Automation
Integration not found: secrets
Invalid config for [switch.command_line]: expected dictionary for dictionary value @ data['switches']. Got None
extra keys not allowed @ data['blue_iris']. Got OrderedDict([('command_on', 'curl -k "http://XXX/admin?profile=1&lock=2&user=XXX&pw=XXX"'), ('command_off', 'curl -k "http://XXX/admin?profile=0&lock=2&user=XXX&pw=XXX"'), ('friendly_name', 'Camera Recording')]). (See ?, line ?). Please check the docs at Command line Switch


I am not sure how to create the group for myself and wife.

Thanks for your help,
John
 

Richdem

Getting the hang of it
Joined
May 12, 2015
Messages
107
Reaction score
39
Thanks, Honestly I had not heard of HA until I ran across your post.
I ordered the Pi and got it loaded up yesterday.
I have a Linksys Router and was successful in getting HA configured for presence detection and the known_devices.yaml file created. I have edited it and set only the devices I want tracked.
I am also assuming all of the configuration is done thru the configuration.yaml file and automations.yaml, maybe I am wrong.
When I go to "Configuration">"Configuration Validation" I get allot of errors. (I will add them to the bottom)

I have edited the configurations.yaml file with the following:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
secrets: !include secrets.yaml
device_tracker:
- platform: linksys_smart
host: 192.168.1.1
new_device_defaults:
track_new_devices: true
hide_if_away: false
switch:
- platform: command_line
switches:
blue_iris:
command_on: !secret blue_iris_profile_on
command_off: !secret blue_iris_profile_off
friendly_name: Camera Recording

I also added the following to the automations.yaml file:

- alias: Camera Recording on
trigger:
platform: state
entity_id: 'group.people'
from: 'home'
to: 'not_home'
action:
- service: switch.turn_on
data:
entity_id: switch.blue_iris
- alias: Camera Recording off
trigger:
platform: state
entity_id: 'group.people'
from: 'not_home'
to: 'home'
action:
- service: switch.turn_off
data:
entity_id: switch.blue_iris

I also added the following to the secrets.yaml file: replaced XXX with my info.

blue_iris_profile_on: 'curl -k "http://XXX/admin?profile=1&lock=2&user=XXX&pw=XXX"'
blue_iris_profile_off: 'curl -k "http://XXX/admin?profile=0&lock=2&user=XXX&pw=XXX"'


Configuration Validation Errors:
Invalid config for [automation]: [platform] is an invalid option for [automation]. Check: automation->platform. (See /config/configuration.yaml, line 13). Please check the docs at Automation
Invalid config for [automation]: [service] is an invalid option for [automation]. Check: automation->service. (See /config/configuration.yaml, line 13). Please check the docs at Automation
Invalid config for [automation]: [platform] is an invalid option for [automation]. Check: automation->platform. (See /config/configuration.yaml, line 13). Please check the docs at Automation
Integration not found: secrets
Invalid config for [switch.command_line]: expected dictionary for dictionary value @ data['switches']. Got None
extra keys not allowed @ data['blue_iris']. Got OrderedDict([('command_on', 'curl -k "http://XXX/admin?profile=1&lock=2&user=XXX&pw=XXX"'), ('command_off', 'curl -k "http://XXX/admin?profile=0&lock=2&user=XXX&pw=XXX"'), ('friendly_name', 'Camera Recording')]). (See ?, line ?). Please check the docs at Command line Switch


I am not sure how to create the group for myself and wife.

Thanks for your help,
John
I am at work now, I will take a look at my config over the weekend. Are you able to connect to your Blue Iris remotely for starters?
 

nydegger

n3wb
Joined
Feb 2, 2016
Messages
25
Reaction score
0
Thanks....
Not sure what you mean connect remotely, I have the android app which is working fine with the exception of geofencing and am familiar with changing profiles via HTTP.
I also have STUNNEL set up.

Thanks,

John
 

Richdem

Getting the hang of it
Joined
May 12, 2015
Messages
107
Reaction score
39
Thanks....
Not sure what you mean connect remotely, I have the android app which is working fine with the exception of geofencing and am familiar with changing profiles via HTTP.
I also have STUNNEL set up.

Thanks,

John
That's what I meant sorry,

Are you able to connect to Blue Iris remotely. I too use stunnel to connect remotely. There is a bit of a learning curve with Home Assistant but i'll certainly see what I can do to help
 

nydegger

n3wb
Joined
Feb 2, 2016
Messages
25
Reaction score
0
Thanks, you could probably tell, I am not sure what to configure or how.
I was also assuming that everything is configured using the .YAML files and not using the gui's for "automation" or "integrations" etc. Maybe that is where I am going wrong.

Thanks,

John
 

nydegger

n3wb
Joined
Feb 2, 2016
Messages
25
Reaction score
0
Finally got this working after a little research. Below is what I have in the configuration.yaml, automation.yaml and secrets.yaml files. And modifying the known_devices.yaml file to track the desired devices.
Instead of changing the profile, I am changing the schedule. form Home to Away.

Configuration.yaml:
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: example.duckdns.org:8123
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
zone:
# This will override the default home zone
- name: Home
latitude: XXX
longitude: XXX
radius: 50

device_tracker:
- platform: linksys_smart
host: "192.168.1.1"
interval_seconds: 10
new_device_defaults:
hide_if_away: false
track_new_devices: true
switch:
- platform: command_line
switches:
blue_iris:
command_on: !secret blue_iris_profile_on
command_off: !secret blue_iris_profile_off
value_template: '{{ value == "1" }}'
friendly_name: "Camera Recording"

Automations.yaml:
- id: '1561837682145'
alias: Camera Recording On
trigger:
- entity_id: person.bi_users
from: home
platform: state
to: not_home
condition: []
action:
- service: switch.turn_on
- id: '1561837863629'
alias: Camera Recording Off
trigger:
- entity_id: person.bi_users
from: not_home
platform: state
to: home
condition: []
action:
- service: switch.turn_off

Secrets.yaml:
# Use this file to store secrets like usernames and passwords.
# Learn more at Storing secrets
# some_password: welcome
blue_iris_profile_off: '/usr/bin/curl -k "http://192.168.1.XXX/admin?schedule=Home&user=UserName&pw=Password"'
blue_iris_profile_on: '/usr/bin/curl -k "http://192.168.1.XXX/admin?schedule=Away&user=UserName&pw=Password"'
 

Richdem

Getting the hang of it
Joined
May 12, 2015
Messages
107
Reaction score
39
Finally got this working after a little research. Below is what I have in the configuration.yaml, automation.yaml and secrets.yaml files. And modifying the known_devices.yaml file to track the desired devices.
Instead of changing the profile, I am changing the schedule. form Home to Away.

Configuration.yaml:
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: example.duckdns.org:8123
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
zone:
# This will override the default home zone
- name: Home
latitude: XXX
longitude: XXX
radius: 50

device_tracker:
- platform: linksys_smart
host: "192.168.1.1"
interval_seconds: 10
new_device_defaults:
hide_if_away: false
track_new_devices: true
switch:
- platform: command_line
switches:
blue_iris:
command_on: !secret blue_iris_profile_on
command_off: !secret blue_iris_profile_off
value_template: '{{ value == "1" }}'
friendly_name: "Camera Recording"

Automations.yaml:
- id: '1561837682145'
alias: Camera Recording On
trigger:
- entity_id: person.bi_users
from: home
platform: state
to: not_home
condition: []
action:
- service: switch.turn_on
- id: '1561837863629'
alias: Camera Recording Off
trigger:
- entity_id: person.bi_users
from: not_home
platform: state
to: home
condition: []
action:
- service: switch.turn_off

Secrets.yaml:
# Use this file to store secrets like usernames and passwords.
# Learn more at Storing secrets
# some_password: welcome
blue_iris_profile_off: '/usr/bin/curl -k "http://192.168.1.XXX/admin?schedule=Home&user=UserName&pw=Password"'
blue_iris_profile_on: '/usr/bin/curl -k "http://192.168.1.XXX/admin?schedule=Away&user=UserName&pw=Password"'
Sorry it is a long weekend here in Toronto and I didn't get time to get to this. I am glad you got it working. That looks pretty much how I set things up.

It pretty much works flawlessly for myself & my wife. There's a really good home assistant community. You can do so much with that software
 

nydegger

n3wb
Joined
Feb 2, 2016
Messages
25
Reaction score
0
Thanks for your post, I have been so frustrated with the geofence in the app, sometimes it works great and other times it does nothing.
I've had it working for a day and so far it has worked great and consistent.

If you have any of the notify portions you can share that would be great, such as when someone arrive home to send a sms.
I have looked at it briefly but that will be next on my list to get done.
 

Richdem

Getting the hang of it
Joined
May 12, 2015
Messages
107
Reaction score
39
Thanks for your post, I have been so frustrated with the geofence in the app, sometimes it works great and other times it does nothing.
I've had it working for a day and so far it has worked great and consistent.

If you have any of the notify portions you can share that would be great, such as when someone arrive home to send a sms.
I have looked at it briefly but that will be next on my list to get done.
Have a look at the following post, it is called "Android actionable notifications"
Android actionable notifications

It is a little tricky to setup and took me some trial & error getting the software working on my Galaxy S9+
It will create a service in HA which you can then call upon. For instance when the last person leaves the house and Blue Iris switches profiles to "Away" I get a push notification on my phone.

At the end of the automation I call the service notify.android and under the service data I simply add the following:

{
"message": "Blue Iris Armed"
}

Hopefully if you figured out the Blue Iris profile switching it shouldn't be too difficult. If you have IOS devices you may need to ask in the forum for help, we defected from Apple years ago lol
 

nydegger

n3wb
Joined
Feb 2, 2016
Messages
25
Reaction score
0
Hey, thanks for that, I will give it a try when I get back home. Right now I setup to send SMS messages to my phone via gmail when devices leave or arrive home.
I have been having fun playing with this, already setup my garage doors (MYq) and several wifi outlets (VeSync), although the vesync was a challenge, evidentially the internal vesync profile, is broke and had to load some custom py files to get it to work.

Thanks again.
 

Richdem

Getting the hang of it
Joined
May 12, 2015
Messages
107
Reaction score
39
Hey, thanks for that, I will give it a try when I get back home. Right now I setup to send SMS messages to my phone via gmail when devices leave or arrive home.
I have been having fun playing with this, already setup my garage doors (MYq) and several wifi outlets (VeSync), although the vesync was a challenge, evidentially the internal vesync profile, is broke and had to load some custom py files to get it to work.

Thanks again.
You're very welcome,

You are just beginning on your HA journey LOL

I migrated all my smart switches and lights (30 of them) from my Wink Hub 2 to HA using a Zigbee/Z-Wave USB adapter. Everything is local now and way faster than going through Wink's cloud. I have just started experimenting with the Node Red plugin for customized automatons. I find myself wandering around the house wondering what I can automate next lol

Just one thing to bear in mind if you are using a PI, make sure you have a good SD card than can sustain a high number of read/writes. I have heard the SD cards can crap out. If you get really serious about HA you nay find the PI a little under powered. I brought a used HP Elite 8200 Ultra Compact with no HDD for $60. Threw in a 128GB SSD I had lying about and installed Ubuntu Mate then HA in docker and it has been rock solid. I manage it headlessly with Teamviewer. I still use my PI as a NAS and it also runs my VPN server (Open VPN) It really is a marvelous little device
 
Top