MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    [MMM-MySQLData] Get values from mysql database

    Scheduled Pinned Locked Moved Utilities
    1 Posts 1 Posters 251 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      tabsl
      last edited by

      Description

      A MagicMirror² module to connect to a MySQL database, run a select query (one value) and display the result.

      Screenshots

      558532ad-9a8b-4bc0-9e89-3f431279051e-image.png

      Download

      https://github.com/tabsl/MMM-MySQLData

      Config example

      var config = {
          modules: [
              {
                  module: "MMM-MySQLData",
                  position: "top_center",
                  config: {
                      id: Math.floor(Math.random() * 100),
                      host: "YOUR_HOST",
                      username: "YOUR_USERNAME",
                      password: "YOUR_PASSWORD",
                      database: "YOUR_DATABASE_NAME",
                      port: 3306,
                      values: [
                          {
                              "id": "power_current",
                              "interval": 60000,
                              "title": "Current power consumption",
                              "praefix": "",
                              "suffix": " w",
                              "query": "SELECT round(data) AS value FROM power_consumption WHERE type = 'current' ORDER BY date DESC LIMIT 1",
                              "styles": {
                                  "ok": "< 100",
                                  "warn": "> 1000",
                                  "alert": ">= 10000"
                              }
                          },
                          {
                              "id": "power_total",
                              "interval": 720000,
                              "title": "Total power consumption",
                              "praefix": "",
                              "suffix": " kW",
                              "query": "SELECT round(data/1000) AS value FROM power_consumption WHERE type = 'total' ORDER BY date DESC LIMIT 1",
                          }
                      ]
                  }
              }
          ]
      }
      

      Changelog

      https://raw.githubusercontent.com/tabsl/MMM-MySQLData/main/CHANGELOG.md

      1 Reply Last reply Reply Quote 2
      • 1 / 1
      • First post
        Last post
      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