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

timestamp sensor 32-bit? year 2038 overflow? #85

Closed
scottcopus opened this issue Aug 5, 2023 · 4 comments
Closed

timestamp sensor 32-bit? year 2038 overflow? #85

scottcopus opened this issue Aug 5, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@scottcopus
Copy link

Sorry, I'm new to BTHome and just want to make sure the timestamp is futureproofed.

Is the timestamp sensor a 32-bit or 48-bit number?
https://bthome.io/format/ says "uint48 (4 bytes)" which seems ambiguous, unless I'm misunderstanding the info.

If it's only 32-bit, then it'll overflow in 2038! https://en.wikipedia.org/wiki/Year_2038_problem

BTW, it might be a good idea to add webpage #anchors to all BTHome.io webpages that have multiple/long sections to them so it's easy for someone to deep-link.

@scottcopus scottcopus added the bug Something isn't working label Aug 5, 2023
@Ernst79
Copy link
Collaborator

Ernst79 commented Aug 5, 2023

It’s 4 bytes, excl. the byte for the sensor type. I see I made an error in the table, the example should be 0x50 5d396164, so 4 bytes (unsigned) following 0x50 for timestamp. I have updated the example.

With 0x50 ffffffff We get 4294967295 as integer, which is Sunday 7 February 2106 06:28:15 in epoch time as maximum date. So, no 2035 bug, but a 2108 bug, but I assume we can live with that.

@scottcopus
Copy link
Author

Ah, I didn’t recognize that timestamp was also unsigned which helps it last a bit longer. ;) If this is acceptable by other devs in the general HA world, I’m good with it.

@Ernst79
Copy link
Collaborator

Ernst79 commented Aug 5, 2023

By the time we get close to 2108 I’ll add a 5 byte long timestamp, if I still live. Help me remember by that time 😄

@miri64
Copy link

miri64 commented Nov 14, 2024

Saw this issue but I am still not clear, why the table says uint48 (4 bytes). uint48 would be 6 bytes but all examples (and the parenthesis) hint at 4 bytes so uint32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants