- Class Methods
- init
- tr50_date_format
- email_send
- locale_get
- locale_list
- locale_set
- location_current
- location_decode
- location_encode
- location_publish
- location_speedlimit
- location_weather
- method_exec
- org_find
- org_list
- property_aggregate
- property_current
- property_publish
- session_info
- session_org_list
- session_org_switch
- thing_def_find
- thing_def_list
- thing_find
- thing_list
- twilio_sms_send
- user_find
- user_list
TR50httpWorker.init([options])
Initialize the object, calls the constructor for the super class.
Name | Type | Required | Default | Description |
---|---|---|---|---|
options | Array | No | { } | A dictionary key value pairs used to initialize the object. |
Name | Type | Required | Default | Description |
---|---|---|---|---|
endpoint | String | No | The API endpoint for POSTing (e.g. https://www.example.com/api). | |
appId | String | No | The application identifier to used when authenticating as an application. | |
app_token | String | No | The application appToken to use when authenticating as an application. | |
thing_key | String | No | The thing key used to identify the application if authenticating as an application. | |
username | String | No | The username used to connect to the server if authenticating as a user. | |
password | String | No | The password used to connect to the server if authenticating as a user. | |
session_id | String | No | It is possible to reuse sessionIds between executions of the application that uses the library. |
None.
String = TR50httpWorker.tr50_date_format(date_obj)
Convert a date object to TR50 formatted string.
Name | Type | Required | Default | Description |
---|---|---|---|---|
date_obj | Object | Yes | The date object to reformat. |
The date formatted in the style that TR50 requires.
Boolean = TR50httpWorker.email_send(email_to, email_from, email_subject, email_body)
email.send sends an email to one or more email addresses from a registered user's email address in the M2M Service.
Name | Type | Required | Default | Description |
---|---|---|---|---|
email_to | Mixed | Yes | A single email address: '[email protected]', or an array containing the recipients of the email: ['[email protected]', '[email protected]']. | |
email_from | Mixed | Yes | A single email address: `[email protected]`, or a dict containing an email address indexed by a name of the user to use as the sender of the email: `{'Jane Doe' : '[email protected]'}`. | |
email_subject | String | Yes | The subject of the email. | |
email_body | String | Yes | The body of the email. |
If the command executes successfully.
Mixed = TR50httpWorker.locale_get()
locale.get retrieves the current session's locale.
None.
Returns the dict of the session's locale on success, or the failure code.
Mixed = TR50httpWorker.locale_list()
locale.list lists supported locales.
None.
Returns the dict of supported locales on success, or the failure code.
Boolean = TR50httpWorker.locale_set(locale)
locale.set sets the current session's locale.
Name | Type | Required | Default | Description |
---|---|---|---|---|
locale | String | Yes | The locale to set. |
If the command executes successfully.
Mixed = TR50httpWorker.location_current(thing_key)
location.current returns the last reported location for a thing.
Name | Type | Required | Default | Description |
---|---|---|---|---|
thing_key | String | Yes | Identifies the thing associated with the location entry. |
Returns the dict of the thing's current location on success, or the failure code.
Mixed = TR50httpWorker.location_decode(latitude, longitude)
location.decode is used to decode a latitude/longitude pair into an address.
Name | Type | Required | Default | Description |
---|---|---|---|---|
latitude | Float | Yes | The latitude of the location. | |
longitude | Float | Yes | The longitude of the location. |
Returns the dict of the address of the latitude/longitude pair on success, or the failure code.
Mixed = TR50httpWorker.location_encode(location)
location.encode is used to encode a textual location into a latitude/longitude pair.
Name | Type | Required | Default | Description |
---|---|---|---|---|
location | String | Yes | The textual location to be encoded. |
Returns the dict of the latitude/longitude associated with the provided location on success, or the failure code.
Boolean = TR50httpWorker.location_publish(thing_key, latitude, longitude[, date_obj[, heading[, altitude[, speed[, fix_acc[, fix_type[, corr_id]]]]]]])
location.publish is used to publish the location of a thing.
Name | Type | Required | Default | Description |
---|---|---|---|---|
thing_key | String | Yes | The unique identifier of the thing to which the location data is to be associated. | |
latitude | Float | Yes | The latitude for this location publish. | |
longitude | Float | Yes | The longitude for this location publish. | |
date_obj | Mixed | No | False | A date object or the string representing the date and time for the location that is being published. |
heading | Integer | No | False | The direction for this location publish (in degrees where 0 is North, 90 is East, 180 is South, and 270 is West). |
altitude | Integer | No | False | The altitude for this location publish. |
speed | Integer | No | False | The speed for this location publish. |
fix_acc | Integer | No | False | The accuracy in meters of the coordinates being published. |
fix_type | String | No | False | A string describing the location fixation type. Typically "gps", "gnss", "manual", or "m2m-locate". |
corr_id | String | No | False | A correlation ID that can be used when querying to find related data objects. |
If the command executes successfully.
Mixed = TR50httpWorker.location_speedlimit(latitude, longitude)
location.speedlimit is used to find the speed limit at a specified location.
Name | Type | Required | Default | Description |
---|---|---|---|---|
latitude | Float | Yes | The latitude being requested. | |
longitude | Float | Yes | The longitude being requested. |
Returns the dict of the speed limit associated with the provided location on success, or the failure code.
Mixed = TR50httpWorker.location_weather(latitude, longitude)
location.weather is used to return the weather information at a specified location.
Name | Type | Required | Default | Description |
---|---|---|---|---|
latitude | Float | Yes | The latitude being requested. | |
longitude | Float | Yes | The longitude being requested. |
Returns the dict of the weather information associated with the provided location on success, or the failure code.
Boolean = TR50httpWorker.method_exec(thing_key, method[, singleton[, ack_timeout[, parameters]]])
method.exec is used to execute a method of a thing.
Name | Type | Required | Default | Description |
---|---|---|---|---|
thing_key | String | Yes | Identifies the thing for which the method is executed. | |
method | String | Yes | The method to execute. | |
singleton | Boolean | No | False | Set to true if this call is to be run as a singleton. |
ack_timeout | Integer | No | False | Acknowlege timeout duration in seconds. Default is 30. |
parameters | Dictionary | No | False | Notification variables or method parameters to be passed to the method. |
If the command executes successfully.
Mixed = TR50httpWorker.org_find(org_key)
org.find is used to find and return an organization.
Name | Type | Required | Default | Description |
---|---|---|---|---|
org_key | String | Yes | The key identifying the organization. |
Returns the dict of the organization information on success, or the failure code.
Mixed = TR50httpWorker.org_list([offset[, limit[, can_have_sub_orgs]]])
org.list is used to return a list of organizations.
Name | Type | Required | Default | Description |
---|---|---|---|---|
offset | Integer | No | False | The starting list offset, used for pagination, defaults to 0 if not specified. |
limit | Integer | No | False | Limits the number of results returned. Defaults to the maximum configured size. |
can_have_sub_orgs | Boolean | No | False | Whether to only list organizations that are capable of having child organizations. |
Returns a dictionary of organizations on success, or the failure code.
Mixed = TR50httpWorker.property_aggregate(thing_key, property_key, calc, series, start, end[, split])
property.aggregate is used to obtain historical property data aggregated over a specified time period for a thing.
Name | Type | Required | Default | Description |
---|---|---|---|---|
thing_key | String | Yes | Identifies the thing to which the property data is to be associated. | |
property_key | String | Yes | The key for the property that you wish to aggregate. | |
calc | String | Yes | The calculation to use for the aggregation: avg, sum, max, min, count, etc. | |
series | String | Yes | The series to be used when grouping property values to aggregate: 'hour' or 'day'. | |
start | Mixed | Yes | A date object or the string representing the start of the specified time window. | |
end | Mixed | Yes | A date object or the string representing the end of the specified time window. | |
split | Boolean | No | False | Set to true if you want the timestamp and value fields to be split into two arrays. |
Returns the dict of property aggregation on success, or the failure code.
Mixed = TR50httpWorker.property_current(thing_key, property_key)
property.current is used to retrieve the current value of a property.
Name | Type | Required | Default | Description |
---|---|---|---|---|
thing_key | String | Yes | Identifies the thing to which the property data is associated. | |
property_key | String | Yes | The key for the property that you wish to retrieve. |
Returns the dict of current property on success, or the failure code.
Boolean = TR50httpWorker.property_publish(thing_key, property_key, value[, date_obj[, corr_id]])
property.publish is used to publish property data (typically sensor data) for a thing.
Name | Type | Required | Default | Description |
---|---|---|---|---|
thing_key | String | Yes | Identifies the thing to which the property data is to be associated. | |
property_key | String | Yes | The key for the property that you wish to publish. | |
value | Float | Yes | The value to publish. | |
date_obj | Mixed | No | False | A date object or the string representing the date and time the value was recorded. |
corr_id | String | No | False | A correlation ID that can be used when querying to find related data objects. |
If the command executes successfully.
Mixed = TR50httpWorker.session_info()
session.info is used to obtain information about the current session.
None.
Returns the dict of current session on success, or the failure code.
Mixed = TR50httpWorker.session_org_list([include_roles])
session.org.list is used to obtain a list of organizations available to the current session.
Name | Type | Required | Default | Description |
---|---|---|---|---|
include_roles | Boolean | No | False | Indicate that the available roles are to be returned with the response. Default is false. |
Returns the dict of organizations (and roles) on success, or the failure code.
Boolean = TR50httpWorker.session_org_switch(org_key)
session.org.switch is used to switch a session between organizations.
Name | Type | Required | Default | Description |
---|---|---|---|---|
org_key | String | Yes | The organization key. |
If the command executes successfully.
Mixed = TR50httpWorker.thing_def_find(thing_def_key)
thing_def.find is used to find an existing thing definition.
Name | Type | Required | Default | Description |
---|---|---|---|---|
thing_def_key | String | Yes | The key of the thing definition to find. |
Returns the dict of the selected thing definition on success, or the failure code.
Mixed = TR50httpWorker.thing_def_list([offset[, limit]])
thing_def.list Acquire the list of Thing Definitions.
Name | Type | Required | Default | Description |
---|---|---|---|---|
offset | Integer | No | False | The starting list offset, used for pagination, defaults to 0 if not specified. |
limit | Integer | No | False | Limits the number of results returned. Defaults to the maximum configured size. |
Returns the dict of thing definitions on success, or the failure code.
Mixed = TR50httpWorker.thing_find(thing_key)
thing.find is used to find and return a thing.
Name | Type | Required | Default | Description |
---|---|---|---|---|
thing_key | String | Yes | Identifies the thing. |
Returns the dict of the selected thing on success, or the failure code.
Mixed = TR50httpWorker.thing_list([offset[, limit[, show[, sort[, tags[, keys]]]]]])
thing.list is used to find and return a list of things.
Name | Type | Required | Default | Description |
---|---|---|---|---|
offset | Integer | No | False | The starting list offset, used for pagination. Defaults to 0 if not specified. |
limit | Integer | No | False | Limits the number of results returned. Defaults to the maximum configured size. |
show | Array | No | False | An array of field names of the data columns to return. |
sort | String | No | False | A string indicated the direction ("+" for ascending, "-" for descending) and column to sort the results by. To sort by the key descending, use "-key". Defaults to "+name". |
tags | Array | No | False | If specified, the command will only return things that have all tags in this parameter. |
keys | Array | No | False | If specified, the command will only return things that have the keys specified in this parameter. |
Returns the dict of things on success, or the failure code.
Boolean = TR50httpWorker.twilio_sms_send(sms_to, sms_body, sms_from)
twilio.sms.send Send an SMS message to a phone number.
Name | Type | Required | Default | Description |
---|---|---|---|---|
sms_to | String | Yes | The recipient's phone number, a comma separated string of phone numbers, or an array of phone numbers. | |
sms_body | String | Yes | The body of the SMS message. | |
sms_from | String | No | False | The sender's phone number. |
If the command executes successfully.
Mixed = TR50httpWorker.user_find(email_address)
user.find is used to retrieve a user by email address.
Name | Type | Required | Default | Description |
---|---|---|---|---|
email_address | String | Yes | The email address of the user. |
Returns the dict of the user on success, or the failure code.
Mixed = TR50httpWorker.user_list(offset, limit)
user.list is used to return a list of users.
Name | Type | Required | Default | Description |
---|---|---|---|---|
offset | Integer | No | False | The starting list offset, used for pagination, defaults to 0 if not specified. |
limit | Integer | No | False | Limits the number of results returned. Defaults to the maximum configured size. |
Returns a dictionary of users on success, or the failure code.