MagicMirror² v2.14.0 is available! For more information about this release, check out this topic.

How to keep a history of values on Mirror

  • Hello,

    I’m considering keeping a history of the values displayed on the mirror to use later in a simple Machine Learning project. Of course I wouldn’t want to keep a history of everything on the screen, only some key values.

    For example, I would like to keep a history of the temperatures of the previous two days. In that case if today’s temperature is more than 3 degrees different than yesterday’s I would show an alert. I could also keep a history of whether it was raining yesterday or not. If it was raining yesterday and it’s not raining today, display alert. If it’s raining today but not yesterday, show alert. If it hasn’t rained for three days and it’s not raining today, no need to show an alert.

    I could keep a history of my grocery list (shared with my girlfriend), that way if she were to add items to it I would only show the new items for the day.

    Bottom line, I was wondering if there’s a smart way to communicate key values in between modules without having to fork each one of them to add that feature. I could write a small JS hack that fetches the values from the screen, but that wouldn’t be a clean solution at all.


  • Module Developer

    Modify the modules to keep the log of whichever you want into files.

    Communication between modules are usually using notification. See the development guide.

  • @sean Thanks for your input, I appreciate you taking the time.
    However I was wondering if I could do that without explicitly modifying the code in the modules. I thought about that but I was hoping to be able to do something universal that could be applied to any module, not only ones that I can edit myself.

  • Module Developer

    I can say there isn’t such a magic wand.

  • Module Developer

    The only way I could see not having to modify other modules would be to only use modules that already emit notifications when events happen. Then all you would need to do is create a simple module that receives, saves, and recalls those notifications and looks for changes. You could use something like json-store to make the whole process even easier. If you wanted to get more information, you could do a very simple modification to modules to just spit out more notifications with more data.

  • Hm, I was hoping there would be a smarter way.

    Thanks for your ideas everyone, I guess I’m going to write some code that gets the state of the mirror and parses it for the relevant information. I will need to handle the various modules I’m interested in and potentially make it so that it’s easy to onboard new modules into it. It could either be an actual module on the mirror (working on writing my own modules now) or a totally separate process that fetches the mirror and parses that.

    Thank you everyone, I’ll work on it for a while and come back here if I ever get anything done 🙂

Log in to reply