Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Geofence-based Presence #343

Open
jjhuff opened this issue Aug 16, 2017 · 17 comments
Open

Integrate Geofence-based Presence #343

jjhuff opened this issue Aug 16, 2017 · 17 comments
Labels
enhancement Indicates new feature requests

Comments

@jjhuff
Copy link

jjhuff commented Aug 16, 2017

I'm in the process of migrating from SmartThings, and I'm missing how easy geofence-based presence detection was on ST. With OH2, I need to setup MQTT, secure it, expose it to the 'net, AND all my family's devices need to have another app installed and configured.

This seems like ideal functionality to just integrate into the Android (and iOS) app.

I'm thinking something like:

  1. A setting to enable it (prompt for location permission at that point)
  2. Select an item to control
  3. Pick a location and radius (unless we can get that from the server?)
  4. Setup the geofence using Android's geofencing (better battery life -- we don't need to completely track the user!)
  5. Use the REST API to update the item when entering/exiting

I'm happy to do the work, but I wanted to discuss the approach, design, concerns before diving in.

@mueller-ma
Copy link
Member

mueller-ma commented Aug 17, 2017

MQTT, secure it, expose it to the 'net, AND all my family's devices need to have another app installed and configured.

I wouldnt know how to do this without exposing some interface to the internet. You will need at least openhab or openhab cloud companion to connect to.

unless we can get that from the server?

Technicaly you could use homekit tags in some way. See comment of @digitaldan #334 (comment)
Suggestion: tags named "hostname-isInRadius1" or "wifiMac-isInRadius1" or similar uniq information.

Use the REST API to update the item when entering/exiting
The easiest solution would be to have a simple switch which is on, when a person is inside the radius. Maybe you can also transmit a timestamp for entered/exited and last update.

Also have a look at #269 which is quite similar

@jjhuff
Copy link
Author

jjhuff commented Aug 17, 2017

I wouldnt know how to do this without exposing some interface to the internet. You will need at least openhab or openhab cloud companion to connect to.
Yup, but fewer is better. If one was only concerned about local usage, the network plugin with an expiration could be an option. I could also see potential of a more limited 'presence' channel offered by openhabcloud.

Technicaly you could use homekit tags in some way. See comment of @digitaldan #334 (comment)
Suggestion: tags named "hostname-isInRadius1" or "wifiMac-isInRadius1" or similar uniq information.
I'm not sure what you're thinking here, but I don't know much about HomeKit or it's OH integration

Also have a look at #269 which is quite similar
Ahh, yes it does!

I'll see what I can put together.

@mueller-ma
Copy link
Member

We should get some thoughts of @digitaldan about this feature in generell and from @kaikreuzer about homekit tags usage in clients

@digitaldan
Copy link
Contributor

Geo tagging would be a great feature for sure.

Select an item to control

Use the REST API to update the item when entering/exiting

The easiest solution would be to have a simple switch which is on, when a person is inside the

I agree this would be a simple solution and best for battery life. I also like that it would be easy to duplicate on IOS and does not require any special configuration.

@jjhuff
Copy link
Author

jjhuff commented Aug 17, 2017

Ok great. I should have a basic PoC working shortly.

Thoughts on how to get the home location (and radius) from the server?

@mueller-ma
Copy link
Member

Would be great if you could implement this in a way that makes it easy to send other stuff to oh

@digitaldan
Copy link
Contributor

thoughts on how to get the home location (and radius) from the server?

I would keep this very simple and just associate entering/exiting a geofence with an existing switch in OH. The user can then decide if that switch is "home".

@digitaldan digitaldan added the enhancement Indicates new feature requests label Aug 26, 2017
@jjhuff
Copy link
Author

jjhuff commented Aug 26, 2017 via email

@mueller-ma
Copy link
Member

@jjhuff Does this rely on Google Maps?

@jjhuff
Copy link
Author

jjhuff commented Aug 26, 2017 via email

@mueller-ma
Copy link
Member

mueller-ma commented Aug 26, 2017

Ok, please keep a option for users without GMaps

@jjhuff
Copy link
Author

jjhuff commented Aug 26, 2017 via email

@mueller-ma
Copy link
Member

Well, I hope #30 will be fixed anytime

@jimtng
Copy link
Contributor

jimtng commented Jan 7, 2024

How about the mobile devices (android, ios) simply sends its lat/long coordinates? This can be disabled by the app, and the interval can be customised. It'd be much like the current reporting of wifi ssid, BT, etc.

The geofencing is up to the rule writers. This way it can check device's proximity against a list of locations, e.g. "home", "school", "local shops", "post office", etc. It's way easier to configure this in the rules.

@mueller-ma
Copy link
Member

The reason I didn't implement it this way is that getting GPS coordinates requires some error handling. Getting the wifi ssid for example always succeeds, but GPS may fail.

@jimtng
Copy link
Contributor

jimtng commented Jan 9, 2024

The reason I didn't implement it this way is that getting GPS coordinates requires some error handling. Getting the wifi ssid for example always succeeds, but GPS may fail.

Could you provide some links/pointers on this? I'm unfamiliar with android development in general. Would it be possible to send it when it can and just log the errors when it couldn't? Is it a matter of permissions?

@mueller-ma
Copy link
Member

You can look at the commit 264682e. Sending GPS coordinates is mostly the same, except for getting the value to send.

There's probably no Android event when the coordinates change, like there is for bluetooth connects. So you can ignore everything related to ACL_CONNECTED in the commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

4 participants