Sirowa warehouse sensor temperature and humidity data visualization logserver.
- Download/
git clone
the project - Create
.env
file from.env_template
file and adjust parameters - Run
composer install
in root folder to generate dependencies and autoloading. If the command throws error 'Root composer.json requires PHP extension ext-soap ...
' uncommentextension=soap
attribute in thephp.ini
global PHP config file. - Open terminal and
cd site
- (if you have data files) Copy
backupCSV
folder tosite/db
and generate db with sample dataphp -r "require './db/Initializer.php'; App\db\Initializer::Initialize();"
. If the command throws a "Fatal error: Uncaught PDOException: could not find driver in ..." error, uncommentextension=pdo_mysql
inphp.ini
. - Start php server by running command
php -S localhost:8080
- Open in browser http://127.0.0.1:8080
Possible errors:
- No database access - Go into your
php.ini
file and uncommentextension=pdo_mysql
- Follow 1. and 2. step from local install
- Run
docker-compose --env-file ../.env up -d
indocker
directory - Install dependencies
docker-compose exec tempsens-app composer install
- Open in browser http://127.0.0.1:8000
- phpdotenv - Loads environment variables from
.env
togetenv()
,$_ENV
and$_SERVER
automagically. - Slim - PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
- Symfony/Serializer and PropertyAccess - hydrated JSON deserialization to class instance
- Illuminate/Support/Collection - Convenient array methods
- Ramsey/Uuid - database table row UUID ID generator
- Reset CSS - Cross browser style inconsistency remover
- Bootstrap Icons - Different icons (class tags
bi bi-
) - jQuery - Needed for jQuery UI
- jQuery UI - Cross browser identical calendar/datepicker, kinda stupid for such a simple thing
- bootstrap - HTML, CSS and JavaScript framework, Used components: collapsable, modal
- Google Chart (charts/loader.js) - Drawing charts
- Day.js (with plugins: customParseFormat) - date parsing, needed for chart data manipulation
IT documentation - Temperature and Humidity Monitoring in the Baltic Warehouse [link]
Documentation for physical sensor API and Tempsens logserver API:
API Documentation
+------------------------------------+ +---------------------------------------------+
| Sensors | | SensorReading |
+--------------+---------------+-----+ +--------------+----------------+-------------+
| id | string! | PK | | id | string! | PK |
| name | string! | |1....*| sensor_id | string! | FK(sensors) |
| serial | string! | | | temp | decimal(18,1)! | |
| model | string! | | | rel_hum | decimal(18,1)! | |
| ip | string! | | | date_recorded| string! | |
| location | string! | | | date_added | string? | |
| is_portable | bool! | | +--------------+----------------+-------------+
| min_temp | decimal(18,1)!| |
| max_temp | decimal(18,1)!| |
| min_rel_hum | decimal(18,1)!| |
| max_rel_hum | decimal(18,1)!| |
| reading_inter| int! | |
+--------------+---------------+-----+
Date format is YYYYMMDDHHmm. This makes ordering SensorReadings by date easy (eg 13:42, 13.03.2021 becomes 202103131342)
DateAdded is null
for not isPortable sensors.
Script site/db/Initializer.php
generates new database tables and imports data from local CSV files.
Modify the script to fit your needs then run php Initializer.php
to execute the script.
Sample CSV data files are available on request [link].
Create directory site/db/backupCSV
and place the data there.
Sample CSV data files are available on request [link] to test portable sensor's sensor readings import functionality.
Api request endpoint and body is described in API.
Versioning follows major.minor.patch three digit numbering:
- major - Breaking database changes
- minor - API changes or 5+ patch changes worth documenting
- patch - Small tweaks
15.01.2020 by Indrek Hiie - Soap Data Collector
27.02.2020 by Timm Soodla - initial GUI version
30.12.2020 by Indrek Hiie - moved to PDO MySQL driver, sensors now in DB, more modular code and some bugfixes applied
24.01.2021 - watchdog added
Notes:
- Remade database (removed: alarms, emails, emails_to_sensor, parms, portable and queue. Redesigned sensor and sensorReading)
- Removed unnecessary values sent by sensors from being saved to sensorReading
- Removed scripts/alarms.php - Email sending didn't work
- Removed confusing alerts(global vs sensor) and Max/min(total vs sensor)
- Removed ambiguous sensor state .png balls in v0.3.5
- Removed unused Composer dependencies(php-jwt, Guzzle, oauth2-client, random_compaq, Phpmailer, http-message, getallHeaders, oauth-keycloak, Symfony)
- Replaced Db generated int Ids with server-side 22 char base64 random generated ones
- Added Db default data initialization script and migrations
- Now all sensors are shown together and can be graphed together
- Added relative humidity to overview and graph
- Fixed bugs with selecting end date changing start date value
- Added CRUD functionality to sensor
- Added cache file for fast last sensor readings
- Added options for chart drawing
- Added option to export graph as screenshot
- Added option to upload CSV data to portable sensors
- Restructured code
- Separated views and controllers, following MVC design
- Added partial views
- Created favicon
- Used new PHP 8.0 and below features (function parameter and return types, named arguments, constructor property promotion)
Made with ❤️ by Karl Oskar Anderson
Notes:
- Update UI - Sensor info (Alerts, Actions, Details) are organized into clickable
nav
element buttons - Change database table collation to binary. All field comparisons are now case-sensitive.
- Remove dependency from existing database:
- Update environment variable reading
- Change database initializer to work with CSV files
- Refactor code, increase readability
- Fix a bug causing alert packing to result in a null pointer exception
Made with ❤️ by Karl Oskar Anderson
Notes:
- Used REST API for cleaner controllers
- Minor UI tweaks to sensor alert view
- Reduced memory usage
- Removed cache file
- Refactored project structure
Notes:
- Changed database table ID to UUIDv4 and time fields to ISO8601
- Switched all times to UTC timezone to remove false alert due to daylight savings
- Added support for missing readings alerts