Simple java app to read sensor values from Telldus Live!
Moderator: Telldus
Simple java app to read sensor values from Telldus Live!
Hello,
As my hosting provider (godaddy) does not support OAuth and I really wanted to have some graphs showing the temperature readings on my website, I created a small java tool to read sensor values from Telldus Live!. The tool simply reads the values of the sensors you indicate, creates a small text file and then upload this file to a FTP server.
You can see the graphs for my sensors on the link below. I just received the second one so the indoor page does not have much history yet:
http://antibes.pelogeo.com
The tool can be downloaded here:
http://antibes.pelogeo.com/SensorReader.jar
Source code available here:
https://github.com/logge/SensorReader
It's very easy to use. First you have to get your api tokens from Telldus (http://api.telldus.com/keys/index)
Then, you can use the tool to get the ids of your sensors, like this:
java -jar SensorReader.java PublicKey PrivateKey PublicToken SecretToken
It's displayed as xml, but you can easily see the sensor ids in there.
Then, to start retrieving sensor values, you do this:
SensorReader.java PublicKey PrivateKey PublicToken SecretToken
FtpServer FtpUser FtpPassword ReadIntervalInMinutes sensorId1 sensorId2 ... sensorIdN
The tool will create one file for each sensor (sensorid.txt) and upload it to your ftp server. The content of the file is simply a timestamp for each reading (not taken from the sensor, but rather when the tool received the values) as well as the temperature and humidity. This file can then simply be read by something on the webserver that generates a graph. Personally I used amcharts.com. Each line in the file looks like this:
22/08/2012/12/00,30.4,69
Happy sensor reading,
//Peter
As my hosting provider (godaddy) does not support OAuth and I really wanted to have some graphs showing the temperature readings on my website, I created a small java tool to read sensor values from Telldus Live!. The tool simply reads the values of the sensors you indicate, creates a small text file and then upload this file to a FTP server.
You can see the graphs for my sensors on the link below. I just received the second one so the indoor page does not have much history yet:
http://antibes.pelogeo.com
The tool can be downloaded here:
http://antibes.pelogeo.com/SensorReader.jar
Source code available here:
https://github.com/logge/SensorReader
It's very easy to use. First you have to get your api tokens from Telldus (http://api.telldus.com/keys/index)
Then, you can use the tool to get the ids of your sensors, like this:
java -jar SensorReader.java PublicKey PrivateKey PublicToken SecretToken
It's displayed as xml, but you can easily see the sensor ids in there.
Then, to start retrieving sensor values, you do this:
SensorReader.java PublicKey PrivateKey PublicToken SecretToken
FtpServer FtpUser FtpPassword ReadIntervalInMinutes sensorId1 sensorId2 ... sensorIdN
The tool will create one file for each sensor (sensorid.txt) and upload it to your ftp server. The content of the file is simply a timestamp for each reading (not taken from the sensor, but rather when the tool received the values) as well as the temperature and humidity. This file can then simply be read by something on the webserver that generates a graph. Personally I used amcharts.com. Each line in the file looks like this:
22/08/2012/12/00,30.4,69
Happy sensor reading,
//Peter
Last edited by logge on Tue Oct 02, 2012 3:25 pm, edited 2 times in total.
Re: Simple java app to read sensor values from Telldus Live!
I managed to receive the sensor ID's with the first command, but how do you execute the above command from the command line? I just get the following error:logge wrote:Hello,
Then, to start retrieving sensor values, you do this:
SensorReader.java PublicKey PrivateKey PublicToken SecretToken ReadIntervalInMinutes
FtpServer FtpUser FtpPassword sensorId1 sensorId2 ... sensorIdN
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at SensorReader.main(SensorReader.java:88)
Re: Simple java app to read sensor values from Telldus Live!
petzno wrote:I managed to receive the sensor ID's with the first command, but how do you execute the above command from the command line? I just get the following error:logge wrote:Hello,
Then, to start retrieving sensor values, you do this:
SensorReader.java PublicKey PrivateKey PublicToken SecretToken ReadIntervalInMinutes
FtpServer FtpUser FtpPassword sensorId1 sensorId2 ... sensorIdN
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at SensorReader.main(SensorReader.java:88)
Sorry, a small typo in the example. The Read interval should be after the ftp password. Like this for example:
java -jar SensorReader.jar PublicKey PrivateKey PublicToken SecretToken ftphost username password 30 86413 128565
This command will read the value of two sensors every 30 minutes.
Re: Simple java app to read sensor values from Telldus Live!
OK, let me try this later today.
BTW; How is your setup to do the collection of data for trending/graphing? Do you have a computer setup where you simply run this command constantly (with e.g. 30 minutes as interval setting)? If so I thought maybe using the windows scheduler without the interval setting could be a better option? Your input and experience with this is highly appreciated.
I have the possibilities to have both a windows and linux computer setup. Ideally I would like to do this from a webserver/my domain so that I don't have to have a computer running all the time.
BTW; How is your setup to do the collection of data for trending/graphing? Do you have a computer setup where you simply run this command constantly (with e.g. 30 minutes as interval setting)? If so I thought maybe using the windows scheduler without the interval setting could be a better option? Your input and experience with this is highly appreciated.
I have the possibilities to have both a windows and linux computer setup. Ideally I would like to do this from a webserver/my domain so that I don't have to have a computer running all the time.
Re: Simple java app to read sensor values from Telldus Live!
For the moment I have the tool running constantly on my computer at work (which is basically on all day). It would of course be ideal to run it directly on a webserver, but my hosting provider does not support this. Using the windows scheduler would also be an option, in fact, if you download the tool again, I changed it slightly so that if you put 0 as time interval it will exit after having read the sensor data.petzno wrote:OK, let me try this later today.
BTW; How is your setup to do the collection of data for trending/graphing? Do you have a computer setup where you simply run this command constantly (with e.g. 30 minutes as interval setting)? If so I thought maybe using the windows scheduler without the interval setting could be a better option? Your input and experience with this is highly appreciated.
I have the possibilities to have both a windows and linux computer setup. Ideally I would like to do this from a webserver/my domain so that I don't have to have a computer running all the time.
Re: Simple java app to read sensor values from Telldus Live!
Great idea with the 0 option!
Unfortunately I have run into problems with your script when I tried it back home. I don't know if it is the latest version you uploaded or if it is the fact I changed computer, because I don't have your previous version. Here is the error I am facing, seems to be something with the ftpclient used in the script:
UPDATE:
I found the solution, have a look here if somebody face the same problem:
http://stackoverflow.com/questions/1016 ... pplication
Question: Any options to set the path for the ftp server?
Unfortunately I have run into problems with your script when I tried it back home. I don't know if it is the latest version you uploaded or if it is the fact I changed computer, because I don't have your previous version. Here is the error I am facing, seems to be something with the ftpclient used in the script:
Code: Select all
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at sun.nio.cs.StreamDecoder.read0(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at it.sauronsoftware.ftp4j.NVTASCIIReader.readLine(NVTASCIIReader.java:1
05)
at it.sauronsoftware.ftp4j.FTPCommunicationChannel.read(FTPCommunication
Channel.java:142)
at it.sauronsoftware.ftp4j.FTPCommunicationChannel.readFTPReply(FTPCommu
nicationChannel.java:187)
at it.sauronsoftware.ftp4j.FTPClient.openPassiveDataTransferChannel(FTPC
lient.java:3614)
at it.sauronsoftware.ftp4j.FTPClient.openDataTransferChannel(FTPClient.j
ava:3549)
at it.sauronsoftware.ftp4j.FTPClient.upload(FTPClient.java:2677)
at it.sauronsoftware.ftp4j.FTPClient.upload(FTPClient.java:2586)
at it.sauronsoftware.ftp4j.FTPClient.upload(FTPClient.java:2457)
at SensorReader.main(SensorReader.java:175)
I found the solution, have a look here if somebody face the same problem:
http://stackoverflow.com/questions/1016 ... pplication
Question: Any options to set the path for the ftp server?
Re: Simple java app to read sensor values from Telldus Live!
I have tried your script the last few days and I like it! However there are a few changes that could be nice to do, e.g. adding more than one sensor to the same csv file and comparing read value with previous values (based on having a problem if sensor or Tellstick is unavailable, then the reading will just show last value with a new timestamp).
Are you able to give access to the source code? If so I am more than happy to do the changes myself.
Are you able to give access to the source code? If so I am more than happy to do the changes myself.
Re: Simple java app to read sensor values from Telldus Live!
Yes, I will give access to the source code, I don't have so much time to add more features myself unfortunately.petzno wrote:I have tried your script the last few days and I like it! However there are a few changes that could be nice to do, e.g. adding more than one sensor to the same csv file and comparing read value with previous values (based on having a problem if sensor or Tellstick is unavailable, then the reading will just show last value with a new timestamp).
Are you able to give access to the source code? If so I am more than happy to do the changes myself.
Re: Simple java app to read sensor values from Telldus Live!
Perfect!
Not sure how it is most easy to do that, seems like the PM features is turned off in the forum so I am not able to send you a message.
Not sure how it is most easy to do that, seems like the PM features is turned off in the forum so I am not able to send you a message.
-
- Posts: 65
- Joined: Fri Mar 17, 2023 9:45 am
Re: Simple java app to read sensor values from Telldus Live!
When I'm running the sensor finding I get no results at all. Just an empty sensor tag.
Any ideas what might be wrong?
Any ideas what might be wrong?
Re: Simple java app to read sensor values from Telldus Live!
I created a public Github repository where you can get the source. Feel free to commit any improvements you do there if you want to share them.petzno wrote:Perfect!
Not sure how it is most easy to do that, seems like the PM features is turned off in the forum so I am not able to send you a message.
The code is very simple, it's just one file. Then it uses one lib for the FTP part and another lib for OAuth.
https://github.com/logge/SensorReader
Re: Simple java app to read sensor values from Telldus Live!
Does your temperature sensors show up in the Telldus live web interface? Could you post the xml output?liverpoolarn wrote:When I'm running the sensor finding I get no results at all. Just an empty sensor tag.
Any ideas what might be wrong?
-
- Posts: 65
- Joined: Fri Mar 17, 2023 9:45 am
Re: Simple java app to read sensor values from Telldus Live!
When looking at live.telldus.com there is only devices, no sensors... But in the win-app they show up no problem.logge wrote:Does your temperature sensors show up in the Telldus live web interface? Could you post the xml output?liverpoolarn wrote:When I'm running the sensor finding I get no results at all. Just an empty sensor tag.
Any ideas what might be wrong?
Output in cmd-win is like this:
F:\Programs\Tellstick>java -jar SensorReader.jar FEHxxx ZUXyyy 952### 553###
Sensor list response: <?xml version="1.0" encoding="utf-8" ?>
<sensors />
Re: Simple java app to read sensor values from Telldus Live!
If there are no sensors in Telldus Live, then you have to direct this question to Telldus. My software can only retrieve what is listed there.liverpoolarn wrote:When looking at live.telldus.com there is only devices, no sensors... But in the win-app they show up no problem.logge wrote:Does your temperature sensors show up in the Telldus live web interface? Could you post the xml output?liverpoolarn wrote:When I'm running the sensor finding I get no results at all. Just an empty sensor tag.
Any ideas what might be wrong?
Output in cmd-win is like this:
F:\Programs\Tellstick>java -jar SensorReader.jar FEHxxx ZUXyyy 952### 553###
Sensor list response: <?xml version="1.0" encoding="utf-8" ?>
<sensors />
Re: Simple java app to read sensor values from Telldus Live!
Same like you the hardest thing is to find time for such things. But I will let you know if I do any changeslogge wrote:petzno wrote:Perfect!
I created a public Github repository where you can get the source. Feel free to commit any improvements you do there if you want to share them.
The code is very simple, it's just one file. Then it uses one lib for the FTP part and another lib for OAuth.
https://github.com/logge/SensorReader