Telldus/Tellstick Local API with PHP

Robert Andresen Internet of things, Programming, Tutorials 2 Comments

21.01.2016 Telldus announced a closed beta for their Local API on the ZNet Lite. 24.05.2016 they opened the Local API to public beta.

Local API let’s you connect and fetch data directly from the Tellstick ZNet without going through Telldus Live, which can be a huge advantage as it’s faster and more stable.

As long as the Local API is in beta, you will need to contact Telldus support to activate the beta on your Tellstick.

I have been playing around with the Local API the last days, and I finally got it to work. I created a simple PHP-class for the necessary requests. Please keep in mind that this is a quick work-in-progress draft, and it could probably be optimized a bit, throw some errors, etc…

 

TelldusLocalAPI.class.php

 

auth.php

First you need to fetch a request token. This token need to be used to authenticate your app, by clicking the link. The link will open a new window, where you can select some access options. After the app is authenticated, you can exchange the request token for an access token by going back to the page and clicking the other link.

After exchanging the request token for an access token, this will create a textfile in your root directory with the access token. Make sure you have write permissions to create and write to the textfile. You can also create a file named “token.txt” manually.

 

request.php

After the authentication is done, you can start fetching data directly from your Tellstick ZNet.

 

Here is a screenshot of the request.php. I don’t have any devices connected to my new ZNet Lite v2 yet, so that array is empty.

local_api_test