MagicMirror² v2.4.1 is available! For more information about this release, check out this topic.
Please read the release notes carefully since this update requires adjustments to your Raspberry Pi configuration!

Writing my own OS



  • Hi everyone,

    First of all this is probably not the best place to ask this question. Sorry for that!(didn’t know where else to aks it)

    As the title might suggest I want to build my own OS for my magic mirror. I want to make more of a smart magic mirror(smart home). It should be able to do the following things.

    -I should be able to connect to the mirror from my phone/pc/laptop etc.
    -I should be able to turn of lights/play music(smart home stuff).
    -I should be able to run python scripts
    -It should be highly customizable(because i’ll hope to learn a lot in the next couple of months, so i might change everything)

    In general I want the mirror to be more connected to the rest of my devices. It should really be the center of my smart home. I also plan to do some machine learning like face recognition. So it should also be able to run python scripts.

    The only problem is that I have 0 experience with web/server development. And therefore I have no clue which software/frameworks i should use to write all the software. What the best way is to setup a server etc. I don’t know if it is smart to use electron or nodeJS or angular because I have no experience with any of them. And I don’t want to waste a lot of time with learning the “wrong” frameworks.

    I do however have quite some experience with java and python.

    So the main question I am asking is: what is the best way to set a project like this up(server wise) and what frameworks or languages should i learn.

    ps. Timewise I am planning to take a year to learn and make everything. Do you guys think that is enough time?

    Thanks in advance!



  • You can do all of this without writing a new ‘OS’ … MagicMirror2 is a damn good backbone…I have many things running on mine…
    Example…

    https://www.youtube.com/watch?v=GiHU1tSGf0g



  • Looks really cool,

    But part of the reason that I want to do this myself is to learn. So using MagicMirror2(which is way better that what i will ever make) won’t allow me to learn all the things I want to learn. And making my own seems like a fun project



  • my suggestion is aswell use MM2. You don’t have to start from scratch that costs a ton of time and makes asking harder.
    For most stuff there is already someone that has done something similar thats helps.

    As an example my setup is
    MM2 as info displays (probably multiple mirrors sooner or later)
    The standalone offline voice recognition snips for all smarthome stuff (obviously works with all the online alexa stuff ect aswell)
    And as general backbone that really controls all the smarthome stuff something like openhab/homeassistant.

    Those are all great software parts that support you. you obviously can live for example without openhab/homeassistant and do controls directly with modules in MM2, but the moment you have many devices you want to control it kind of gets messy. (I am a big fan of keeping the software parts simple so you can maintain something without being scared that suddenly everythings broken)

    Obviously same for stuff like your machine learning. I would just have it run standalone with just a couple connections to for example MM2 to tell it which user it recognised.

    What language stuff should you learn? Your experienced with java and python, so just use them. Can’t really see a reason to use another when your good in them.

    So my suggestion is use this premade software out there. You obviously can develop the wheel again, but you probably spend a ton of time without getting a better endproduct (would be more of a educational thing to rebuild something like that xD)
    Then you can spend all your time on really building the stuff you want to build like this facial recognition.
    Is a year enough? Well hard to say for me it would be never because with my smarthome stuff it’s really always the same thing I build one thing and already have 5 ideas for new stuff to add.



  • @ruben said in Writing my own OS:

    Looks really cool,

    But part of the reason that I want to do this myself is to learn. So using MagicMirror2(which is way better that what i will ever make) won’t allow me to learn all the things I want to learn. And making my own seems like a fun project

    yes thats what I mean the only real reason to rebuild it is for educational purposes 😉



  • I also believe you should not waste your time creating your own OS.
    If you wish to do this purely for learning this can be done by taking a current OS and just strip it down to what you need. You’ll also get more enjoyment creating something others can use as well. So stick with Magic Mirror and expand on it you’ll learn just as much and others can benefit, while you learn you can also be teaching. 😉



  • Heya, I’m a full stack developer and will give my 2cents, however I’m extremely new to MagicMirror so I can’t answer many questions regarding it.

    Probably the most important information you should know is that web knowledge is very portable. Just learn web basics and you’re golden to work in your language preference. If you already know Python and Java, why not use them?

    However, there are other languages you can write in, and it seems like you’re keen, so here are the ones I’ve found to work best for me (easy to learn, can do a lot with them):

    Server-side

    • NodeJS (easier, loosely typed, strong community)
    • PHP (intermediate, but meh.. a little outdated, prefer the others)
    • Go (intermediate, strongly typed, strong community)

    Client-side
    Just learn the basics of HTML/CSS/JavaScript, and use JavaScript to send HTTP requests to which your server will respond.

    Research

    1. HTML
    2. CSS
    3. JavaScript
    4. HTTP/HTTPS (GET, POST, PUT, PATCH, UPDATE, DELETE)
    5. AJAX
    6. Choose a server-side language, if it's a new one then practice it by writing some data structures or making something you've already made in Python/Java.
    7. REST services (maybe GraphQL if you want to be bleeding edge, but definitely not necessary)
    8. Optional (overkill), look into architectural patterns such as MVC. Very valuable for web app development
    9. Optional (overkill), look into front-end frameworks such as React, Vue, Django, etc...

    If you learn the basics of HTTP protocols, it’ll take you very far with what you want to accomplish with smart-home devices. For example:

    1. Create an index.html page with button named trigger
    2. Make it look pretty with CSS
    3. Use JavaScript to capture the button click. The click will initiate a HTTP GET request to your Go/NodeJS/Java/Python server, specifically to the url localhost:8080/capture
    4. You will (probably) have a REST server. Your server, running on port 8080, will have routing setup to see capture a GET request made to the /capture endpoint (this is a web hook -- you're telling your server to do X when it sees a request has been made from some specific URL route)
    5. You can now do ANYTHING on your server, such as grab data from a database, and spit it back to your client-side JavaScript app in (probably) JSON format since it's easy to parse.

    Once you get that to work, look into Amazon Alexa or Google Home and how they handle HTTP requests. They use the same approach and you’ll find it very similar. However you seem like a go-getter willing to do machine-learning, so maybe you’ll build your own web-hook system to control request/response actions in your smart home, there are GitHub repositories out there for anything now!

    Again, I’m only a full stack developer and you said you want to learn more about web servers. I believe most if not all developers should have web fundamentals down solid, and learning this stuff puts you in the nitty-gritty side of things, which I have a feeling is what you want. I’m not sure why people think this is a time-waster, development experience is development experience and that’s that; the developer just needs to be shown the optimal path.

    By the way, a year is PLENTY to learn all of this since you already have programming experience. When you do learn it, then as you stated yourself you’ll have learned all the things you want to learn and will have the experience create whatever you want with MM2 and MANY other platforms (or make your own).



  • I’ll never say “don’t try an incredibly ambitious project!” because that’d just make me a hypocrite: however, I will say this:

    Depending on what you actually want to do with it… you might now need to. I’ve been spending a good deal of time recently working on a setup with Home Assistant, and I used to have my instance on the same pi as my mirror. I honestly think that given the level of features that you want, you may want to look into just combining some projects with something like that – it’s open source still, but it allows your controls, remote access (provided you set up a reverse proxy or open a port), and a stupidly wide-ranging API. Mine also runs Homekit for interfacing with the family’s iPhones. and a custom Alexa skill that ties anything and everything “smart” together.

    What does that have to do with the MagicMirror? Well, I’m working on it. For starters, a lot of control over the mirror itself is provided by the URL scheme setup by Jopyth’s wonderful Remote Control module. Right now I have it set up as a switch in HASS (so I can turn the display on/off easily), but I also can use HASS to send notifications to the mirror, automate hiding/content of various modules, etc! That’s all just with the URLs, not even getting into more advanced stuff – I’m working on a module that allows autodiscovery of a Mirror as an MQTT device. With the touch controls built into a lot of modules, you can already control lots of smart home things, and given the expensive API, I’m SURE that you or someone else could write a great module to control HASS directly. Even with what’s available now, it should be pretty straightforward to use the rEST API module to tell HASS (or openHAB, or Domoticz!) to toggle lights, set scenes, activate scripts, etc.

    The nice thing about HASS is that it’s written in python and is pretty easily extensible! The bad thing is that it’s configured via YAML. There’s a learning curve, and it takes some tinkering – but then, if you’re gonna try and build an OS, I figure you’re already ready for that.



  • @pyrosmiley I gotta agree with you… I didn’t want to discourage him from trying…heck if that were the case NOAA3 would have never gotten done…learned a lot of new things myself…

    SO perhaps it’s a great idea for him to learn and make it truly his own!! 🙂



  • Although I did state I thought creating your own OS was a waste of time. It may have been a bad choice of words. Lots of people state “why reinvent the wheel?” well if that were the case we’d all be using wooden wheels on our autos. The statement of “creating my Own OS” makes me think this won’t be shared with a sharing community.
    If everyone created their own MM modules and didn’t share where would MM be?
    I also don’t wish to discourage anyone from learning and creating something new and my OP definitely came across like that. That was not my intention.