At any rate, this is how you can identify the countries that use a given timezone, like this:
{country for country, timezones in country_timezones.items()
if timezone in timezones}
If you need to do lots of these lookups, you can of course build your own dict to make it faster and simpler:
timezone_countries = {}
for country, timezones in country_timezones.items():
for timezone in timezones:
timezone_countries.setdefault(timezone, set()).add(country)
And now it’s just:
timezone_countries[timezone]
which I posted earlier…
the TZ_INFO should in my original post be populated with the complete list of course, possibly loaded from file
TZ_MATCH would be the attribute.time_zone of the device_tracker listed in some config for the script
the print should the be replaced with has.states.set…
though I would still love to be able to do that, if only for educational purposes, this AD app using the geopy package is so much more precise, it is a bit scary really… many more details than the on the list, and dynamic at that.
Hope this is secure and no eavesdropping is possible.
Anything using a external webserver for any kind of data can theoretically be tracked.
This is the documentation for that lib https://geopy.readthedocs.io/en/latest/#
final question for now:
How can I comment in the configuration file? apparently AD doenst like the # I used, but since I do that all the time in my python scripts, I thought I could here also. Apparently not.
hi, getting back to the App please.
All of a sudden, I see incorrect time_zones popping up. May very well be they were incorrect before and I simply hadn’t noticed, but still.
On 2 of my devices, I see an incorrect time_zone, while the lat/lon are correct, and the address and country etc which is added by the App are all fine and perfect.
Does this App replace the time_zone? Or could it be the life360 has an incorrect time_zone.
it can’t be that when the lat/lon are correct, an incorrect time_zone is displayed (stating another city with a completely different lat/lon set…)
thanks for confirming, Ill check life360 again for erroneous time_zones…
and indeed, my second system, still without the App has the life360 device with the identical erroneous time_zone. Never noticed that before!
so much the better we use the geopy component to check on lat/lon, and not have it do what I originally wanted, check for the time_zones…
update
to be in line with the discussion at the Life360 CC thread: above, read ‘time zone name’ where I wrote ‘time zone’…
@ludeeus
checking the sure code at Geocode would it be possible to also display a distance? its mentioned on the docs. Would be nice to have in the attributes.
seocndly, about the time_zone_names: would the timezone.py in the Geopy GitHub be any good in producing a correct time zone name. If so, could an attribute time_zone_name be added to the App (don’t want to overwrite the existing ‘time zone’ attribute of the device_tracker.
so the App could then add/append the currently added attributes for Address, and add Distance and Time zone name to that?
thanks for having a look!
quite, but it displays … indicating there’s more than displayed in the image… Tried to read through the code, but couldn’t find a list of attributes it creates for ‘address’
I don’t think TZ or distance calculations have a place in a app designed for address information.
Now would be a great time for you to take the next step in your AD venture, by creating two new apps, one to get TZ info, and one to calculate distance
I left an issue on the github, maybe you didn’t notice or it is offline:
would you please check whats up with the app address? I can’t get it to work after updating to Appdaemon 4.0.
discussed about that update here, though even that change from self.get_state(entity=entity) to self.get_state(entity_id=entity) or even self.get_state(entity) doesn’t solve the issue.
could it be the final set_state should be changed also?
thanks for having a look, if you can find a moment.
thanks Petro, figured the bottom-line myself, and added the other change now too. I don’t see any errors logged anymore, but nothing I happening either…
could this then be important after all?
WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.