Read the statement by Michael Teeuw here.
Store data that's accessible after restart of MM²
-
Hi all!
I have a Homey device with a MQTT Client who sends out a message that tells if I’m at home or not to my MM². It’s a message containing1
if I’m home, and0
if I’m away. If I receive a1
I start a timer on my mirror telling me for how long I’ve been at home, I.E.2h 34m 22s
. Pretty basic actually.
Now here’s my issue. When I, for some reason, restart my MM², the counter is lost. Is there a way to save the data I’m using somehow? I’m thinking that I can save the start time somewhere, if I have one, and when the MM² starts up I will check for that and continue the timer. But where can I store that kind of data? I guess localStorage isn’t the way to go, or? -
I don’t know much about programming, but I guess you can store the time in a text file each second or minute, and then read the file at startup, and then continue from there
-
That’s my thought as well, the thing is I’m not sure how to do it. Not to store the time each second tho, that will destroy my SD card. But save the start time when I get home, and set the time to 0 when I leave home. And if I need to reboot I will check for the start time value I’ve saved, and if its’ more that 0 I will continue the timer from that starting point.
My question is if there’s a recommended way to store this data, and how should I do it?
-
I took a look at the web, and found this: https://unix.stackexchange.com/questions/43854/save-entire-process-for-continuation-after-reboot
I don’t know if it is entirely helpful for you. -
Thanks @Blauenfeldt, but that’s not what I’m looking for. Thanks anyway. :)
-
@C-son there is nothing built-in that does what you want
-
@sdetweil ok, thanks. I’m trying to solve this by save the timestamp in a file with
fs
:)