Giter Site home page Giter Site logo

id872 / devmon Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.05 MB

Saving and presenting device data from encrypted POST data

License: MIT License

CSS 1.32% JavaScript 5.99% PHP 92.69%
data logging mysql php chart presentation devices sensors decryption aes data-logger airpurifier xiaomi-smart-home ds18b20 tasmota-devices tuya-smart tuya-convert

devmon's Introduction

devmon

Saving and presenting device data from encrypted POST data.

What is it and what is for?

It is a web application for saving and presenting sensors/devices readouts received from encrypted JSON request. You can see this project: https://github.com/id872/data_logger for more details. Decrypted devices data readouts are inserted into DB. Charts are generated with using Chart.js library.

See demo app.

The application works with data from the following devices:

This is personal project. It has been implemented mainly for tracking a performance of my solar installation. Another devices were added in a further implementation. Feel free to fork and improve according to your needs.

Summary, features, general info

The application has two main goals – Save devices data in the DB and present devices data in graphical form (with using the Chart.js library).

The application decrypts encrypted JSON POST data and inserts devices data into MySQL DB. Charts are generated from data stored in the DB. Application structure was divided into two sections:

  1. Sql – containing SQL Request class definition for SQL query execution and device data getters.
  2. Chartgenerators – here are generators for devices data presentation in graphical form. The device data is taken from SQL tables. Chart data is prepared as JSON format for Chart.js library.

There is no need to refresh page to change data scope or type. It works with AJAX requests.

To handle new device data for saving/presentation, following need to be done:

  • (DeviceDataSaver.php) insert function for new device data has to be created and used
  • (SQL DB) new device must be added into “devices” table, new device data type must be added into “dev_data_type” table, readouts table for new device must be created
  • (1) device data getter implementation
  • (2) chart data generator implementation

For sure there is a room for improvement to simplify it, but for now it has to be done in that way.

SQL DB is defined to handle many devices from many users. See the sql_create.sql in the sql_db. SQL DB configuration sql_db.ini is in the sql_db. It is used by SqlRequest.php.

“users” table contains api_hash used to determine api_key for data decryption for particular user. At the logger side (which prepares encrypted JSON request) need to be the same pair defined in a configuration, otherwise the devices data will not be decrypted and stored in DB – please see the device logger project for details. There is also user_password_hash (bcrypt hash) for additional authentication – required only for inserting data into DB. You can see an authentication steps in the add.php file. Check also .htaccess where rewrite engine rules were defined.

Devices names defined in a logger configuration must be the same as those defined in the DB.

Data presentation - examples

Solar data

Solar power production statistics

DS18B20 temperature sensor data

Xiaomi AirPurifier data

Tasmota Plug data

devmon's People

Contributors

id872 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.