How to use Telldus API
Posted: Fri Mar 17, 2023 9:45 am
Suppose you have a telldus.net, a Telldus account, at least one sensor and
Internett connection to the web;
To connect to the Telldus API, you need some security keys;
You will get your keys here: https://api.telldus.com/keys/index
The 4 keys looks like this :
PUBLIC_KEY = 'FExxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; (Replace the strings by your own)
PRIVATE_KEY = 'ZUxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
TOKEN = '6cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
TOKEN_SECRET= '0ccxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
(Don’t even think of ”key in” these values; Use copy/past)
PUBLIC_KEY is in some places also called ” ConsumerKey”
PRIVATE_KEY is in some places also called ” ConsumerSecret”
You will need some Telldus URL’s:
API_URL = 'https://api.telldus.com'; { Use https://.... in production}
ACCESS_TOKEN = '/oauth/accessToken'; {Not used in this example}
REQUEST_TOKEN = '/oauth/requestToken'; {Not used in this example }
AUTHORIZE_TOKEN= '/oauth/authorize'; {Not used, in this example only web login}
REQUEST_XML = '/xml'; { Get response as XML}
REQUEST_JSON = '/json'; { Get response as JSON }
SENSOR_LIST = '/sensors/list'; {Get list of your sensos, and last sensor values}
DEVICES_LIST = '/devices/list'; {Get list of devices; Not used in this example}
SENSOR_INFO = '/sensor/info'; {Get info and value of one sensor; Not used in this exampler}
+ suppose there are some more.
Then you will need a ”oAuth” program. Telldus is using OAuth 1.0
(There are some links abouth oAuth in the bottom of this dokument.)
The oAuth program need the 4 security key’s and an Url :
As you have all 4 security key’s, you don’t need all URL’s, just use:
To get a list of all sensors:
URL=API_URL + REQUEST_XML + SENSOR_LIST or
URL=API_URL + REQUEST_JSON + SENSOR_LIST
To get info of one sensor:
URL=API_URL + REQUEST_XML + SENSOR_INFO or
URL=API_URL + REQUEST_JSON + SENSOR_INFO
(Put the sensor number in the oAuth.SendBody )
Important:
The OAuth 1.0 Protocol expect the 4 security key’s in ASCII (or Ansi)
As most OS these days use utf8, convert like this:
ConsumerKey =UTF8ToAnsi(PUBLIC_KEY);
ConsumerSecret = UTF8ToAnsi(PRIVATE_KEY);
AuthToken = UTF8ToAnsi(TOKEN);
AuthSecret = UTF8ToAnsi(TOKEN_SECRET);
Build the send (In some ”pseudocode”)
You have to supply with some parameters (to tell Telldus API what you want in return):
PARAM:='includeIgnored=0&'+ 'includeValues=1&' + 'includeScale=0';
or just: PARAM:= 'includeValues=1'
oAuth.CallBackURL = '""; (no value)
oAuth.FallBackOOB = False;
Typical request,:
oAuth.SendBody := PARAM
oAuth.URL := API_URL + REQUEST_XML + SENSOR_LIST
If (oAuth.OAuthHTTPMethod('POST', URL) = 200) …..
If you recive 200 the request is OK;
The oAuth will send to Telldus a string like this (as XML or JSON):
https://api.telldus.com /xml /sensors/list or
https://api.telldus.com /json /sensors/list
If the request is accepted, Telldus API will respond with a string in the ReceivedBody:
XML:
<?xml version="1.0" encoding="utf-8" ?>
<sensors>
<sensor id="9999999" name=" RainSensor " lastUpdated="1422825359"
ignored="0" client="9999999" clientName="Home" online="1" editable="1" battery="254" rrate="0.0" rtot="262.1" />
</sensors>
JSON:
{"sensor":[{"id":"9999999","name":"RainSensor","lastUpdated":1422825359,
"ignored":0,"client":"9999999","clientName":"Home","online":"1","editable":1,"battery":254,"rrate":"0.0","rtot":"262.1"}]}
Info fields:
id: Sensor id number. (Not visible in http://www.livetelldus.com)
name: Sensor name, as in http://www.livetelldus.com, ”MySensors”
lastUpdated: Last update time in Unix format. (Seconds since 1970.1.1) Seems to be UTC time (GMT).
ignored: http://www.livetelldus.com, MySensors -> Edit -> show in list.
Client: Client number (Not visible in http://www.livetelldus.com)
clientName: Name from http://live.telldus.com -> My Locations
online: 1=Sensor is online;
editable: (? No idea)
battery: Not in use, allways 254, may be used in the future.
Possible value fields and format in recived string:
temp 0.0 (ºC or F, depending on sensor)
humidity 00 (%)
rrate 0.0 (mm, Don’t know exactly how it works but seems ok in graph)
rtot 0.0 (mm, accumulated since last start of sensor)
wdir 0.0 (Wind direction)
wgust 0.0 (Wind gust)
wavg 0.0 ( Average of wind speeds -)
All is recived as string, no decimal values.
Value fields may be combined like this:
temp
temp and humidity
rrate and rtot
wdir, wgust and wavg
Sensors not defined by Telldus may look like temp and humidity.
…………………..
The OAuth 1.0a Protocol has some more possibilities but should work.
The OAuth2 Protocol is totally different and will not work with Telldus API.
Links:
The OAuth 1.0 Protocol: http://tools.ietf.org/html/rfc5849
The OAuth 1.0 guide covers the protocol as defined by RFC 5849: http://hueniverse.com/oauth/
OAuth, Send secure authorized requests to the Twitter API: https://dev.twitter.com/oauth
Internett connection to the web;
To connect to the Telldus API, you need some security keys;
You will get your keys here: https://api.telldus.com/keys/index
The 4 keys looks like this :
PUBLIC_KEY = 'FExxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; (Replace the strings by your own)
PRIVATE_KEY = 'ZUxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
TOKEN = '6cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
TOKEN_SECRET= '0ccxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
(Don’t even think of ”key in” these values; Use copy/past)
PUBLIC_KEY is in some places also called ” ConsumerKey”
PRIVATE_KEY is in some places also called ” ConsumerSecret”
You will need some Telldus URL’s:
API_URL = 'https://api.telldus.com'; { Use https://.... in production}
ACCESS_TOKEN = '/oauth/accessToken'; {Not used in this example}
REQUEST_TOKEN = '/oauth/requestToken'; {Not used in this example }
AUTHORIZE_TOKEN= '/oauth/authorize'; {Not used, in this example only web login}
REQUEST_XML = '/xml'; { Get response as XML}
REQUEST_JSON = '/json'; { Get response as JSON }
SENSOR_LIST = '/sensors/list'; {Get list of your sensos, and last sensor values}
DEVICES_LIST = '/devices/list'; {Get list of devices; Not used in this example}
SENSOR_INFO = '/sensor/info'; {Get info and value of one sensor; Not used in this exampler}
+ suppose there are some more.
Then you will need a ”oAuth” program. Telldus is using OAuth 1.0
(There are some links abouth oAuth in the bottom of this dokument.)
The oAuth program need the 4 security key’s and an Url :
As you have all 4 security key’s, you don’t need all URL’s, just use:
To get a list of all sensors:
URL=API_URL + REQUEST_XML + SENSOR_LIST or
URL=API_URL + REQUEST_JSON + SENSOR_LIST
To get info of one sensor:
URL=API_URL + REQUEST_XML + SENSOR_INFO or
URL=API_URL + REQUEST_JSON + SENSOR_INFO
(Put the sensor number in the oAuth.SendBody )
Important:
The OAuth 1.0 Protocol expect the 4 security key’s in ASCII (or Ansi)
As most OS these days use utf8, convert like this:
ConsumerKey =UTF8ToAnsi(PUBLIC_KEY);
ConsumerSecret = UTF8ToAnsi(PRIVATE_KEY);
AuthToken = UTF8ToAnsi(TOKEN);
AuthSecret = UTF8ToAnsi(TOKEN_SECRET);
Build the send (In some ”pseudocode”)
You have to supply with some parameters (to tell Telldus API what you want in return):
PARAM:='includeIgnored=0&'+ 'includeValues=1&' + 'includeScale=0';
or just: PARAM:= 'includeValues=1'
oAuth.CallBackURL = '""; (no value)
oAuth.FallBackOOB = False;
Typical request,:
oAuth.SendBody := PARAM
oAuth.URL := API_URL + REQUEST_XML + SENSOR_LIST
If (oAuth.OAuthHTTPMethod('POST', URL) = 200) …..
If you recive 200 the request is OK;
The oAuth will send to Telldus a string like this (as XML or JSON):
https://api.telldus.com /xml /sensors/list or
https://api.telldus.com /json /sensors/list
If the request is accepted, Telldus API will respond with a string in the ReceivedBody:
XML:
<?xml version="1.0" encoding="utf-8" ?>
<sensors>
<sensor id="9999999" name=" RainSensor " lastUpdated="1422825359"
ignored="0" client="9999999" clientName="Home" online="1" editable="1" battery="254" rrate="0.0" rtot="262.1" />
</sensors>
JSON:
{"sensor":[{"id":"9999999","name":"RainSensor","lastUpdated":1422825359,
"ignored":0,"client":"9999999","clientName":"Home","online":"1","editable":1,"battery":254,"rrate":"0.0","rtot":"262.1"}]}
Info fields:
id: Sensor id number. (Not visible in http://www.livetelldus.com)
name: Sensor name, as in http://www.livetelldus.com, ”MySensors”
lastUpdated: Last update time in Unix format. (Seconds since 1970.1.1) Seems to be UTC time (GMT).
ignored: http://www.livetelldus.com, MySensors -> Edit -> show in list.
Client: Client number (Not visible in http://www.livetelldus.com)
clientName: Name from http://live.telldus.com -> My Locations
online: 1=Sensor is online;
editable: (? No idea)
battery: Not in use, allways 254, may be used in the future.
Possible value fields and format in recived string:
temp 0.0 (ºC or F, depending on sensor)
humidity 00 (%)
rrate 0.0 (mm, Don’t know exactly how it works but seems ok in graph)
rtot 0.0 (mm, accumulated since last start of sensor)
wdir 0.0 (Wind direction)
wgust 0.0 (Wind gust)
wavg 0.0 ( Average of wind speeds -)
All is recived as string, no decimal values.
Value fields may be combined like this:
temp
temp and humidity
rrate and rtot
wdir, wgust and wavg
Sensors not defined by Telldus may look like temp and humidity.
…………………..
The OAuth 1.0a Protocol has some more possibilities but should work.
The OAuth2 Protocol is totally different and will not work with Telldus API.
Links:
The OAuth 1.0 Protocol: http://tools.ietf.org/html/rfc5849
The OAuth 1.0 guide covers the protocol as defined by RFC 5849: http://hueniverse.com/oauth/
OAuth, Send secure authorized requests to the Twitter API: https://dev.twitter.com/oauth