MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord
    1. Home
    2. brendan_c23
    B
    • Profile
    • Following 0
    • Followers 0
    • Topics 6
    • Posts 56
    • Best 0
    • Controversial 0
    • Groups 0

    brendan_c23

    @brendan_c23

    0
    Reputation
    5
    Profile views
    56
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    brendan_c23 Unfollow Follow

    Latest posts made by brendan_c23

    • RE: MMM-Stock Cannot read property 'toLowerCase'

      @sdetweil is there anybody we can notify that its not working so they can begin working on fixing it?

      posted in Troubleshooting
      B
      brendan_c23
    • RE: MMM-Stock Cannot read property 'toLowerCase'

      @sdetweil What do you think we could do?

      posted in Troubleshooting
      B
      brendan_c23
    • RE: MMM-Stock Cannot read property 'toLowerCase'

      @sdetweil Do you think I should delete it then redownload? Might be the companies… although they have worked before

      posted in Troubleshooting
      B
      brendan_c23
    • RE: MMM-Stock Cannot read property 'toLowerCase'

      @brendan_c23 Not completely sure on how to delete a module though, my Pi4 doesnt give me the option when right-clicking on the folder

      posted in Troubleshooting
      B
      brendan_c23
    • RE: MMM-Stock Cannot read property 'toLowerCase'

      @sdetweil What do you think it could be? I am going to try copying original .js from hakanmhmd and make sure I didnt make any small changes I wasnt aware of , or maybe just delete and try to re download it

      posted in Troubleshooting
      B
      brendan_c23
    • RE: MMM-Stock Cannot read property 'toLowerCase'

      @sdetweil Could you try running it with both my config entry and MMM-stock.js entry I’ve posted and let me know if it works for you?

      posted in Troubleshooting
      B
      brendan_c23
    • RE: MMM-Stock Cannot read property 'toLowerCase'

      @sdetweil yes, and I remember there being a delay before when it worked (around 5 mins) , but never this long as I am yet to see it, but here is the config
      {
      module: “MMM-Stock”,
      position: “bottom_right”,
      config: {
      companies: [“SPY”, “GME”, “AMC”, “NOK”, “BB”]
      }
      },

      posted in Troubleshooting
      B
      brendan_c23
    • RE: MMM-Stock Cannot read property 'toLowerCase'

      @sdetweil Load script: modules/MMM-Stock//MMM-Stock.js
      module.js:517 Module registered: MMM-Stock
      loader.js:148 Bootstrapping module: MMM-Stock
      loader.js:153 Scripts loaded for: MMM-Stock
      loader.js:195 Load stylesheet: modules/MMM-Stock/MMM-Stock.css
      loader.js:155 Styles loaded for: MMM-Stock
      loader.js:157 Translations loaded for: MMM-Stock

      posted in Troubleshooting
      B
      brendan_c23
    • RE: MMM-Stock Cannot read property 'toLowerCase'

      @sdetweil They should be, but just in case Im missing something…

      Module.register(“MMM-Stock”, {
      result: {},
      defaults: {
      updateInterval: 60000,
      fadeSpeed: 1000,
      companies: [“GOOGL”, “YHOO”],
      currency: “usd”,
      baseURL: “https://www.alphavantage.co/”,
      apikey: “IPWULBT54Y3LHJME”
      },

      getStyles: function() {
      	return ["MMM-Stock.css"];
      },
      
      getTranslations: function() {
      	return false;
      },
      
      start: function() {
      	this.getStocks();
      	if(this.config.currency.toLowerCase() != "usd"){
      		this.getExchangeRate();
      	}
      	this.scheduleUpdate();
      },
      
      getDom: function() {
      	var wrapper = document.createElement("div");
      	wrapper.className = "quotes";
      	var list = document.createElement("ul");
      
      	var data = this.result;
      	// the data is not ready
      	if(Object.keys(data).length === 0 && data.constructor === Object){
      		return wrapper;
      	}
      
      	//if another currency is required - usd is default
      	var differentCurrency = false;
      	if(this.config.currency.toLowerCase() != "usd"){
      		differentCurrency = true;
      		var requiredCurrency = this.config.currency.toUpperCase();
      	}
      
      	for (var key in data) {
      		if (!data.hasOwnProperty(key)) {continue;}
      		var symbol = key;
      		var obj = data[key];
      		var current = obj[0];
      		var prev = obj[1];
      		var price = current["4. close"];
      		var change = prev["4. close"] - current["4. close"];
      
      		var html = "";
      		var priceClass = "greentext", priceIcon="up_green";
      		if(change < 0) {
      			priceClass = "redtext";
      			priceIcon="down_red";
      		}
      		html = html + "<span class='" + priceClass + "'>";
      		html = html + "<span class='quote'> (" + symbol + ")</span> ";
      		html = html + parseFloat(price).toFixed(2) + " USD";
      		html = html + "<span class='" + priceIcon + "'></span>" + parseFloat(Math.abs(change)).toFixed(2);
      
      		var stock = document.createElement("span");
      		stock.className = "stockTicker";
      		stock.innerHTML = html;
      
      		var listItem = document.createElement("li");
      		listItem.innerHTML = html;
      		list.appendChild(listItem);
      	}
      
      	wrapper.appendChild(list);
      	return wrapper;
      },
      
      scheduleUpdate: function(delay) {
      	var loadTime = this.config.updateInterval;
      	if (typeof delay !== "undefined" && delay >= 0) {
      		loadTime = delay;
      	}
      
      	var that = this;
      	setInterval(function() {
      		that.getStocks();
      		if(that.config.currency.toLowerCase() != "usd"){
      			that.getExchangeRate();
      		}
      	}, loadTime);
      },
      
      getStocks: function () {
      	var allCompanies = this.config.companies;
      	var urls = [];
      	for(var company in allCompanies){
      		var url = this.config.baseURL + "query?function=TIME_SERIES_DAILY&outputsize=compact&symbol=" + allCompanies[company] + "&apikey=" + this.config.apikey;
      		urls.push(url);
      	}
      	this.sendSocketNotification("GET_STOCKS", urls);
      },
      
      getExchangeRate: function () {
      	var url = this.config.baseURL + "?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20('USD" + this.config.currency + "')&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback="
      	this.sendSocketNotification("GET_EXCHANGE_RATE", url);
      },
      socketNotificationReceived: function(notification, payload) {
      	if (notification === "STOCK_RESULT") {
      		this.result = payload;
      		this.updateDom(self.config.fadeSpeed);
      	} else if(notification === "EXCHANGE_RATE"){
      		this.rate = payload;
      	}
      }
      

      });

      posted in Troubleshooting
      B
      brendan_c23
    • RE: MMM-Stock Cannot read property 'toLowerCase'

      @sdetweil No errors have come up, but it also has not displayed, have been waiting for around 10 minutes

      posted in Troubleshooting
      B
      brendan_c23