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

wolkenaj

@wolkenaj

0
Reputation
465
Profile views
3
Posts
0
Followers
0
Following
Joined Mar 21, 2018, 2:29 AM
Last Online Apr 9, 2018, 4:38 AM

wolkenaj Unfollow Follow

Latest posts made by wolkenaj

  • RE: Displaying data from MySQL database

    @ninjabreadman This was very helpful to get a node helper function up and running. I am able to receive a socket notification and run a function based on the notification. My program in the node helper currently looks like

    activateShell: function(){
         console.log("Activating shell");
         exec("/Test -s");
    }
    

    I receive the activating shell in the console but the script (a simple echo “Hello World”) does not execute. I’ve tried placing it in my module folder, the Magic Mirror folder, and as a path in the desktop, all to no avail. Would you have any ideas on what is wrong?

    posted in Development
    W
    wolkenaj
    Mar 30, 2018, 7:29 PM
  • RE: Displaying data from MySQL database

    @cirdan Thank you for this tidbit. I was aware that I would need a node helper. I think my preferred course would be to call the php file from the node helper. I will eventually need to also call a bash script from my node helper if possible as well. Do you know of a module that does a similar call that I could look at for reference?

    posted in Development
    W
    wolkenaj
    Mar 27, 2018, 9:00 PM
  • Displaying data from MySQL database

    Hello! I am quite new to MagicMirror and trying to display personal data from a MySQL database (stored on amazon cloud) in text and graphs on my mirror. I currently have a mixture of html and php files to access the data and display on a website. I would like to transfer the functionality but am unsure how to do so in a compatible way.
    I currently doing so with php:

    	$db = mysqli_connect(REDACTED) or die('Error connecting to MySQL server.');
    	//the SQL query to be executed
    	$query = "SELECT * FROM table";
    	//storing the result of the executed query
    	$result = $db->query($query);
    	//initialize the array to store the processed data
    	$jsonArray = array();
    	//check if there is any data returned by the SQL Query
    	if ($result->num_rows > 0) {
    	  //Converting the results into an associative array
    	  while($row = $result->fetch_assoc()) {
    		  $date= $row['timestamp'];
    	    $jsonArrayItem = array();
    	    $jsonArrayItem['label'] = $date;
    	    $jsonArrayItem['value'] = $row['columnName'];
    	    //append the above created object into the main array.
    	    array_push($jsonArray, $jsonArrayItem);
    	  }
    	}
    	//Closing the connection to DB
    	$db->close();
    	//set the response content type as JSON
    	header('Content-type: application/json');
    	//output the return value of json encode using the echo function. 
    	echo json_encode($jsonArray);
    ?>
    

    And then displaying with Fusion charts:

    $(function(){
    	  $.ajax({
    	    url: 'http://REDACTED',
    	    type: 'GET',
    	    success : function(data) {
    	      chart1Data = data;
    	      var chart4Properties = {
    	        "caption": " ",
    	        "xAxisName": "Date",
    	        "yAxisName": " ",
    	        "rotatevalues": "1",
    	        "theme": "zune"
    	      };
    	      api4Chart = new FusionCharts({
    	        type: 'column2d',
    	        renderAt: 'chart4-container',
    	        width: '550',
    	        height: '350',
    	        dataFormat: 'json',
    	        dataSource: {
    	          "chart": chart4Properties,
    	          "data": chart1Data
    	        }
    	      });
    	      api4Chart.render();
    	    }
    	  });
    	});
    

    Any help would be appreciated. If there is any other information I can provide, please let me know. Thank you :)

    posted in Development
    W
    wolkenaj
    Mar 21, 2018, 2:42 AM
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