Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
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?
Posts: 7763
Threads: 42
Joined: Jun 2015
Reputation:
447
You can use SVG+JavaScript to access HTML5 Geolocation functions , more info here:
http://www.w3schools.com/html/html5_geolocation.asp
Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
(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?
Posts: 7763
Threads: 42
Joined: Jun 2015
Reputation:
447
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.
Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
(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
Posts: 449
Threads: 94
Joined: Jun 2015
Reputation:
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.
Posts: 429
Threads: 100
Joined: Jun 2015
Reputation:
45
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!
Posts: 449
Threads: 94
Joined: Jun 2015
Reputation:
6
nice code
The code string.split doesn't work for me:
time = string.split(time, '.')[1]
Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
(15.11.2016, 15:43)gjniewenhuijse Wrote: nice code
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.
Posts: 449
Threads: 94
Joined: Jun 2015
Reputation:
6
15.11.2016, 16:13
(This post was last modified: 15.11.2016, 16:14 by gjniewenhuijse.)
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
Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
(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 string plit(it produce the table of a few data which before was in one string separated via separator).
Posts: 7763
Threads: 42
Joined: Jun 2015
Reputation:
447
Or you can use a single regexp instead of many splits
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)
Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
(16.11.2016, 07:35)admin Wrote: Or you can use a single regexp instead of many splits
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 solution string:match is powerful tool
|