So, can you tell me more about how you’d use this?
Right now the only attributes with time are last_seen and at_loc_since, neither of which is the current time. They are both timezone aware Python datetime objects. Previously they were always in UTC, whereas with the change I’m working on now they can be in the timezone from HA’s config. (There are also last_changed and last_updated fields of the state object, but those are always in UTC, and also are not really the current time.)
Let’s say I add new attributes that are influenced by the timezone where the device is physically located. Some possibilities that come to mind are adding last_seen_d & at_loc_since_d, which would be the same values as the existing attributes, but in the timezone of the device. That would be easy to add. But then, how would you use them? You could compare them to the corresponding attributes (in UTC or HA local), but as a whole, they are the same (i.e., last_seen and last_seen_d would be the same time, just in different timezones. E.g., if you subtracted them, you’d get a timedelta object whose value is effectively zero.) I suppose you could look at their hour attributes (e.g., last_seen.hour and last_seen_d.hour) to figure out the difference in the timezones in hours. Or you could use the output from their tzname or utcoffset methods; the latter might be more useful. E.g., last_seen_d.utcoffset() would return a timedelta object representing the offset from UTC of the device’s timezone.
Or do you think it might be more helpful to include other new attributes, e.g., maybe the name of the device’s timezone? Or the offset from UTC and/or HA local, as a float?
In summary, I think it would be nice just for display purposes to have the last_seen and at_loc_since values available in additional attributes where they are in the device’s local timezone. It might also be nice to have a new attribute that shows the name of the device’s timezone. But for automation purposes, I’m wondering what would be most helpful. Maybe add the three new attributes I just described (i.e., last_seen_d, at_loc_since_d & timezone_d), and one more attribute with the device’s timezone’s UTC offset as a float.
Thoughts?