jesserizzo / envoy_reader

MIT License
37 stars 26 forks source link

Time zone issue - Inverter last reported time #94

Open rct opened 2 years ago

rct commented 2 years ago

Description

Time zone isn't being set correctly on the last reported time for microinverters. The last updated time shown in Home Assistant is always 4 hours ago. My current offset from UTC is -4 hours due to daylight savings time.

The datetime/ISO string as seen by Home Assistant stores is incorrect 2022-05-25 10:55:00+00:00 The date/time in the string looks like it has the correct local time, but that's actually wrong because the time zone component is "00:00" so no offset from UTC. So when that datetime gets localized it shows as 4 hours earlier 06:51.

Since these sensors are disabled by default, most people probably don't notice.

I'm not sure whether the problem is in envoy_reader or the Home Assistant integration. http://envoy.local/api/v1/production/inverters shows the last report date in epoch seconds. So the problem is likely the place that is turned into a datetime or ISO 8601 string.

Expected Behavior

The datetime/time stamp seen in Home Assistant should reflect a somewhat recent (within 5-15 minute) time when the inverters are producing power.

Reproduction

  1. Enable one or more of the disabled inverter last update time sensors.
  2. Check the reasonableness of the timestamp when the inverters are producing power.

Environment

Any additional information about your environment

Home Assistant 2022.05.05 with default/released version of envoy reader.

Additional discussion

The inverter last report time is potentially useful for detecting problems with individual inverters and/or the PLC network.

Related to the Home Assistant integration:

Currently this is implemented as a separate entity/sensor. It might be more efficient if this was included as an attribute of each inverter rather than a separate entity. As two separate entities, I think this will generate two separate state update rows in Home Assistant recorder database.