pnbruckner / ha-entity-tz

Home Assistant Entity Time Zone Sensor
The Unlicense
3 stars 0 forks source link

Cache time zone from lat/lon results #6

Closed pnbruckner closed 8 months ago

pnbruckner commented 8 months ago

Determining time zone from lat & lon can take a significant amount of time. Since time zone will not change for same lat/lon values, add a cache of calculated values. To maximize cache hits, round lat & lon to 4 digits each (which is equivalent to about 11 meters, similar to what is done for Nominatim location caching.)

Also, in update_zones, ignore events without data. For some reason, at startup, there are two core_config_updated events fired (with no data), even though the core config has not actually changed. Ignoring these eliminates unnecessary time zone lookups for HA zones.