CommonSense PHP API Library
Sensor Class Reference

List of all members.

Public Member Functions

 Sensor (stdClass $data, Api $api)
 getID ()
 getOwner ()
 getName ()
 getDeviceType ()
 update ($name, $displayName, $deviceType, $pagerType, $dataType, $dataStructure)
 delete ()
 getData ($page, $perPage, $startDate, $endDate, $date, $next, $last, $sort, $total, $interval=0)
 updateData ($value, $date)
 deleteData ($dataID)
 uploadDataAsJson ($json)
 getDevice ()
 getMyDevice ()
 getEnvironment ()
 addSharredUser ($userID, $userID)
 removeSharredUser ($userID)
 connectSensor ($connectedSensorID)
 removeConnectedSensor ($connectedSensor)
 disconnectFromService ($serviceID)
 getMetatags ()
 listTags ($namespace=NULL)
 replaceTags ($metatags, $namespace=NULL)
 updateTags ($metatags, $namespace=NULL)
 deleteTags ($namespace=NULL)

Detailed Description

sense dashboard - Sensor.php

This file is part of sense dashboard.

Author:
Remi Appels <remi@sense-os.nl> The class Sensor handels all the sensor actions

public

Author:
Remi Appels <remi@sense-os.nl>

Member Function Documentation

Sensor::addSharredUser ( userID,
userID 
)

This method will add a user to a sensor, giving the user access to the sensor and data. Only the owner of the sensor is able to upload data, mutate sensors and add users to their sensor. To add a user at least a username or user_id must be specified.

public

Parameters:
intuserID
stringusername
Returns:
mixed
Sensor::connectSensor ( connectedSensorID)

This method connects a sensor to the sensor selected with <sensor_id>. The type of the selected sensor will be automatically set to 2 (virtual sensor).

public

Parameters:
intconnectedSensorID
Returns:
mixed

This method will delete a sensor. If the current user is the owner of the sensor then the sensor will be removed from the current user and all other users. If the current user is not owner of the sensor then access to the sensor will be removed for this user.

public

Returns:
mixed
Sensor::deleteData ( dataID)

This method deletes a data point

public

Parameters:
intdataID
Returns:
mixed
Sensor::deleteTags ( namespace = NULL)

Delete sensor tags

This method will delete all the metatags for the given sensor in the given namespace

public

Parameters:
arraymetatags an array with the metatags
stringnamespace (optional) Attach metatags to the given namespace. If not given “default” is assumed as the namespace.

This method disconnects the parent sensor from the service. The service will be stopped if it's not used by other sensors.

public

Parameters:
intserviceID
Returns:
mixed
Sensor::getData ( page,
perPage,
startDate,
endDate,
date,
next,
last,
sort,
total,
interval = 0 
)

This method will return a list of sensor data. The maximum amount of data points that can be retrieved at once are 1000 items.

public

Parameters:
intpage
intperPage
DatestartDate
DateendDate
Datedate
intnext
Booleanlast
stringsort
Booleantotal
Returns:
json object (max 1000 items)

The method returns the details of the environment of this sensor.

public

Returns:
mixed

Return metatags

public

Returns:
array An array with the metatags

This method returns the details of the device to witch the sensor is connected.

public

Returns:
Device
Sensor::listTags ( namespace = NULL)

List sensor tags

This method will return a list of metatags attached to the given sensor.

public

Returns:
mixed An array of metatags which consists of a key and an array of strings and/or integers
Sensor::removeConnectedSensor ( connectedSensor)

This method removes a sensor from the parent sensor. If the parent sensor does not have any sensors that it uses, its type will automatically be set to 0. If this parent sensor is also a service, then the connected sensor will also be disconnected from the service.

public

Parameters:
intconnectedSensor
Returns:
mixed

This method removes a users from a sensor, which removes the access to the sensor for this user.

public

Parameters:
intuserID
Returns:
mixed
Sensor::replaceTags ( metatags,
namespace = NULL 
)

Replacing sensor tags

This method will persist a list of metatags to the given sensor. All metatags that are not mentioned in the uploaded list are removed from the sensor. Metatag names can have a maximum length of 32 (ASCII) characters. The metatag value can have a maximum length of 100 (UTF-8) characters. For now we impose a limit on the amount of metatags attached to a sensor in a single namespace. Currently this is set on 30.

public

Parameters:
arraymetatags an array with the metatags
stringnamespace (optional) Attach metatags to the given namespace. If not given “default” is assumed as the namespace.
Sensor::Sensor ( stdClass $  data,
Api api 
)
Sensor::update ( name,
displayName,
deviceType,
pagerType,
dataType,
dataStructure 
)

This method will update an existing sensor.

public

Parameters:
stringname
stringdisplayName
stringdeviceType
stringpagerType
stringdataType
stringdataStructure
Returns:
mixed
Sensor::updateData ( value,
date 
)

With this method sensor data can be uploaded. The uploaded data can either be a single value or an array.

public

Parameters:
stringvalue
Datedate
Returns:
mixed
Sensor::updateTags ( metatags,
namespace = NULL 
)

Modifying sensor tags

This method will persist a list of metatags. Existing metatags not mentioned in the uploaded list will be kept. Metatag names can have a maximum length of 32 (ASCII) characters. The metatag value can have a maximum length of 100 (UTF-8) characters. For now we impose a limit on the amount of metatags attached to a sensor in a single namespace. Currently this is set on 30. For now we impose a limit on the amount of metatags attached to a sensor in a single namespace. Currently this is set on 30.

public

Parameters:
arraymetatags an array with the metatags
stringnamespace (optional) Attach metatags to the given namespace. If not given “default” is assumed as the namespace.

With this method sensor data can be uploaded at once for different sensors. The uploaded data can either be a single value or an array.

public

Parameters:
stringjson
Returns:
mixed

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables