Tellstick NET API documentation

Moderator: Telldus

Post Reply
polarbearNO
Posts: 11
Joined: Fri Mar 17, 2023 9:45 am

Tellstick NET API documentation

Post by polarbearNO »

I've been playing around with your API explorer and I'm about to write my own webUI for personal use. However I think the API documentation is inadequate. I've seen in other topics references to the C/C++ examples, but as I'm completely unfamiliar with those languages, I'm lost. For instance, the "device/command" command has a method property. Helptext: "This should be any of the method constants."

What constants?? I've tried TELLSTICK_TURNOFF, TURNOFF, tdTurnOff etc but nothing seems to work. Where, excactly, can I find the valid constants?

Best regards,
Anders

Edit, March 18: Does the lack of replies mean that I'm a n00b unable to read the documentation, or does it mean that the documentation is so poorly written that noone knows?
polarbearNO
Posts: 11
Joined: Fri Mar 17, 2023 9:45 am

Re: Tellstick NET API documentation

Post by polarbearNO »

Anyone?
asjmcguire
Posts: 3
Joined: Fri Mar 17, 2023 9:45 am

Re: Tellstick NET API documentation

Post by asjmcguire »

The API is very much lacking - however - I managed to build a simple PHP script that can do the basics using the basic example provided and the "methods" here -
http://developer.telldus.se/doxygen/gro ... 492e5660c9

In order to use the methods - you need to remember they are actually integers (and need to be defined - that's why you see TELLSTICK_TURNON and TELLSTICK_TURNOFF defined in the php example).

So for instance TELLSTICK_TURNON = 1 and TELLSTICK_TURNOFF = 2. TELLSTICK_DIM = 16
Passing a method of 1 to device/command will turn on a device and passing a method of 2 will turn it off.
Method 32 = learn etc etc

Where it seems to get a bit more complicated (why they couldn't just accept an array of supported methods I don't know) is when you need to tell the API what methods your application supports in certain endpoints. So to tell the API you support TELLSTICK_TURNON and TELLSTICK_TURNOFF you pass the OR'd value - an example:

Code: Select all

<?php
$tellstick_turnon = 1;
$tellstick_turnoff = 2;
$tellstick_dim = 16;
$method = ($tellstick_turnon | $tellstick_turnoff);
echo $method; //outputs 3
$method = ($tellstick_turnon | $tellstick_turnoff | $tellstick_dim);
echo $method; //outputs 19
?>
So as you can see - if you only support switching stuff on an off - then when telling the API which methods you support - you say 3 - if you support dimming as well then you say 19.

Take a look at the simple scripts I have uploaded -
I use them like this:

Code: Select all

<?php
$devices = tellstick_devices_List($user_token,$user_secret);
$name = "livingroom"; //the name of the device you want to control (can be a partial name)
$dev = tellstick_findDeviceByName($devices,$name,1);
if ($dev['id'] > 0) {
echo "Found {$dev['name']} at id {$dev['id']}\n";
echo "Current State: " .($dev['friendlyState'] == 1 ? "On" : "Off") ."\n";
 if ($dev['friendlyState'] == 0) { 
 $ret = tellstick_device_turnOn($user_token,$user_secret,$dev['id']);
 } else {
  $ret = tellstick_device_turnOff($user_token,$user_secret,$dev['id']);
}
}
?>
I hope this helps you on your way :D
Attachments
tellstick_test.zip
(1.69 KiB) Downloaded 420 times
polarbearNO
Posts: 11
Joined: Fri Mar 17, 2023 9:45 am

Re: Tellstick NET API documentation

Post by polarbearNO »

Perfect, asjmcguire! This will get me started! :)
Post Reply