Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Daylight Saving Time (DST) transition #104

Closed
dennissiemensma opened this issue Mar 23, 2016 · 7 comments
Closed

Support for Daylight Saving Time (DST) transition #104

dennissiemensma opened this issue Mar 23, 2016 · 7 comments
Milestone

Comments

@dennissiemensma
Copy link
Member

Coming sunday 27th of March is the first DST transition since I've started this project. I've used Django's timezone aware features, but I still have to check:

  • Whether MySQL respects the transition. Or not.
  • What will the DSMR meters do, will they actually apply DST or just keep going at the current rate? I expect they will respect the transition, as they are connected to the Internet anyway (using GPRS).

Since we will be skipping an hour, in the worst case all data of that hour will be lost. Next winter will be more interesting, as the hours drops backwards, potentially overriding existing data when not respecting timezones (MySQL).

@dennissiemensma dennissiemensma modified the milestones: 1.0.0, 0.16 (RC 2) Mar 23, 2016
@dennissiemensma
Copy link
Member Author

Too bad that it seems to crash the datalogger. Honestly, I was expecting the backend to fail, not the datalogger. The meters are DST aware it seems, but I got no clue why the datalogger crashes.

@dennissiemensma
Copy link
Member Author

 File "/home/dsmr/dsmr.git/dsmr_datalogger/management/commands/dsmr_datalogger.py", line 27, in run
    dsmr_datalogger.services.telegram_to_reading(data=telegram)
  File "/home/dsmr/dsmr.git/dsmr_datalogger/services.py", line 137, in telegram_to_reading
    value = reading_timestamp_to_datetime(string=value)
  File "/home/dsmr/dsmr.git/dsmr_datalogger/services.py", line 160, in reading_timestamp_to_datetime
    year=2000 + int(timestamp.group(1)),
AttributeError: 'NoneType' object has no attribute 'group'

@dennissiemensma
Copy link
Member Author

Aah I see, the last character in the timestamp marks the DST period. I was wondering what the W was meant for. Now it's ending with a S, crashing my regex's.

@dennissiemensma
Copy link
Member Author

Fixed in #105. More checks tomorrow, datalogger is the most important one..

@dennissiemensma
Copy link
Member Author

For the next summer to winter transition I will have to signal pytz whether the input time is with or without DST, as the same hour is read twice. It wouldn't have been a problem when the meters used UTC as output, but apparently for some reason they choose not to do so.

@dennissiemensma dennissiemensma changed the title Check Daylight Saving Time (DST) Support for Daylight Saving Time (DST) transition Mar 28, 2016
@dennissiemensma
Copy link
Member Author

Fixed it in the timestamp input reader, which now both manually sets DST to the W/S value and also returns the timestamp in UTC.

It already was timezone-aware, but Django formatted it to +1 or +2. PostgreSQL shouldn't care, as it already keeps track of tzinfo, but MySQL might be bugged by it.

@dennissiemensma
Copy link
Member Author

Merged. Next winter's DST transition should be no problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant