Hi Petro, I’m using the sensor from Home Assistant app, I did enable it to send my geo location and when I look into that sensor data in Attributes there is Longitude and Latitude.
that’s interesting, my geocode location sensors do not have a latitude and longitude attribute. Can you post a screenshot of yours in the dev tools → states page? I’d be willing to bet that they do not have these attributes. The attribute needs to be exactly latitude
and longitude
and both has to have a value. It cannot be the location
attribute with a comma separated list.
I had to redact some info but the numbers are there
and is Latitude
the same as latitude
?
Well technically no, but how can I change it ? Seems to be hard coded on app side
You’ll have to make a template sensor from that using those attributes.
template:
- sensor:
- name: xyz
state: "{{ states('sensor.my_geocoded_location') }}"
attributes:
latitude: "{{ state_attr('sensor.my_geocoded_location', 'Latitude') }}"
longitude: "{{ state_attr('sensor.my_geocoded_location', 'Longitude') }}"
then use that on your map
Thats fantastic, thanks 100x
no problem
I’m very new to HA and I’m having issue making a template sensor.
Do I put this in sensor.yaml?
template:
- sensor:
- name: xyz
state: “{{ states(‘sensor.moto_g_power_geocoded_location’) }}”
attributes:
latitude:"{{ state_attr(‘sensor.moto_g_power_geocoded_location’, ‘Latitude’) }}"
longitude:"{{ state_attr(‘sensor.moto_g_power_geocoded_location’, ‘Longitude’) }}"
- name: xyz
Then, do I do with configuration.yaml?
Thanks for your help.
it goes in configuration.yaml, and it will only work if your geocoded entities have those attributes. For example, my geocoded entities have different attributes.
I’m sorry, I don’t quite understand what you said.
This is what shows up when I use the template under developer.
I think you should spend some more time learning what each keyword I said means. These are basic fundamentals of home assistant.
If you take the code I produced above, copy and paste them into configuration.yaml, then put your entity_id in the correct spots in the code, it should work. But this will only work if your geocoded entity has the attributes that are used in the code.
Basics fundamentals of home assistant is a cliff dive for some of us without the in depth programing background. I know the basics of C++ but I feel like I’m on a tricycle trying to learn the control of a SpaceX rocket.
Any further assistance or direction would be much appreciated.
That’s not the code I posted, you altered it. Check my code against yours.
Still not the same…
Look at the second copied line
Yep unless that already exists, then it will create xyz_2