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

Posts

Recent Best Controversial
  • RE: Notifications help

    @BKeyport I did that and it’s definitely my code, I can see the notification is being sent by the SHOW_ALERT but my module is not able to capture them, I tried different codes and hit mental block now.

    posted in Troubleshooting
    S
    sdmydbr9
    Feb 12, 2023, 5:10 AM
  • RE: Notifications help

    @sdetweil well they match, the folder, the module name and module.js.
    The folder is MMM-11-TTS under the modules directory.
    Under that directory is MMM-11-TTS.js module. I have also specified the config.js to consider this module.
    The contents of the MMM-11-TTS.js posted earlier, is that correct or if there is anything missing, can you please provide me the updated code.

    posted in Troubleshooting
    S
    sdmydbr9
    Feb 12, 2023, 5:06 AM
  • Notifications help

    Trying to capture notifications for a module, can anyone tell me what’s wrong with this mai js, my objective for now is to capture the SHOW_ALERT notification and print it in the console log. Here is the mainjs

    Module.register("MMM-11-TTS", {
        start: function() {
            console.log(`Starting module: ${this.name}`);
        },
    
        notificationReceived: function(notification, payload) {
            if (notification === 'SHOW_ALERT') {
                console.log(`Received notification: ${notification}`);
                console.log(`Payload: ${payload}`);
            }
        }
    });
    
    
    posted in Troubleshooting
    S
    sdmydbr9
    Feb 12, 2023, 3:59 AM
  • RE: Need help creating a module.

    @sdmydbr9
    Module has been created and working version has been published in GitHub. Feel free to Check out

    posted in Requests
    S
    sdmydbr9
    Feb 10, 2023, 3:14 PM
  • RE: Need help creating a module.

    @mumblebaj
    Here is the updated nodehelper

    
    var https = require("https");
    
    module.exports = NodeHelper.create({
    
      // Override start method.
      start: function() {
        console.log("Starting node helper for: " + this.name);
      },
    
      // Handle the GET_VIDEO_TITLES socket notification.
      socketNotificationReceived: function(notification, payload) {
        if (notification === "GET_VIDEO_TITLES") {
          var apiKey = payload.apiKey;
          var channelId = payload.channelId;
    
          var url = "https://www.googleapis.com/youtube/v3/search?key=" + apiKey + "&channelId=" + channelId + "&part=snippet,id&order=date&maxResults=10";
    
          https.get(url, function(res) {
            var body = "";
    
            res.on("data", function(chunk) {
              body += chunk;
            });
    
            res.on("end", function() {
              var response = JSON.parse(body);
              var titles = [];
    
              for (var i = 0; i < response.items.length; i++) {
                titles.push(response.items[i].snippet.title);
              }
    
              // Send the video titles back to the module.
              this.sendSocketNotification("VIDEO_TITLES", { titles: titles });
            }.bind(this));
          }.bind(this)).on("error", function(error) {
            console.log("Error: " + error.message);
          });
        }
      }
    });
    
    
    posted in Requests
    S
    sdmydbr9
    Feb 10, 2023, 6:47 AM
  • RE: Need help creating a module.

    @mumblebaj so to sum up, the main.is is correct and I need to edit the nodehelper.js script?

    posted in Requests
    S
    sdmydbr9
    Feb 10, 2023, 6:35 AM
  • Need help creating a module.

    Being from one of the remotest part of the world, it’s not easy to get the local news from the convenient sources to stay updated, having no options I was using the default newsfeed modules. My only source of local news is the local YouTube news channel, therefore I was looking for ideas to implement something similar to display the titles of the latest YouTube videos on the mirror. I used the MMM-Pythonprint module for doing that, unfortunately I couldn’t figure out a way to rotate the titles one at a time since my python script prints the title of latest 10 videos using YouTube api.
    I then stumbled upon chatgpt, I asked it to create a module for me to use this functionality.
    It did create the module, it gave me the following codes but due to some reasons I could not get it to work, Iam still a learner and I have zero knowledge about codes. Im hoping someone will stumble upon this and figure out a way

    This is the main.js

    
    Module.register("MMM-LocalNews", {
        // Default module config.
        defaults: {
            channelId: "UCX6OQ3DkcsbYNE6H8uQQuVA",
            apiKey: "YOUR_API_KEY",
            updateInterval: 60 * 60 * 1000, // Every hour.
            animationSpeed: 2 * 1000,
            initialLoadDelay: 0,
            retryDelay: 2500,
            maxTitles: 10,
            reverse: false
        },
    
        // Define required scripts.
        getScripts: function() {
            return [];
        },
    
        // Define required styles.
        getStyles: function() {
            return [
                "MMM-LocalNews.css"
            ];
        },
    
        // Define start sequence.
        start: function() {
            Log.info("Starting module: " + this.name);
    
            // Set locale.
            moment.locale(config.language);
    
            this.videoTitles = [];
            this.scheduleUpdate();
        },
    
        // Override the getDom method.
        getDom: function() {
            var wrapper = document.createElement("div");
            wrapper.className = "video-titles";
    
            if (!this.videoTitles.length) {
                wrapper.innerHTML = "Loading video titles...";
                wrapper.classList.add("bright", "light");
                return wrapper;
            }
    
            if (this.config.reverse) {
                this.videoTitles.reverse();
            }
    
            this.videoTitles.forEach(function(videoTitle) {
                var title = document.createElement("div");
                title.className = "video-title";
                title.innerHTML = videoTitle;
                wrapper.appendChild(title);
            });
    
            return wrapper;
        },
    
        // Request video titles from the node helper.
        scheduleUpdate: function() {
            setTimeout(function() {
                this.sendSocketNotification("GET_VIDEO_TITLES", {
                    channelId: this.config.channelId,
                    apiKey: this.config.apiKey
                });
            }.bind(this), this.config.initialLoadDelay);
    
            setInterval(function() {
                this.sendSocketNotification("GET_VIDEO_TITLES", {
                    channelId: this.config.channelId,
                    apiKey: this.config.apiKey
                });
            }.bind(this), this.config.updateInterval);
        },
    
        // Handle the video titles received from the node helper.
        socketNotificationReceived: function(notification, payload) {
            if (notification === "VIDEO_TITLES") {
                this.videoTitles = payload.titles.slice(0, this.config.maxTitles);
                this.updateDom(this.config.animationSpeed);
            }
        }
    });
    
    

    And here is the node_helper.js

    
    var https = require("https");
    
    // Replace YOUR_API_KEY with your actual API key.
    var apiKey = "YOUR_API_KEY";
    var channelId = "UC_CHANNEL_ID";
    
    // Build the API request URL.
    var url = "https://www.googleapis.com/youtube/v3/search?key=" + apiKey + "&channelId=" + channelId + "&part=snippet,id&order=date&maxResults=10";
    
    https.get(url, function(res) {
        var body = "";
    
        res.on("data", function(chunk) {
            body += chunk;
        });
    
        res.on("end", function() {
            var response = JSON.parse(body);
            var titles = [];
    
            for (var i = 0; i < response.items.length; i++) {
                titles.push(response.items[i].snippet.title);
            }
    
            console.log(titles);
        });
    }).on("error", function(error) {
        console.log("Error: " + error.message);
    });
    
    

    I have also created a GitHub repository for the same
    link to repo

    Can anyone provide me another alternative to do this because this module doesn’t work, or can someone fix this module to make it work. Thanks

    posted in Requests
    S
    sdmydbr9
    Feb 9, 2023, 1:12 PM
  • RE: Compliment from calendar event

    @MMRIZE

    
    {
    	classes: "default scheduler",
    	module: "compliments_plus",
    	position: "middle_center",
    	disabled: false,
    	config: {
    		module_schedule: {from: '0-59/10 * * * *', to: '5-59/10 * * * *'},
    		updateInterval: 30000,
    		remoteFile: null,
    		fadeSpeed: 4000,
    		random: true,
    		mockDate: null,
    		classes: "compliments_plus thin large pre-line",
    
    //	the beginning of the day period
    
    		morning: 5,
    		noon: 12,
    		afternoon: 15,
    		evening: 18,
    		night: 22,
    		midnight: 1,
    
    		compliments: {
    			"AQI_1" : [
    				"<i class=\"fa fa-leaf lime\"></i> Air Quality Good",
    			],
    			"AQI_2" : [
    				"<i class=\"fa fa-leaf yellow\"></i> Air Quality Fair, mask on",
    			],
    			"AQI_3" : [
    				"<i class=\"fa fa-leaf orange\"></i> Air Quality Moderate, mask on",
    			],
    			"AQI_4" : [
    				"<i class=\"fa fa-leaf orangered\"></i> Air Quality Poor, need air purifier",
    			],
    			"AQI_5" : [
    				"<i class=\"fa fa-leaf redrf\"></i> Air Quality Unhealty, dont breathe",
    			],
    			"25-12-...." : [
    				"<i class=\"fa fa-snowman\"></i> Marry Christmas!"
    			],
    			"01-01-....": [
    				function() {return "<i class=\"fa fa-glass-cheers\"></i> Happy New Year! " + moment().format("YYYY")}
    			],
    			"..-..-....": [
    				function() {return moment().locale(config.language).format("dddd, D MMMM")}
    			],
    		}
    	},
    	},
    
    

    The config for the module

    posted in Troubleshooting
    S
    sdmydbr9
    Jul 15, 2022, 4:07 PM
  • RE: Compliment from calendar event

    @MMRIZE I have come across a module which displays compliments based on notification received but unfortunately I’m unable to integrate it together mainly due to lack of skills. The name of the module is compliments-plus

    posted in Troubleshooting
    S
    sdmydbr9
    Jul 15, 2022, 3:53 PM
  • 1
  • 2
  • 3
  • 4
  • 2 / 4
Enjoying MagicMirror? Please consider a donation!
MagicMirror created by Michael Teeuw.
Forum managed by Sam, technical setup by Karsten.
This forum is using NodeBB as its core | Contributors
Contact | Privacy Policy