Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Recommended Posts

Posted (edited)

This is a forum thread how to integrate external location services to be compatible with the HC3 API and programming model.

The HC3 has locations defined in /api/panels/location.
A location has locationId, name, radius, latitude and longitude. 

The HC3 has users, defined in /api/users
A user has an userId.

The HC3 also has defined user devices as api/devices?type=iOS_device

The map between device and user seems to be the lastLoggedUser property of a device device... (or??)

When a user moves, the HC3 posts a refreshStates event

Please login or register to see this code.


This is translated by the HC3 to a sourceTrigger

Please login or register to see this code.

That we can trigger on in Scenes (or using something like EventLib in QAs)

If we get location data from an external source, we can post a system/refreshStates event that gets picked up by the HC3

Please login or register to see this code.


The HC3 don't deal with latitude/longitude in the events, only locationId, so we need to map the positions we receive to HC3 locations and then post the right type of event, when we are entering or leaving defined locations - and user/device it was related to. The API doesn't seem to be too picky about the device ID (if it is defined or not), but the users needs to be there.

As an example I have a small python app that can be installed with

Please login or register to see this code.

It has a lot of parameters (see fibioslocation --help)
but it can be setup to post iCloud location data for your devices (family and friends) to a QA on the HC3. All data is sent to

Please login or register to see this code.


Below is an example QA that uses that data to keep track if users are entering leaving HC3 defined locations and posts related events using api.post("/events/publishEvent/GeofenceEvent",...)

We setup what devices to track using the QA's quickAppVariables

-- <name>;<model>;<userId>;<deviceId>

-- If <userId> and <deviceId> are numbers, they will be used in the geofence event. Otherwise, the device will be tracked but no events will be published. The <name> and <model> fields are used to match against the name and model coming from the iOS data for the device.

 

Ex. a=Tim’s iPhone;iPhone 14 Pro;4;976

 

Please login or register to see this spoiler.


Please posts improvement or examples of integrating other location services. 

Edited by jgab
  • Like 2

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...