Page 1 of 1
Dynamically update Domoticz' location from GPS
Posted: Monday 30 January 2017 23:58
by Lomax
My use-case is a little different to the typical Domoticz installation, because I'm running it on a houseboat! It would be really nice if there was a way to update the Domoticz lat/lng setting from my GPS receiver, and to log these changes in the Domoticz database (for future reference). This should make it possible to automatically get weather reports for my actual location etc, and perhaps do nifty things with the historical data later. Sound feasible?
Re: Dynamically update Domoticz' location from GPS
Posted: Tuesday 31 January 2017 13:33
by bjacobse
Maybe if the latitude/longitude is stored in domoticz.db then make a script with the following pseudo code that could run every hour:
Read current GPS coordinates from GPS receiver
read gps_file.txt file containing last GPS coordinates
if current GPS == last GPS then quit
else:
stop Domoticz
backup domoticz.db to new backup name increment with 1 in filename
insert current GPS coordinate into domotcz.db (example something like this: sqlite> INSERT OR REPLACE INTO Cars VALUES(4, 'Volvo', 29000);)
Write current GPS coord into gps_file.txt
start Domoticz
exit script
Re: Dynamically update Domoticz' location from GPS
Posted: Tuesday 31 January 2017 22:10
by Lomax
bjacobse wrote:Maybe if the latitude/longitude is stored in domoticz.db then make a script with the following pseudo code that could run every hour
Many thanks, that sounds like a viable approach. Since I've already
started getting into how the Domoticz scripting engine works I might give it a go. Thinking about it though, maybe it's better to have a "virtual sensor" which stores the lat/lng values, and update the Domoticz setting from this. That way I would automagically get historical data, while the actual setting could be updated at a
much slower rate (say once per hour). I just need to figure out how to have a sensor that accepts multiple values. Maybe later this can be used to put a map on the dashboard!