Tellstick Net Live API Dot.Net exempel

Moderator: Telldus

sverkerf
Posts: 4
Joined: Fri Mar 17, 2023 9:45 am

Tellstick Net Live API Dot.Net exempel

Post by sverkerf »

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: Fri Mar 17, 2023 9:45 am

Re: Tellstick Net Live API Dot.Net exempel

Post by GliMM »

+1
brewman
Posts: 3
Joined: Fri Mar 17, 2023 9:45 am

Re: Tellstick Net Live API Dot.Net exempel

Post by brewman »

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: Fri Mar 17, 2023 9:45 am

Re: Tellstick Net Live API Dot.Net exempel

Post by Larsey »

+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: Fri Mar 17, 2023 9:45 am

Re: Tellstick Net Live API Dot.Net exempel

Post by paaland »

+1

I'm also having issues with .Net and OAuth. Please release a working sample.
Larsey
Posts: 4
Joined: Fri Mar 17, 2023 9:45 am

Re: Tellstick Net Live API Dot.Net exempel

Post by Larsey »

+1

I would really want to see an example with C#, preferably a console application or wpf.
tridy
Posts: 20
Joined: Fri Mar 17, 2023 9:45 am
Location: Stockholm, Sweden

Re: Tellstick Net Live API Dot.Net exempel

Post by tridy »

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: Fri Mar 17, 2023 9:45 am

Re: Tellstick Net Live API Dot.Net exempel

Post by Waran »

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

Thanks

Robert
RickardP
Posts: 55
Joined: Fri Mar 17, 2023 9:45 am
Location: Nyköping, Sweden
Contact:

Re: Tellstick Net Live API Dot.Net exempel

Post by RickardP »

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: Fri Mar 17, 2023 9:45 am
Location: Stockholm, Sweden

Re: Tellstick Net Live API Dot.Net exempel

Post by tridy »

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: Fri Mar 17, 2023 9:45 am
Location: Nyköping, Sweden
Contact:

Re: Tellstick Net Live API Dot.Net exempel

Post by RickardP »

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: Fri Mar 17, 2023 9:45 am
Location: Stockholm, Sweden

Re: Tellstick Net Live API Dot.Net exempel

Post by tridy »

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: Fri Mar 17, 2023 9:45 am

Re: Tellstick Net Live API Dot.Net exempel

Post by Sabeltann »

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: Fri Mar 17, 2023 9:45 am

Re: Tellstick Net Live API Dot.Net exempel

Post by ketels »

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: Fri Mar 17, 2023 9:45 am

Re: Tellstick Net Live API Dot.Net exempel

Post by avatar1 »

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