• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Store data that's accessible after restart of MM²

Scheduled Pinned Locked Moved Solved Development
7 Posts 3 Posters 839 Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C-son Module Developer
    last edited by Oct 23, 2020, 8:32 AM

    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 containing 1 if I’m home, and 0 if I’m away. If I receive a 1 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?

    MMM-MagicMover :: MMM-MagicSuperHero :: MMM-MagicHexClock

    1 Reply Last reply Reply Quote 0
    • B Offline
      Blauenfeldt
      last edited by Oct 23, 2020, 8:31 PM

      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

      1 Reply Last reply Reply Quote 0
      • C Offline
        C-son Module Developer
        last edited by C-son Oct 24, 2020, 11:13 AM Oct 24, 2020, 11:12 AM

        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?

        MMM-MagicMover :: MMM-MagicSuperHero :: MMM-MagicHexClock

        1 Reply Last reply Reply Quote 0
        • B Offline
          Blauenfeldt
          last edited by Oct 25, 2020, 11:22 AM

          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.

          1 Reply Last reply Reply Quote 0
          • C Offline
            C-son Module Developer
            last edited by Oct 25, 2020, 12:08 PM

            Thanks @Blauenfeldt, but that’s not what I’m looking for. Thanks anyway. :)

            MMM-MagicMover :: MMM-MagicSuperHero :: MMM-MagicHexClock

            S 1 Reply Last reply Oct 25, 2020, 12:13 PM Reply Quote 0
            • S Offline
              sdetweil @C-son
              last edited by Oct 25, 2020, 12:13 PM

              @C-son there is nothing built-in that does what you want

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              C 1 Reply Last reply Oct 25, 2020, 3:07 PM Reply Quote 0
              • C Offline
                C-son Module Developer @sdetweil
                last edited by Oct 25, 2020, 3:07 PM

                @sdetweil ok, thanks. I’m trying to solve this by save the timestamp in a file with fs :)

                MMM-MagicMover :: MMM-MagicSuperHero :: MMM-MagicHexClock

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                1 / 1
                • First post
                  2/7
                  Last post
                Enjoying MagicMirror? Please consider a donation!
                MagicMirror created by Michael Teeuw.
                Forum managed by Sam, technical setup by Karsten.
                This forum is using NodeBB as its core | Contributors
                Contact | Privacy Policy