Dynamic Longitude and lattitude

Hi All

I travel Australia fulltime in a RV/Caravan. As a result my longitude and latitude changes frequently. In the caravan i have a pi 3 B+ with Hassio on it. Rather than manually changing my longitude and latitude readings in config.yaml each time i move from one destination to the next i was wondering if it can be auto updated by using the location of my PI, or router, or something else thats physically in the caravan ?

PS: i’m still a noob so not fully up to speed on the lingo yet but happy to research if you can point me in the right direction please

I don’t think so. As far as I am aware the Lat & Lon are set at startup, either from the supplied config or by IP Geolocation if a config is not defined.

It’s an interesting use case and warrants an enhancement request. There is at least one other user (who’s setup is on a yacht) that would benefit for this.

Thanks tom

Id suspect there will be a few out there that could benefit from something like that. I’ll have a look at how to suggest a feature request :smile:

1 Like

FWIW, 0.94 is supposed to have some new UI configuration options, including location, so the idea is definitely that these things can change “on the fly.” See this twitter from balloob. If you look closely, you can see that the location settings are in this new UI, and that there’s a DETECT button that will get the info from the Internet (as @tom_l mentioned.) So when you move, maybe all you’ll need to do is to go to this page and click DETECT. :slight_smile:

I don’t think much of internet detection of location. Auto detection on my system puts me at my isp’s head office hundreds of miles away.

My solution would be to get a usb gps unit. Have a script that gets GPS location and if it has changed, write the new location to configuration.yaml and restart ha.

2 Likes

I’d be very interested in this as well. I’m a live-aboard sailor and being able to update my location automatically would be fantastic. I have gpsd reading data from my onboard GPS devices, so getting the current location is very easy.

Just adding this as a “me too” with real-world interest. :slight_smile:

@Knobee can you share the GPS unit you are using? Was looking at using home assistant for a side project and can’t find much info on a GPS unit that would work.

Frankly they are pretty much all the same. Plug into usb. Read created serial port. Profit.

Well, not really.

I live on a sailboat, and get my GPS from the NMEA 2000 bus. Sure, there are USB GPS devices, but why go easy when you can go hard? :slight_smile:

You made me look that up!

1 Like

I live an a small yacht ans are also very interested. I have a raspberry pi with a GPS HAT that can sends longitude/latitude over mqtt to HASS.

You would use the service homeassistant.set_location which takes lat/long as parameters.

I am unsure whether this requires a restart.

Also you wouldn’t always want to change the location with every small change in lat/long. Perhaps an automation that runs periodically and checks whether you have moved more than, say 20k, it runs the service and (if needed) restarts ha.

Has anyone tried this? I have an RV and have got to the point that I have entities for LON and LAT now, looking for a way to update my Zone for the RV pi HASSIO. I have a second pi that is using an USB GPS unit.

Now you don’t have to change the configuration.yaml file. There is the homeassistant.set_location service which takes latitude and longitude as parameters

latitude: 32.87336
longitude: 117.22743
3 Likes

Can I use an entity for Latitude?

latitude: sensor.nodered_d988b4f8_8db528
longitude: sensor.nodered_37f79a7_16a4066

type or paste code here

You can if you use a data_template for the homeassistant.set_location service.

2 Likes

For those looking here is my working automation to update location:

- id: '001456'
  alias: Update MH Location
  trigger:
  - entity_id: binary_sensor.wyzesense
    from: 'off'
    platform: state
    to: 'on'
  action:
  - service: homeassistant.set_location 
    data_template:
      latitude: >
        {{ states("sensor.nodered_d988b4f8_8db528") }}
      longitude: > 
        {{ states("sensor.nodered_37f79a7_16a4066") }}
    
4 Likes

Thanks everyone above! This topic helped me a lot in figuring out how to get things working. I put together a guide for anyone using a USB dongle with Victron systems that may be useful for anyone else visiting this forum topic in future. There were quite a lot of gaps in my knowledge so it took me way longer to figure everything out.

3 Likes

Hi,
Do you have gpsd running on the same Raspberry Pi as Home Assistant.
If so can you please explain how you did it.