This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

How to integrate a geolocalisation and LM?
#1
Hello,

Have you any experience in the integration of geolocation of mobile phone and using this service in home logic?

Where can I download an information about the location of user's iPhone? Do I have to install some additionall app on iPhone?
Reply
#2
You can use SVG+JavaScript to access HTML5 Geolocation functions , more info here:
http://www.w3schools.com/html/html5_geolocation.asp
Reply
#3
(28.09.2015, 06:15)admin Wrote: You can use SVG+JavaScript to access HTML5 Geolocation functions , more info here:
http://www.w3schools.com/html/html5_geolocation.asp

Thank you for your answer but your solution works only when the User cell phone running and browser running on it and we do not know who is it because there can be more than 1 user logged on LM.

I've meant some solution with app running on iPhone and sending its position regularly to a server. And LM would be downloading this information from a server.

Do you know about some Google APIs?
Reply
#4
Can you explain what kind of solution are you trying to make? There are some Android and iOS apps which allow sending GPS coordinates periodically to a server via HTTP or raw TCP.
Reply
#5
(28.09.2015, 08:07)admin Wrote: Can you explain what kind of solution are you trying to make? There are some Android and iOS apps which allow sending GPS coordinates periodically to a server via HTTP or raw TCP.

Yes, this is what i am searching but do you know some solution where server has some API where you can find HTTP commands to make a communication?

I'd like to use the user's location to e.g. change the mode of HVAC or something else what would be suited and will be a good and comfort solution for my client.

This solution is available in Fibaro. This advertisment shows that function:
https://www.youtube.com/watch?v=K35uFXoa5c0
Reply
#6
(29.09.2015, 07:34)buuuudzik Wrote:
(28.09.2015, 08:07)admin Wrote: Can you explain what kind of solution are you trying to make? There are some Android and iOS apps which allow sending GPS coordinates periodically to a server via HTTP or raw TCP.

Yes, this is what i am searching but do you know some solution where server has some API where you can find HTTP commands to make a communication?

I'd like to use the user's location to e.g. change the mode of HVAC or something else what would be suited and will be a good and comfort solution for my client.

This solution is available in Fibaro. This advertisment shows that function:
https://www.youtube.com/watch?v=K35uFXoa5c0

You can look at the Traccar Client app.
Reply
#7
Here is a ready example for Geolocalization with LogicMachine based on Traccar service:
http://openrb.com/geolocalization-with-l...ar-service

Thanks to buuuudzik for this nice step-by-step guide! Smile
Reply
#8
nice code Smile

The code string.split doesn't work for me:
time = string.split(time, '.')[1]
Reply
#9
(15.11.2016, 15:43)gjniewenhuijse Wrote: nice code Smile

The code string.split doesn't work for me:
time = string.split(time, '.')[1]

If you have some devices and some data received from them this should work. Firstly check errors and alerts.

If this won't be a solution then log the whole response by insert this line:
log(response)

but you must add above line after this code:
Code:
-- decoding received data
response = table.concat(t)
response = json.decode(response)

And please check what is in "Logs" section.
Reply
#10
yes i have data, for example:
[fixTime]
   * string: 2016-11-15T16:04:04.000+0000

But i think the problem is the general loaded string.split function:
Code:
-- split a string into a table
function string:split( inSplitPattern, outResults )
 if not outResults then
   outResults = { }
 end
 local theStart = 1
 local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
 while theSplitStart do
   table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) )
   theStart = theSplitEnd + 1
   theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
 end
 table.insert( outResults, string.sub( self, theStart ) )
 return outResults
end
Reply
#11
(15.11.2016, 16:13)gjniewenhuijse Wrote: yes i have data, for example:
[fixTime]
   * string: 2016-11-15T16:04:04.000+0000

But i think the problem is the general loaded string.split function:
Code:
-- split a string into a table
function string:split( inSplitPattern, outResults )
 if not outResults then
   outResults = { }
 end
 local theStart = 1
 local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
 while theSplitStart do
   table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) )
   theStart = theSplitEnd + 1
   theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
 end
 table.insert( outResults, string.sub( self, theStart ) )
 return outResults
end

What are the symptoms of problem? This function should work especially stringConfusedplit(it produce the table of a few data which before was in one string separated via separator).
Reply
#12
Or you can use a single regexp instead of many splits Smile

Code:
date = '2016-11-15T16:04:04.000+0000'
d = {}
d.year, d.month, d.day, d.hour, d.min, d.sec = date:match('(%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+)')
time = os.time(d)
Reply
#13
(16.11.2016, 07:35)admin Wrote: Or you can use a single regexp instead of many splits Smile

Code:
date = '2016-11-15T16:04:04.000+0000'
d = {}
d.year, d.month, d.day, d.hour, d.min, d.sec = date:match('(%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+)')
time = os.time(d)

Very short and elegant solutionWink string:match is powerful toolWink
Reply


Forum Jump: