Dynamically update Domoticz' location from GPS
Moderators: leecollings, remb0
-
- Posts: 32
- Joined: Monday 18 May 2015 17:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: United Kingdom
- Contact:
Dynamically update Domoticz' location from GPS
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?
-
- Posts: 85
- Joined: Tuesday 06 September 2016 9:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Sorø, DK
- Contact:
Re: Dynamically update Domoticz' location from GPS
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
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
-
- Posts: 32
- Joined: Monday 18 May 2015 17:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: United Kingdom
- Contact:
Re: Dynamically update Domoticz' location from GPS
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!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
Who is online
Users browsing this forum: No registered users and 1 guest