MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    SOLVED Store data that's accessible after restart of MM²

    Development
    3
    7
    281
    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-son
      C-son Module Developer last edited by

      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
        Blauenfeldt last edited by

        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-son
          C-son Module Developer last edited by C-son

          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
            Blauenfeldt last edited by

            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-son
              C-son Module Developer last edited by

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

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

              S 1 Reply Last reply Reply Quote 0
              • S
                sdetweil @C-son last edited by

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

                Sam

                Create a working config
                How to add modules

                C-son 1 Reply Last reply Reply Quote 0
                • C-son
                  C-son Module Developer @sdetweil last edited by

                  @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
                  • First post
                    Last post
                  Enjoying MagicMirror? Please consider a donation!
                  MagicMirror created by Michael Teeuw.
                  Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
                  This forum is using NodeBB as its core | Contributors
                  Contact | Privacy Policy