-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
26 lines (20 loc) · 866 Bytes
/
Copy pathexample.php
File metadata and controls
26 lines (20 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
require __DIR__.'/../vendor/autoload.php';
use \Moay\OpensensemapApiClient\OpensensemapApiClientFactory;
use \Moay\OpensensemapApiClient\SensorValue\SensorValue;
$client = OpensensemapApiClientFactory::create();
$senseBoxData = $client->getSenseBoxData('5a0c2cc89fd3c200111118f0');
foreach ($senseBoxData as $sensorValue) {
echo sprintf(
'%s: %s %s (Sensor: %s, %s)'."\n",
$sensorValue->getValueType(),
$sensorValue->getValue(),
$sensorValue->getUnit(),
$sensorValue->getSensorType(),
$sensorValue->getMeasurementTime()->format('Y-m-d H:i:s')
);
}
$temperature = $senseBoxData->getValueByType(SensorValue::TYPE_TEMPERATURE);
echo 'Temperature by type: '.$temperature->getValue().' '.$temperature->getUnit()."\n";
// Shorthand string output
echo 'Temperature by type shorthand: '.$temperature."\n";