MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. ianperrin
    3. Posts
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    I
    Offline
    • Profile
    • Following 0
    • Followers 6
    • Topics 6
    • Posts 164
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: modules day and time Depending represented

      @cowboysdude said in modules day and time Depending represented:

      It’s turning anything off with 'classes: ‘scheduler’, attached no matter what time you set

      The expected functionality is that the module is shown between the dates specified, so once the module has done it’s thing, it hides the modules and they are not shown until the next ‘from’ date.

      In more detail, it should follow the following process once it receives the notification (DOM_OBJECTS_CREATED) that all modules have been loaded:

      • It checks each module to see if it contains the ‘scheduler’ class
      • If yes, it checks whether the module config includes the ‘module_scheduler’ option
      • if yes, it checks whether the option includes the ‘from’ and ‘to’ properties
      • if yes, it creates the cron jobs to show (‘from’) and hide (‘to’) the module
      • if the next show (‘from’) date for the module is in the future and less than the next hide (‘to’) date, it hides the module
      • when the ‘from’ cron job is triggered, it sends a notification to show the module
      • when the ‘to’ cron job is triggered, it sends a notification to hide the module

      Now, as this is work in progress I haven’t had time to check all permutations of modules and cron expressions. However, it’s logging is rather verbose so please do check out the console log (pm2 logs mm) to see what it thinks it is doing!

      If you find problems, can you post your config (or at the least, which module you are trying to schedule and the values for the module_scheduler option?

      Thanks

      posted in General Discussion
      I
      ianperrin
    • RE: modules day and time Depending represented

      @cowboysdude said in modules day and time Depending represented:

      Only thing I can see wrong is the speed [decreased] of loading the mirror!

      As part of the install process, npm install needs to be run to install the dependency on node-cron. This can take a little time, but is only required once. Having completed the install, I’m not seeing the performance issues you mention so we might need to look into that a little further.

      posted in General Discussion
      I
      ianperrin
    • RE: modules day and time Depending represented

      @bjoern - I have created an initial version of MMM-ModuleScheduler and pushed it to github -https://github.com/ianperrin/MMM-ModuleScheduler

      If you would like to test it, feel free to install it on your Mirror and report back here.

      However, please remember that this is work in progress and has not yet been fully tested, so please do use with care.

      posted in General Discussion
      I
      ianperrin
    • RE: modules day and time Depending represented

      So, my current thinking is based around the following config

      {
      	module: 'MMM-ModuleScheduler'
      },
      {
      	module: 'calendar',
      	position: 'top_left',
      	classes: 'scheduler',
      	config: {
      		// Show at 9:00 and hide at 18:00 every day from Monday through Friday
      		module_schedule: {from: '0 9 * * 1-5', to: '0 18 * * 1-5'}
      	}
      },
      {
      	module: 'MMM-soccer',
      	position: 'top_right',
      	classes: 'scheduler',
      	config: {
      		// Show at 9:00 on Saturday and hide at 20:00 on Sunday
      		module_schedule: {from: '0 9 * * SAT', to: '0 20 * * SUN'}
      	}
      }
      

      Modules would then be shown and hidden based on the addition of a specific class classes: 'scheduler' and a module_schedule config option containing the cron expressions which control when the module should be shown (from) and hidden (to).

      How does that sound?

      p.s. here’s another useful cron resource - http://crontab.guru/

      posted in General Discussion
      I
      ianperrin
    • RE: modules day and time Depending represented

      @bjoern - a common way of scheduling activity is use cron expressions which give an enormous amount of flexibility for defining when things should happen.

      I would think this is a better way to tackle the solution rather than try to create custom scheduling logic.

      I’ve built the basis of the module which hides and shows other modules based on the config options, but will need a little time to add and test the scheduling. Give me a day or so.

      Ian

      posted in General Discussion
      I
      ianperrin
    • RE: assign a symbol to a module

      Hi @dominic

      The simplest approach would be to add a “br” element between the temperature and humidity.

      However, I would consider putting them in an unordered list and take advantage of the inbuilt layout controls within FontAwesome. E.g.

      getDom: function() {
      	var wrapper = document.createElement("div");
      	if(this.dataFile){
      
      		var humidityRegExp = /Humidity = (.*?) %/ig;
      		var humidity = humidityRegExp.exec(this.dataFile)[1];
      
      		var temperatureRegExp = /Temperature = (.*?) *C/ig;
      		var temperature = temperatureRegExp.exec(this.dataFile)[1];
      
      		var list = document.createElement("ul");
      		list.classList.add("fa-ul");
      
      		// add temperature
      		var temperature_item = document.createElement("li");
      		var temperature_symbol =  document.createElement("i");
      		temperature_symbol.classList.add("fa", "fa-li", "fa-home");
      		temperature_item.appendChild(temperature_symbol);
      		temperature_item.appendChild(document.createTextNode(" " + temperature + "°C"));
      		list.appendChild(temperature_item);
      
      		// add humidity 
      		var humidity_item = document.createElement("li");
      		var humidity_symbol =  document.createElement("i");
      		humidity_symbol.classList.add("fa", "fa-li", "fa-tint");
      		humidity_item.appendChild(humidity_symbol);
      		humidity_item.appendChild(document.createTextNode(" " + humidity + "%"));
      		list.appendChild(humidity_item);
      
      		wrapper.appendChild(list);
      
      	} else {
      		wrapper.innerHTML = "No data";
      	}
      	return wrapper;
      },
      
      posted in Troubleshooting
      I
      ianperrin
    • RE: assign a symbol to a module

      @Plati glad to help - and we’re all learning here so don’t worry!

      Fontawesome provides lots of support for managing the display of icons, so if the icons are throwing the alignment in the table out try making the icons Fixed Width by adding “fa-fw” to the icon e.g. icon.classList.add("fa", "fa-fw", "fa-" …

      Alternatively, set the icon font-size to the same as the message, by using the inbuilt MM styles, e.g. iconCell.classList.add("small");

      or a combination of both :)

      posted in Troubleshooting
      I
      ianperrin
    • RE: assign a symbol to a module

      You could also consider making the icon configurable via the options,

      First add the default values for the options

      	defaults: {
      		max: 5,
      		format: false,
      		types: {
      			INFO: "dimmed",
      			WARNING: "normal",
      			ERROR: "bright"
      		},
      		icons: {
      			INFO: "info",
      			WARNING: "exclamation",
      			ERROR: "exclamation-triangle"
      		}
      	},
      

      Then change the code to create the icon (and for bonus points, set class for the icon to the same as the message.

      		var iconCell = document.createElement("td");
      		var icon =  document.createElement("i");
      		if(this.config.icons.hasOwnProperty(this.messages[i].type)){
      			icon.classList.add("fa", "fa-" + this.config.icons[this.messages[i].type]);
      		} else {
      			icon.classList.add("fa", "fa-question");
      		}
      		if(this.config.types.hasOwnProperty(this.messages[i].type)){
      			icon.classList.add(this.config.types[this.messages[i].type]);
      		}
      		iconCell.appendChild(icon);
      		callWrapper.appendChild(iconCell);
      
      

      Warning - this code was entered directly here in the comment so may contain TyoPs ;)

      posted in Troubleshooting
      I
      ianperrin
    • RE: assign a symbol to a module

      @Plati said in assign a symbol to a module:

      Hi @ianperrin

      | Icon | Message | Time | should be ok

      In that case, try this

      
      		var iconCell = document.createElement("td");
      
      		var icon =  document.createElement("i");
      		if (this.messages[i].type === "INFO"){
      			icon.className = "fa fa-info";
      		}
      		else if (this.messages[i].type === "WARNING"){
      			icon.className = "fa fa-exclamation";
      		}
      		else if (this.messages[i].type === "ERROR"){
      			icon.className = "fa fa-exclamation-triangle";
      		}
      		else {
      			icon.className = "fa fa-question";
      		}
      
      		iconCell.appendChild(icon);
      		callWrapper.appendChild(iconCell);
      		
      		//Set caller of row
      		var caller =  document.createElement("td");
      		caller.innerHTML = "[" + this.messages[i].type + "] " + this.messages[i].message;
      
      posted in Troubleshooting
      I
      ianperrin
    • RE: assign a symbol to a module

      Hi @Plati

      The solution depends on how you want to display the table.

      Do you want

      • 3 columns in the following order: | Icon | Message | Time |
      • Or 2 columns laid out as follows: | Message Icon | Time |
      posted in Troubleshooting
      I
      ianperrin
    • 1
    • 2
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 14 / 17