New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optional displaying the sensors location on the map #12375
Conversation
the sensor is now using the correct attributes (latitued and longitued) which enables them to show up on the map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! This is, however, a breaking change. Could you write a 1-2 sentences describing this in a special "Breaking Change" paragraph in your original PR text?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Showing a sensor on the map needs to be an optional feature because if the sensor isn't around the corner of your location the map will be loaded with a zoom level that everything fits.
We discussed this for the iss
platform already deeply and agreed on using show_on_map
.
Makes sense. The "airvisual" sensor seems to use the same config option. Perhaps it would be beneficial to extract that into |
the configuration will be extended by the optional 'show_on_map' flag. Default is not display the sensor on the map.
@fabaff I've implemented the requested change. It makes sense to give the user an option to exclude the sensor from the map. The documentation will require an update now as well. |
Now it technically has less features than before if If you were to implement it in the same way, and set the default for |
That's a valid point. I will change it accordingly. Not breaking things is good 👍 |
Looks good now. 👍 |
@@ -121,6 +126,9 @@ def device_state_attributes(self): | |||
'lat': self.luftdaten.data.meta['latitude'], | |||
'long': self.luftdaten.data.meta['longitude'], | |||
} | |||
if self._show_on_map: | |||
attr[ATTR_LATITUDE] = self.luftdaten.data.meta['latitude'] | |||
attr[ATTR_LONGITUDE] = self.luftdaten.data.meta['longitude'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If show_on_map
is True
then we will have duplicate entries in the state card (lat/ and long/longitude). It should be either lat and long or latitude and longitude.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK - didn't know that that's a problem. I thought this way it will be always non-breaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a problem but looks wired and could confuse people because the same data is shown twice. [ATTR_LATITUDE]
and [ATTR_LONGITUDE]
are exposed by default. Don't append it to the existing attributes, just make two different dict in regard of the configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, agreed! 👍
@fabaff anything else? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 🐦
Description:
the sensor is now using the correct attributes (latitued and longitued) which enables them to show up on the map.
Breaking changeThe sensor attributes for GPS location used to belat
andlong
. This has been changed tolatitude
andlongitude
respectively.Related issue (if applicable): fixes #
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#4680
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.