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

    Posts

    Recent Best Controversial
    • RE: How to Change MMM-DWD-WarnWeather Module for Switzerland

      @strawberry-3-141 thank you for your fast and competent answer.

      This is what i did now:

      
      ......
      
      request ( {
                url: url,
                method: 'GET'
      		  }, 
      
                 function (error, response, body) {
      
      			var result = JSON.parse(body);
      			var warningData = [];
      			
      			for (var regionId in result['alarms']) {
      
                      			if (result['alarms'][regionId]['regions'][0]['name_de'] == region) {
      					var warnings = new Object();
      					warnings.start = result['alarms'][regionId]['valid_from'];
      					warningData.push(warnings.start);
      					warnings.end = result['alarms'][regionId]['valid_to'];
      					warningData.push(warnings.end);
      					warnings.regionName = result['alarms'][regionId]['regions'][0]['name_de'];
      					warningData.push(warnings.regionName);
      					warnings.level = result['alarms'][regionId]['priority']
      					warningData.push(warnings.level);
      					warnings.type = result['alarms'][regionId]['code']
      					warningData.push(warnings.type);
      					warnings.altitudeStart = undefined;
      					warningData.push(warnings.altitudeStart);
      					
      					if (warnings.type == 1){warnings.event = "Frost";}
      					else if (warnings.type == 2){warnings.event = "Gewitter";}
      					else if (warnings.type == 3){warnings.event = "Grossflächige Glätte";}
      					else if (warnings.type == 4){warnings.event = "Kräftiger Regen";}
      					else if (warnings.type == 5){warnings.event = "Schnee";}
      					else if (warnings.type == 6){warnings.event = "Sturm";}
      					else if (warnings.type == 7){warnings.event = "Hochwasser";}
      
      					warningData.push(warnings.event);
      
      					warnings.headline = result['alarms'][regionId]['de']['title'];
      					warningData.push(warnings.headline);
      					warnings.description = result['alarms'][regionId]['de']['paragraph'];
      					warningData.push(warnings.description);
      				}
      			}
      			self.sendSocketNotification('WARNINGS_DATA', {warnings: warningData, region: region});
      
      			console.log(warnings);
      			console.log(warningData)
      
      		});
      
                .......
      
      

      Now i got the following outputs:

      // With console.log(warnings);
      
      { start: '2017-01-16T21:00:00.000Z',
        end: '2017-01-19T00:00:00.000Z',
        regionName: 'Seeland/Bielersee',
        level: 1,
        type: 6,
        altitudeStart: undefined,
        event: 'Sturm',
        headline: 'Starke Windböen',
        description: 'eisige Bise. 21 Uhr bis Do 00 Uhr' }
      
      // With console.log (warningData)
      
      [ '2017-01-17T00:00:00.000Z',
        '2017-01-18T23:00:00.000Z',
        'Seeland/Bielersee',
        1,
        3,
        undefined,
        'Grossflächige Glätte',
        'Gefahr von grossflächiger Glätte',
        'durch Schneeglätte. Di 00 Uhr bis Mi 23 Uhr',
        '2017-01-16T21:00:00.000Z',
        '2017-01-19T00:00:00.000Z',
        'Seeland/Bielersee',
        1,
        6,
        undefined,
        'Sturm',
        'Starke Windböen',
        'eisige Bise. 21 Uhr bis Do 00 Uhr' ]
      

      My Problem now is that my Output is still looking different than his output. And when i get 2 warnings for the same Region the Output goes into the same Array… By the Way… Why i get only one Warning for the region with console.log(warnings);

      Here is the Output example of his module:

      [ { start: 1484586000000,
          end: 1484650800000,
          regionName: 'Kreis Harburg',
          .....
          state: 'Niedersachsen' 
        },
        { start: 1484586000000,
          end: 1484650800000,
          regionName: 'Kreis Harburg',
          .......
          state: 'Niedersachsen' 
          }
       ]
      
      posted in Development
      S
      Squirrel
    • RE: How to Change MMM-DWD-WarnWeather Module for Switzerland

      Ok i understand. But i have problems to transfer this to my module.

      the simplified structure of my json looks like this:

      result = {
          "alarms": [ {
               "id":49664,
               ...
               "regions": [
                     {
                     "id":40,
                     "name_de":"Agglo BE",
                     "name_fr":"Agglo BE",
                     "name_it":"Agglo BE"
                      }
                ],
               ...
            },
            
       }
      

      Now i tried as a first test to display some stuff of my JSON.

      var regionId = 0; // Later i want to create a for-loop with this
      
      console.log (result['alarms'][regionId]['regions']);
      

      With this i got something like:

      "id":40,
       "name_de":"Agglo BE",
       "name_fr":"Agglo BE",
       "name_it":"Agglo BE"
      

      But then i tried

      console.log (result['alarms'][regionId]['regions']['name_de']);
      
      AND
      
      console.log (result['alarms'][regionId]['regions'][1]);
      

      But this gives me undefined as answer… I dont understand why…?
      Very strange is also that i no more see the regions when i delete the last bracket again… then i get [Object][Object]as Answer!? And when i Start again with only the [‘alarms’] Bracket i can see all the Warnings and then again also the regions with [‘alarms’][regionId][‘regions’]

      posted in Development
      S
      Squirrel
    • RE: White Screen after starting Magic Mirror

      i got it! When i change with alt + tab to the Terminal i can close the Terminal and that also Quits my mirror! Thanks!

      posted in Troubleshooting
      S
      Squirrel
    • RE: White Screen after starting Magic Mirror

      No. Ctrl + q is not working… It works when the mirror is running but with my white screen it is now more possible to quit it with this command…

      posted in Troubleshooting
      S
      Squirrel
    • RE: White Screen after starting Magic Mirror

      Yes i work on raspberry directly. Sadly i did mot found a way to test my work on my mac!? Ok thanks! alt + tab is working. But it still s**** a bit when i have to restart my raspberry after ever fault i did…

      posted in Troubleshooting
      S
      Squirrel
    • RE: How to Change MMM-DWD-WarnWeather Module for Switzerland

      I still need help. Maybe someone else can help me!? Here is the whole Part:

      getWarningData: function (region) {
      var self = this;

      	var timestamp = Date.now().toString();
      	var url = 'http://www.dwd.de/DWD/warnungen/warnapp_landkreise/json/warnings.json?jsonp=loadWarnings' + timestamp;
      
      
      
      	request({
      		url: url,
      		method: 'GET'
      	}, function (error, response, body) {
      
      		var result = JSON.parse(body.substr(24).slice(0, -2));
      		var warningData = [];
      		for (var regionId in result['warnings']) {
      			if (result['warnings'][regionId][0]['regionName'] == region) {
      				var warnings = [];
      				for (var warning in result['warnings'][regionId]) {
      					warnings.push(result['warnings'][regionId][warning]);
      				}
      				if (warnings.length > 0) {
      					warningData = warnings;
      				}
      			}
      		}
      		self.sendSocketNotification('WARNINGS_DATA', {warnings: warningData, region: region});
      

      Here is the JSON Link from @LukeCodewalker and this is the JSON Link i want to use for my Module.

      Dont give me too much help. I need to learn somthing but i stil don understand how is his request working (Line 32)…

      Line 32: if (result['warnings'][regionId][0]['regionName'] == region) };

      posted in Development
      S
      Squirrel
    • White Screen after starting Magic Mirror

      I try to build my own Module. When i start the MagicMirror now i get a blank white screen and i cant Quit the mirror no more. The only way to quit is a restart. but that sucks because i want to read the Terminal. When i Open Terminal then i get a new blank Terminal. How can i Quit the Terminal or how can i see my other Open Windows behind the Mirror?

      posted in Troubleshooting
      S
      Squirrel
    • RE: How to Change MMM-DWD-WarnWeather Module for Switzerland

      It looks like this is a lot of work. ;) After watching 100s of videos and reading 1000s of tutorials i can read now the most of your code and i know that its not that easy as i was thinking. I dont give up but there are still some lines i dont understand. It looks like i need more help for the request in node_helper.
      Can you tell me what the following Line is exactly doing?

      Line 32: if (result['warnings'][regionId][0]['regionName'] == region) };

      i dont understand why you use 4x [ ]. What i think to understand is that you search for regionName in your object warnings. I can imaging for what you use regionId (what you buildet in the line before) but i have no idea forwhat the [0] is??

      posted in Development
      S
      Squirrel
    • How to Change MMM-DWD-WarnWeather Module for Switzerland

      @LukeCodewalker here we ;)

      and here is the Output i got from mitmproxy:

      curl -H ‘Host:my.wetteralarm.ch’ -H ‘Content-Type:application/json; charset=utf-8’ -H ‘Proxy-Connection:keep-alive’ -H ‘Weal-Device-ID:1015262’ -H ‘Accept:/’ -H ‘User-Agent:WetterAlarm/5.5.0 (iPhone; iOS 10.1.1; Scale/2.00)’ -H ‘Accept-Language:de’ -H ‘Accept-Encoding:gzip’ -H ‘Connection:keep-alive’ ‘http://my.wetteralarm.ch/v6/alarms/meteo/with-regions.json’

      posted in Development
      S
      Squirrel
    • RE: save some information from a xml or json to a txt file

      Hmm since i changed some things in node_helper.js my MagicMirror is no more working and i get the following ERROR:

      npm ERR! Linux 4.4.34-v7+
      npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “start”
      npm ERR! node v0.12.6
      npm ERR! npm v2.11.2
      npm ERR! code ELIFECYCLE
      npm ERR! magicmirror@2.0.0 start: electron js/electron.js
      npm ERR! Exit status 1
      npm ERR!
      npm ERR! Failed at the magicmirror@2.0.0 start script ‘electron js/electron.js’.
      npm ERR! This is most likely a problem with the magicmirror package,
      npm ERR! not with npm itself.
      npm ERR! Tell the author that this fails on your system:
      npm ERR! electron js/electron.js
      npm ERR! You can get their info via:
      npm ERR! npm owner ls magicmirror
      npm ERR! There is likely additional logging output above.

      npm ERR! Please include the following file with any support request:
      npm ERR! /home/pi/MagicMirror/npm-debug.log

      This is what i did in config.js:

      module: 'MMM-DWD-WarnWeather',
      position: 'bottom_right',
      header: 'Wetterwarnungen',
      config: {
          region: 'Seeland/Bielersee',					// Kreis Lörrach
          changeColor: true,
          interval: 10 * 60 * 1000, // every 10 minutes
          loadingText: 'Warnungen werden geladen...',
          noWarningText: 'Keine Warnungen'
      }
      

      },

      And here what i did in node_helper.js :

      getWarningData: function (region) {
      	var self = this;
      
      	var timestamp = Date.now().toString();
      	var url = 'http://my.wetter.ch/v6/alarms/meteo/with-regions.json' + timestamp;			// http://www.dwd.de/DWD/warnungen/warnapp_landkreise/json/warnings.json?jsonp=loadWarnings
      
      
      
      	request({
      		url: url,
      		method: 'GET'
      	}, function (error, response, body) {
      
      		var result = JSON.parse(body.substr(24).slice(0, -2));
      		var warningData = [];
      		for (var regionId in result['warnings']) {
      			if (result['warnings'][regionId][0]['name_de'] == region) {			// name_de = regionName 
      				var warnings = [];
      				for (var warning in result['warnings'][regionId]) {
      					warnings.push(result['warnings'][regionId][warning]);
      				}
      				if (warnings.length > 0) {
      					warningData = warnings;
      				}
      			}
      		}
      		self.sendSocketNotification('WARNINGS_DATA', {warnings: warningData, region: region});
      
      	});
      

      I changed the link and i changed regionName to name_de… Any idea? Hope this is gonna be my last Question ;)

      posted in Requests
      S
      Squirrel
    • 1
    • 2
    • 3
    • 2 / 3