Skip to content

A client for retrieving sensor data from a senseBox from the opensensemap api

License

Notifications You must be signed in to change notification settings

moay/opensensemap-api-php-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

travis-ci-status

opensensemap-api-php-client

A lightweight client for retrieving sensor data from a senseBox from the opensensemap api.

This is not an official project from the senseBox team.

Setup

Install via composer:

composer require moay/opensensemap-api-php-client

Usage

Take a look at the implementation example in the directory example.

$client = OpensensemapApiClientFactory::create();

// Change senseBox id
$senseBoxData = $client->getSenseBoxData('someSenseBoxId');

foreach ($senseBoxData as $sensorValue) {
    // $sensorValue->getValueType()
    // $sensorValue->getValue()
    // $sensorValue->getUnit()
    // $sensorValue->getSensorType()
    // $sensorValue->getMeasurementTime()->format('Y-m-d H:i:s')
}

You don't have to iterate over all values, just use this handy function:

$temperature = $senseBoxData->getValueByType(SensorValue::TYPE_TEMPERATURE);

Outputting values can be done directly by casting the values to strings:

echo 'Temperature: '.$temperature; // Output: Temperature: 12 °C
echo $temperature; // Output: 12 °C
$temperatureString = (string) $temperature // $temperatureString = '12 °C' 

Features

The client gives you the latest data for a specific senseBox from the OpenSenseMap Api.

As there was no need for further features, none have been implemented. This could easily be done, though. Feel free to submit a PR.

License

The client is published under the MIT license.

senseBox and all related contents, visuals and brands are published under CC licenses or other public domain licenses. Make sure to check out the project.

About

A client for retrieving sensor data from a senseBox from the opensensemap api

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages