Tellstick Net Live API Dot.Net exempel

Moderator: Telldus

sverkerf
Posts: 4
Joined: Thu Jan 18, 2018 11:08 am

Tellstick Net Live API Dot.Net exempel

Post by sverkerf » Thu Jan 18, 2018 11:08 am

Jag har stångat pannan blodig i mina försök att efterlikna pythonexemplet med hjälp av DotNetOpenAuth. Tyvärr helt utan framgång, jag blir inte klok på vilka klasser eller metoder i DotNetOpenAuth som motsvarar pytonbibliotekets.

Finns det någon som har lyckats?

GliMM
Posts: 3
Joined: Thu Jan 18, 2018 11:08 am

Re: Tellstick Net Live API Dot.Net exempel

Post by GliMM » Thu Jan 18, 2018 11:08 am

+1

brewman
Posts: 3
Joined: Thu Jan 18, 2018 11:08 am

Re: Tellstick Net Live API Dot.Net exempel

Post by brewman » Thu Jan 18, 2018 11:08 am

Då var vi tre, stångar mig också blodig.

Någon av er som fått igång det? Jag har fått svar från servern men inte mkt mera, blir inte autoriserad :(

Larsey
Posts: 4
Joined: Thu Jan 18, 2018 11:08 am

Re: Tellstick Net Live API Dot.Net exempel

Post by Larsey » Thu Jan 18, 2018 11:08 am

+1!!

Jeg vil gjerne ha noe eksempelkode for hvordan jeg kan gjøre API kall i C# med min TellStick NET! Pretty please :D

paaland
Posts: 22
Joined: Thu Jan 18, 2018 11:08 am

Re: Tellstick Net Live API Dot.Net exempel

Post by paaland » Thu Jan 18, 2018 11:08 am

+1

I'm also having issues with .Net and OAuth. Please release a working sample.

Larsey
Posts: 4
Joined: Thu Jan 18, 2018 11:08 am

Re: Tellstick Net Live API Dot.Net exempel

Post by Larsey » Thu Jan 18, 2018 11:08 am

+1

I would really want to see an example with C#, preferably a console application or wpf.

tridy
Posts: 20
Joined: Thu Jan 18, 2018 11:08 am
Location: Stockholm, Sweden

Re: Tellstick Net Live API Dot.Net exempel

Post by tridy » Thu Jan 18, 2018 11:08 am

I decided to give it another try (with C#) and I am still stuck with OAuth.

If I have generated the keys via Telldus website, can actuall skip the authorisation for now, and use the keys?

If not, what do I use the keys for?

Or can anyone post an example of authentication via .net (C# or VB)

Image

Thanks
[tridy]

Waran
Posts: 3
Joined: Thu Jan 18, 2018 11:08 am

Re: Tellstick Net Live API Dot.Net exempel

Post by Waran » Thu Jan 18, 2018 11:08 am

Also have problems with using OAuth (DotNetOpenOAuth) with Telldus. Any help is needed to get me started.

Thanks

Robert

RickardP
Posts: 55
Joined: Thu Jan 18, 2018 11:08 am
Location: Nyköping, Sweden
Contact:

Re: Tellstick Net Live API Dot.Net exempel

Post by RickardP » Thu Jan 18, 2018 11:08 am

Take a look at my test project that are a ASP.NET MVC project using RestSharp with oAuth and get devices and so on maybe you can get some inspiration or reuse the code: https://github.com/RickardPettersson/TelldusLive-MVC

tridy
Posts: 20
Joined: Thu Jan 18, 2018 11:08 am
Location: Stockholm, Sweden

Re: Tellstick Net Live API Dot.Net exempel

Post by tridy » Thu Jan 18, 2018 11:08 am

RickardP wrote:Take a look at my test project that are a ASP.NET MVC project using RestSharp with oAuth and get devices and so on maybe you can get some inspiration or reuse the code: https://github.com/RickardPettersson/TelldusLive-MVC
Thanks for the tip.

I am still surprised that no one has written a simple example in C# (console or winforms or wpf) that would just(?) login and retrieve the list/names of devices. Just one example. Why is it so freaking hard to do?

I, myself, gave up on using oAuth and Telldus Live. With the basic version of Tellstick I could easily create a .Net application (and I am still using it from one of my computers). Sure, this one does not need to authenticate and read anything from the server, but with Tellstick .Net and Live! API, the last thing I want to do is embedding a browser control into the application to do the authentication. With the same success I can just use an embedded web browser for everything. I was expecting more of a SOA API from Telldus. There is way too much plumbing with the existing API.

P.S. My current idea is basically to use my small home server with my first version of Tellstick via Azure Service Bus through publish-and-subscribe. So, the home machine will subscribe to the bus and Windows Phone will publish to the bus.

However, I would love to see a .Net version of Telldus Live! client, if anyone dares to do that.
[tridy]

RickardP
Posts: 55
Joined: Thu Jan 18, 2018 11:08 am
Location: Nyköping, Sweden
Contact:

Re: Tellstick Net Live API Dot.Net exempel

Post by RickardP » Thu Jan 18, 2018 11:08 am

tridy wrote:
RickardP wrote:Take a look at my test project that are a ASP.NET MVC project using RestSharp with oAuth and get devices and so on maybe you can get some inspiration or reuse the code: https://github.com/RickardPettersson/TelldusLive-MVC
Thanks for the tip.

I am still surprised that no one has written a simple example in C# (console or winforms or wpf) that would just(?) login and retrieve the list/names of devices. Just one example. Why is it so freaking hard to do?

I, myself, gave up on using oAuth and Telldus Live. With the basic version of Tellstick I could easily create a .Net application (and I am still using it from one of my computers). Sure, this one does not need to authenticate and read anything from the server, but with Tellstick .Net and Live! API, the last thing I want to do is embedding a browser control into the application to do the authentication. With the same success I can just use an embedded web browser for everything. I was expecting more of a SOA API from Telldus. There is way too much plumbing with the existing API.

P.S. My current idea is basically to use my small home server with my first version of Tellstick via Azure Service Bus through publish-and-subscribe. So, the home machine will subscribe to the bus and Windows Phone will publish to the bus.

However, I would love to see a .Net version of Telldus Live! client, if anyone dares to do that.

I was looking for this to but realized after many hours and testing code after code is that one of the biggest reason for no one left a good peace of code for C# console/winform app is that its need oauth login to get a "good experience".

But there should be very easy to get the keys from developer.telldus.com and copy the code i have write in the ASP.NET MVC project and get it to work with a console application.

I have plans to do this in a project later on so maybe i comming back here then with that code to.

But to let a user to login to get its own Telldus Live account associate with the application it is web application thats needed to get the good experience for the user.

But for someone that whant to build a small home application hack it is not a big problem.

Me and a friend looking right now to communicate with the Tellstick Net directly with UDP traffic instead of using Tellstick Live, many things tood.

tridy
Posts: 20
Joined: Thu Jan 18, 2018 11:08 am
Location: Stockholm, Sweden

Re: Tellstick Net Live API Dot.Net exempel

Post by tridy » Thu Jan 18, 2018 11:08 am

RickardP wrote:But there should be very easy to get the keys from developer.telldus.com and copy the code i have write in the ASP.NET MVC project and get it to work with a console application.
Thanks, I will take a look at it. I missed this option.
RickardP wrote:Me and a friend looking right now to communicate with the Tellstick Net directly with UDP traffic instead of using Tellstick Live, many things tood.
I think I read somewhere that people were modifying the firmware/server code to use it locally. Could be really interesting.

There are several posts on using PowerShell to communicate with TellStick Net. One day I will take a look at it as well.
[tridy]

Sabeltann
Posts: 1
Joined: Thu Jan 18, 2018 11:08 am

Re: Tellstick Net Live API Dot.Net exempel

Post by Sabeltann » Thu Jan 18, 2018 11:08 am

Hi, I was also stuck trying to understand how to use the API with openId authentication. Your example helped a lot, Rickard, thank you.

Here's a simple C# console application using the static api keys provided by telldus, also leveraging RestSharp

// USES NUGETPACKAGE RestSharp
using System;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication
{
class Program
{
// GET THE 4 KEYS BELOW BY BROWSING TO https://api.telldus.com LOGGING IN, AND CLICKING ON THE 'YOUR KEYS' TAB
private const string PublicKey = "AAAAA";
private const string PrivateKey = "BBBBB";
private const string Token = "CCCCC";
private const string TokenSecret = "DDDDD";

private const string BaseUrl = "http://api.telldus.com/";

static void Main(string[] args)
{
var client = new RestClient(BaseUrl);
client.Authenticator = OAuth1Authenticator.ForProtectedResource(PublicKey, PrivateKey, Token, TokenSecret);
var request = new RestRequest("json/devices/list", Method.GET);
var response = client.Execute(request);
// TODO: deserialize the json response
Console.WriteLine(response.Content);
Console.ReadLine();
}
}
}

ketels
Posts: 2
Joined: Thu Jan 18, 2018 11:08 am

Re: Tellstick Net Live API Dot.Net exempel

Post by ketels » Thu Jan 18, 2018 11:08 am

Have anyone got this to work properly?

When using Sabeltann's example I can only get the list calls (e.g: json/devices/list) to work.
I cannot get sensor info or turn on and off devices. When doing so I only get the message: {"error":"OAuth Verification Failed: Verification of signature failed (signature base string was...}.

avatar1
Posts: 3
Joined: Thu Jan 18, 2018 11:08 am

Re: Tellstick Net Live API Dot.Net exempel

Post by avatar1 » Thu Jan 18, 2018 11:08 am

ketels wrote:Have anyone got this to work properly?

When using Sabeltann's example I can only get the list calls (e.g: json/devices/list) to work.
I cannot get sensor info or turn on and off devices. When doing so I only get the message: {"error":"OAuth Verification Failed: Verification of signature failed (signature base string was...}.
I didn't get very far yet with my application, but I thought I share that Sabeltanns example is working fine for me. Just put in the keys and the tokens from api.telldus.com.

To get a sensor value from my thermometer I then use the below code, where id is the sensor id that you want the result from. It still remains to parse the JSON code, but the temperature value is in there somewhere. :wink:

Public Function GetSensorData(id As Integer) As String
Dim request = New RestRequest("json/sensor/info", Method.GET)
request.AddParameter("id", id, ParameterType.GetOrPost)
Dim response = TSClient.Execute(request)
Return response.Content
End Function

Post Reply