add initial project files.
This commit is contained in:
22
sbin/update.php
Normal file
22
sbin/update.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
define('APPDIR', dirname(__DIR__));
|
||||
|
||||
require_once APPDIR.'/vendor/autoload.php';
|
||||
|
||||
$config = json_decode(file_get_contents(APPDIR.'/etc/config.json'), true);
|
||||
|
||||
$digitemp = new \Orrisroot\DigiTemp($config['digitemp'], APPDIR.'/'.$config['digitemp_config']);
|
||||
$rrdtemp = new \Orrisroot\Rrd\Temperature(APPDIR.'/'.$config['database_dir']);
|
||||
$num = $digitemp->getNumSensors();
|
||||
for ($i = 0; $i < $num; ++$i) {
|
||||
$id = $digitemp->getSensorId($i);
|
||||
$value = $digitemp->readSensor($i);
|
||||
$rrdtemp->addSensor($id);
|
||||
$now = time();
|
||||
$rrdtemp->update($id, $now, $value);
|
||||
}
|
||||
foreach ($types = ['hour', 'day', 'week', 'month', 'year', '3year'] as $type) {
|
||||
$fpath = APPDIR.'/'.$config['images_dir'].'/graph-'.$type.'.png';
|
||||
$rrdtemp->outputGraph($type, $fpath);
|
||||
}
|
Reference in New Issue
Block a user