What is the best way to show sensor values on a map?
The Map card seems to only support device trackers (and persons), and Geolocation integration seems to be aimed at specific pre-defined services. It seems I could publish the sensor data as a GeoJSON (or GeoJSON Events) feed, and connect that to the map card. Or I can use the entity picture card, or the custom ha-floorplan card with an SVG map.
I think I am looking for the possibility to give sensor entities lat/lon-attributes and then add those entities to a map card, displaying those as a badge in the map: Think agricultural use (farms with IoT-sensors), pizza delivery temperature monitoring (nRF Pizza: Nordic Thingy:91 concept - YouTube), displaying weather observations on a map.
hi Vidar. I spent a hours to find answer how to add sensor on lovelace map.
I find answe in this thread Adding location ( latitude and longitude) attributes to an entitiy - #4 by AlmostSerious
Answer is:
If we have sensor sending data via mqtt, we can’t just add atributes latitude longitude to this sensor entyty. What we need - to create a new template sensor then add the value from the MQTT Sensor to template sensor, and then add other attributes like latitude longitude.
in my configuration.yaml it looks like this :
#first we getting data via mqtt from physical sensor
#it cant contain attributes lat long, so we will pass its data to template virtual sensor
mqtt:
sensor:
- name: "Sergios Temperature"
state_topic: "SOGD01/temp"
#suggested_display_precision: 1
unit_of_measurement: "°C"
#settings above produces in HAOS a soft virtual sensor with name sergios_temperature
#now we creatte a new virtual sensor via template and getting data from mqtt virtual sensor
#adding attributes latitude longitude and you can see sensor on a map
#but it will be visible only after recieving valid data from real physical sensor via mqtt
sensor:
- platform: template
sensors:
sogd1_temp:
unique_id: "sogd1_temp"
friendly_name: "Суғд №1 Температура"
unit_of_measurement: " *C"
value_template: >-
{{ states('sensor.sergios_temperature') }}
attribute_templates:
latitude: 40.3048818
longitude: 69.6518776