• 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. alihallo
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
A
Offline
  • Profile
  • Following 0
  • Followers 0
  • Topics 1
  • Posts 5
  • Groups 0

alihallo

@alihallo

0
Reputation
561
Profile views
5
Posts
0
Followers
0
Following
Joined Aug 15, 2016, 10:04 AM
Last Online Aug 28, 2021, 12:00 PM

alihallo Unfollow Follow

Latest posts made by alihallo

  • RE: Motion Detector

    First of all, I also had the problem which could be solved by adding

    @reboot sudo modprobe bcm2835-v4l2
    

    at the last line of the crontab. Thank you very much!

    It works fine for some hours, but suddenly the monitor does not show up again.
    I cannot see error messages, but the following commands does not get an answer anymore…

    /opt/vc/bin/tvservice -s
    

    There is no return value anymore, it is just loading forever.
    In the log it looks like this:

    mm-0 monitor :state 0x12000a [HDMI CEA (16) RGB lim 16:9], 1920x1080 @ 60.00Hz, progressive
    mm-0 monitor has been activated
    mm-0 monitor :state 0x120002 [TV is off]
    mm-0 monitor has been deactivated
    mm-0 monitor :state 0x12000a [HDMI CEA (16) RGB lim 16:9], 1920x1080 @ 60.00Hz, progressive
    mm-0 monitor has been activated
    mm-0 monitor :state 0x120002 [TV is off]
    mm-0 monitor has been deactivated
    mm-0 monitor :state 0x12000a [HDMI CEA (16) RGB lim 16:9], 1920x1080 @ 60.00Hz, progressive
    mm-0 monitor :
    mm-0 monitor :
    mm-0 monitor has been deactivated
    mm-0 monitor :
    

    As soon as the problem occures, the command

    /opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 7
    

    also does not switch the monitor on again.
    It seems that the tvservice command just got a problem after some hours… Any idea how to solve this?
    I need to restart the pi to get the monitor on again, after that everything works fine for some hours…

    Best regards,
    alihallo

    posted in Utilities
    A
    alihallo
    Sep 11, 2016, 4:57 PM
  • RE: Parse HTML String

    @strawberry-3-141 You are absolutly right, I made a bad example. The real html code is a little bit more complicated, so I mixed the real code with this example.
    @ianperrin My input html is more complicated, but thanks for your answer, good to know!

    @Plati It helped me a lot to look at other modules. You should use a node_helper.js, there you can create a function which gets the html code of the website.

    //function which gets the data from the given URL
    getTheData: function(theURLtoCatch) {
       var options = {url: theURLtoCatch};
       request(options, (error, response, body) => {
          if (response.statusCode === 200) {
             this.sendSocketNotification("DATA", this.parseHTML(body));
          } else {
             console.log("Error getting Data " + response.statusCode);
             this.sendSocketNotification("ERROR", response.statusCode);
          }
       });
    },
    
    parseHTML: function(dataBody) {
       //use something like ianperrin and strawberry showed in his example
    
    }
    
    posted in Development
    A
    alihallo
    Sep 11, 2016, 12:29 PM
  • RE: Parse HTML String

    Thank you for your answer, but I coudn’t find out how to use the NPM request to parse the html code.
    But I found another solution to solve the issue:

    https://github.com/cheeriojs/cheerio

    This way I could get the data out of the html code like this:

    var options = {url: URL};
            request(options, (error, response, body) => {
                if (response.statusCode === 200) {
                    this.sendSocketNotification("DATA", this.parseData(body));
    
    
    ...
    
    
    var $ = cheerio.load(body, {
       normalizeWhitespace: true,
       xmlMode: false
    });
    		
    $('div[class=data_1]').find('p').each(function (index, element) {
    	data_array.push($(element).text());
    });
    

    This way I could solve my problem.

    Best regards,
    alihallo

    posted in Development
    A
    alihallo
    Aug 29, 2016, 7:54 PM
  • Parse HTML String

    Currently I try to create my first little module and could need a hint from an experienced person.
    In my node_helper.js I request the html code from an simple website by using:

    var options = {url: URL};
            request(options, (error, response, body) => {
                if (response.statusCode === 200) {
                    this.sendSocketNotification("DATA", this.parseData(body));
    

    So in the variable body there is something like

    <head>
    ...
    </head>
    <body><a name="top"></a>
       <div id="data_1">
          <p>The relevant data 1</p>
       </div>
       <div id="data_2">
          <p>The relevant data 2</p>
       </div>
    ...
    

    My question is: What would you recommend to get the relevant data from this body into an local variable?
    I first thought to use javascript & regex, but I guess that is not a good way to solve the issue, isn’t it?

    Best regards,
    alihallo

    posted in Development
    A
    alihallo
    Aug 21, 2016, 11:54 AM
  • RE: Weatherunderground - currently - hourly - daily - configurable

    @yo-less Your changes look great, would it be possible to provide the code?

    posted in Troubleshooting
    A
    alihallo
    Aug 19, 2016, 10:22 PM
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