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

Show some modules and config in Holidays



  • Hi,
    I wish I could display the modules and their configuration depending on whether we are on vacation or not.

    For example, I use the AlarmClock module, some alarms are specific to the school period. So, these are of no use during the holidays.

    Has anyone already configured such a configuration?


  • Module Developer

    @ybbet
    I think it is possible with crontab or some simple scripts. Prepare several config files(config_weekday.js, config_holiday.js, config_sunday.js, etc.) then make a script or cron job to copy one of them to config.js by condition. Add cronjob to restart every 0am with new configuration.



  • Hello,

    This is exactly the answer I put in place. I wanted to know if there was a simpler solution to not multiply the config files. And so, avoid mistakes and forgetfulness.

    @daily bash ~/tools/disk_usage.sh >> /tmp/cron_log.txt
    0 0 * * * cd /home/pi/magicmirror_config; git checkout ./ ; git pull >> /tmp/cron_log.txt
    5 0 * * * bash /home/pi/magicmirror_config/update_files_config.sh >> /tmp/cron_log.txt
    10 0 * * * cd /home/pi/; pm2 restart mm.sh >> /tmp/cron_log.txt
    @monthly sudo reboot
    15 0 * * * mail -s "MagicPi : cron rapport" test@example.tld < /tmp/cron_log.txt; rm /tmp/cron_log.txt
    
    ###############
    # Summer holidays : 7 july
    30 0 8 7 * cd /home/pi/MagicMirror/config/; rm -rf config.js; ln -s /home/pi/magicmirror_config/config_vac_centre.js config.js; pm2 restart mm
    # The boys
    30 0 6 8 * cd /home/pi/MagicMirror/config/; rm -rf config.js; ln -s /home/pi/magicmirror_config/config_vac_salome_centre.js config.js; pm2 restart mm
    # First boy come back to home
    30 0 14 8 * cd /home/pi/MagicMirror/config/; rm -rf config.js; ln -s /home/pi/magicmirror_config/config_vac_salome_1garcon_centre.js config.js; pm2 restart mm
    # The last boy come back to home
    30 0 24 8 * cd  /home/pi/MagicMirror/config/; rm -rf config.js; ln -s /home/pi/magicmirror_config/config_vac_centre.js config.js; pm2 restart mm
    # 3 september
    30 0 3 9 * cd /home/pi/MagicMirror/config/; rm -rf config.js; ln -s /home/pi/magicmirror_config/config.js config.js; pm2 restart mm
    
    

  • Module Developer

    @ybbet
    As I know, MM doesn’t have a feature - dynamic runtime configuration or conditional( or modular) config loading. So I think that might be the easiest (?) way.


  • Module Developer

    @ybbet
    But if your case be somehow regularly, you could make some script or program to compose and encode “config.js” file from some defined structure with python or any other language.
    Basically, config.js is some kind of JSON object(or like-something), So you can prepare one template object, and manipulate the object with your purpose by condition. Then write it into config.js file.