Might be a silly question, but would it be possible to track devices and show in which country they are. Can’t do that with a Zone, since that would need lat/lon settings.
Since my family is often abroad for professional and study purposes, Id like to show lets say the flag of the country they’re in.
You’d need to use, say, Google Maps travel time, and extract the country from the attributes, then use that as a lookup key somehow. I found however that if it can’t work out directions, you don’t always get the start address.
fyi, all my life360 trackers show the current timezone they’re in. Seems very simple for us humans to immediately know the someone is in Europe/Rome the country is Italy, but how to extract that from a computer…
still this wouldn’t lead me to the countries would it?
I’d now have to create a crazy long list of flag_pictures
say I am here:
"time_zone": "Europe/Vatican",
and wanted to use the Italian flag, I would need to convert all these italian timezones to the same flag… and that for each countries existing timezones. or am I missing something.
the link I provided apparently enables the timezone-country conversion, which would allow for a sensor based on the timezone, and then allow me to use your suggestion, based on that sensor.
Yes, you’d need a long set of files, named for the timezone. It’s that or a long, long, long, long set of elif statements.
Naming files for the timezone means it’s visually sane too. You’ll have a folder for Europe/ and then a bunch of files inside. You can even use symbolic links to create the duplicates. So you could create an image in Europe/ called Italy.png and then ln -s Italy.png Vatican.png; ln -s Italy.jpg Rome.png (and so on).
you’d have to help me here, Ive never done symbolic links in Hassio templates…could you give me 1 example how that should be written please?
secondly, and please indulge me, is there truly no way available of iterating over this list Python list of country codes, names, continents, capitals, and pytz timezones · GitHub , look for the attribute time_zone of a given device_tracker and simple report the country_code or name that goes with it. Seems to be completely feasible, and the list isn’t that horrifically long is it? The list seems made for these kind of searches?
Many Ui-lovelace.yaml files are a tenfold of it
it would be a second best way, only topped by an internal python function, which I woud have hoped this:
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]
could have been…please let me carefully ask @pnbruckner and @petro to join in and have a look?
Well, the link wouldn’t be in the template, what I posted there is how you create the files themselves. All of that is entirely out of Home Assistant.
You could certainly do what you’re proposing in HA, I just don’t know how - and for me it’s easier and faster to handle it in the OS. That too makes everything faster, there’s no fancy lookup.
sure, I did before, and thought I complied completely. And carefully selected my fellow members, because there’s a frequent exchange of ideas , advice, testing and helping out going on. Not a careless tagging at all.