UtilitechAS / amsreader-firmware

ESP8266 and ESP32 compatible firmware to read, interpret and publish data to MQTT from smart electrical meters, both DLMS and DSMR is supported
Other
361 stars 69 forks source link

Timezone offset of DLMS timestamp #809

Open dbeinder opened 2 weeks ago

dbeinder commented 2 weeks ago

I'm not 100% certain if this is a bug in AMS Reader or if I'm reading the spec wrong and it is an implementation fail of my meter ;)

Meter: Kaifa MA309MH4LAT1 Austria/Vorarlbergnetz

Basically I think deviation should be added, not subtracted: https://github.com/UtilitechAS/amsreader-firmware/blob/81b3aacc4d66c0b3c60c616a7303d0e2ec1f2435/lib/AmsDecoder/src/Cosem.cpp#L26-L28

I'm reading the spec to mean that the date/time fields are always local time and deviation is how much needs to be added to get to UTC: image https://github.com/dbeinder/KsmWestKaifaReader/raw/master/spec/Blue-Book-Ed-122-Excerpt.pdf (page 33)

This is a decrypted DLMS frame of my meter, captured at 2024-06-15 20:23:45+02:00: dlms.zip It reports 2024-06-15 20:23:45 in the date/time fields, and a deviation of -120.

The current AMS Reader code turns this into meterTimestamp = 1718490225 (2024-06-15 22:23:45 UTC) instead of meterTimestamp = 1718475825 (2024-06-15 18:23:45 UTC)

gskjold commented 2 weeks ago

Absolutely right, thank you! 07e8 06 0f 06 14 17 2d 00 ff88 80 2024-06-15 SAT 20:23:45.000 -120 (0x80 == daylight saving active)

I think this may be the first meter I've seen where the deviation field is used, most meters report 0x8000