Hi There. now that Hassio release 0.95 is out it’s very exciting for me. I live and travel fulltime in a RV so excited that they introduced the " homeassistant.set_location " service. However… being a newbie i don’t understand how i use it. I’m aware its a new feature so not many would of played with it but can anyone shed some light on how i use it to automatically set my installation location ?
I have a raspberry pi 3 B+ in the caravan / RV which holds Hassio and operates multiple tasmota switches etc. i’m assuming to use the homeassistant.set_location service i need to send it longitude and lattitude data for my RPI ? or do i use google maps, or my router etc? what format does the date need to be in ? i tried using the homeassistant service in developer tools and manually used the json format of
{
“latitude”:" -xx.xxxxxxx",
“longitude”: "xxx.xxxxxxx "
}
which didn’t give me any errors but i also didn’t see any changes to my map or config.yaml file either
I commented out the latitude and longitude lines at the top of the config .yaml then restarted Hassio. Now i see that if i go to " configuration" menu in hassio then “general”, Hassio now looks after my location via a map on that page ( if you comment out the appropriate lines in the .yaml.that is.
with that in mind i dragged the map locator icon and placed my self on the other side of the world ( cost me nothing for that short trip too ) i then went back to developer tools and called the homeassistant.set_location service with the
{
“latitude”:" -xx.xxxxxxx",
“longitude”: "xxx.xxxxxxx "
}
( replacing the xx’s with my coordinates ).
Going back to the general page i see the map now updates and i’m back where i’m meant to be. Awesome. love that… however i’m still not sure how to do it “automatically” without my intervention so still appreciate some guideance thanks
Hi again, another update. I’m trying to use the following to automatically set latitude and longitude values but when i’m testing it in the developer " services" screen i get a error " invalid latitude for dictionary value @ data[‘latitude’] "
The JSON data i’m using is
{
“latitude”: " {{ states.device_tracker.life360_caravan.attributes.latitude }}" ,
“longitude”: " {{ states.device_tracker.life360_caravan.attributes.longitude }}"
}
Am i on the right track here or am i just making bad guesses ? and any help on the error please
…but it seems redundant since your lat/lon source appears to be a device_tracker that’s already integrated into HA (should already update your location automatically).
I also have Home Assistant installed in my RV. I’m using the homeassistant.set_location to set my location based on GPS coordinates. That works as expected and the map on the Configuration->General page updates accordingly.
But the HA timezone does not update based on the new location. I have no time zone specified in the configuration.yaml so that HA would automatically computed the time zone based on my location. I have tried calling homeassistant.reload_core_config hoping this would update the time zone based on the new location, but no luck. I also don’t see a service that I can call to specify a new time zone.
Is there a way to update the time zone within an automation?
I got sick of using my phone GPS to trigger the home location of my caravan so i recently got a USB GPS receiver which i plugged into a different Raspberry Pi to what my Home assistant is running.
I couldn’t get the HA GPSD intergration to work so took a detour to that approach.
From the GPS RPI i then had to send that data to the HA RPI. I did that by installing gpsd on the GPS pi and then wrote the following python code which takes the gpsd data from one pi and sends it via MQTT to Home Assistant on the config / state and attributes topics.
The code i wrote can be found on my Github page if it’s of interest to anyone.
Details on usage are in the docstring (top of the file) outlining the basics of how to get it going. However the general idea is to download the gpsdata.py file to the RPI that has the GPS receiver on it.
On that RPi install…
sudo apt-get update
then
sudo apt install gpsd
and
sudo apt install gpsdclient
Then follow the info in the code such as setting mqtt username and password etc.
Edit your configuration.yaml as per instructions in file
create a automation in HA as per instructions in file
create a cron task as per instructions in file
All going well HA should now see your new device tracker and auto update the home location accordingly.
Hope that helps anyone that got stuck with using the GPSD integration on HA or is running the gps from a different device.