fuTelldus - PHP application for sensor-logging

Moderator: Telldus

Post Reply
dico
Posts: 40
Joined: Thu Jan 18, 2018 11:08 am

fuTelldus - PHP application for sensor-logging

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

As many others I have created my own application for sensor-logging with PHP and Telldus LIVE API.
The application is written with PHP and nothing else. It pulls data every 15 minutes with a cronjob, and store values in MySQL database.

DOWNLOAD:
Version 03: http://fosen-utvikling.no/public/futell ... dus_v3.zip (released 13.04.2013)
Version 02: http://fosen-utvikling.no/public/futell ... dus_v2.zip (released 09.04.2013)
Version 01: http://fosen-utvikling.no/public/futell ... dus_v1.zip (released 04.04.2013)
(Se changelog in package for changes...)


PEAR and oAuth files: http://fosen-utvikling.no/public/futell ... elldus.zip (The necessary PEAR files needed if you can't install PEAR and oAuth for some reason, like on Synology (see tutorial below))

INSTALL TUTORIALS:
Ubuntu server (on Virtual box): http://fosen-utvikling.no/public/futell ... erver.html
Synology DSM: http://fosen-utvikling.no/public/futell ... lldus.html

Setting up CRON on synology DSM: http://fosen-utvikling.no/public/futell ... nology.pdf


Features:
- Beautiful interface with bootstrap framework
- Multiple user support with their own set of API-keys. You're friends can get their own users and log their own temperature.
- Log data from Telldus Live every 15 minutes with a cronjob.
- Multiple languages
- XML generated files, so you can retrieve data and use it on another webpage.
- Charts
- Reports. Se chart and max, min, avg values between selected date/times.
- Responsive layout for use on you're phone, with an own Apple-icon for shortcut on you're homescreen.
- Schedule
- Lightcontrol

Prerequisites:
- Webserver with PHP, MySQL and oAuth application installed (I use it on my private-server hosted by ProISP.no).
- Cronjob

Read the readme.txt file in the package for install-help.
There is also following pdf for some help with the oAuth package.


Screenshots:

Image

Image

Image

Image

Image

Image

Licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.

The project name prefix can be misinterpreted, but is just an shortname for my company :-)
Last edited by dico on Tue Apr 16, 2013 11:02 pm, edited 5 times in total.

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

Re: fuTelldus - PHP application for sensor-logging

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

It looks great!
I have a problem- I end up at a login page which says fuTelldus, login/password (/login/index.php). This is not shown in the documentation. What could be wrong?
I'm VERY new to this stuff

dico
Posts: 40
Joined: Thu Jan 18, 2018 11:08 am

Re: fuTelldus - PHP application for sensor-logging

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

faketastic wrote:It looks great!
I have a problem- I end up at a login page which says fuTelldus, login/password (/login/index.php). This is not shown in the documentation. What could be wrong?
I'm VERY new to this stuff
Hi! The fuTelldus.sql file populate the database with a default admin/admin user. Make sure you have imported this file into the MySQL database and added you're connection in /lib/config.inc.php.

You should be able to login with username (mail): admin and password admin, as written in the included readme.txt.

JohanS
Posts: 14
Joined: Thu Jan 18, 2018 11:08 am

Re: fuTelldus - PHP application for sensor-logging

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

Hi!

This looks great indeed!!!

However, I am having some problems - with some luck you can help me, most likely not though...
I have been working way too may hours and I think I nailed the problem down... there seems to be some problems with oauth.so... I am running my own server (Raspberry pi) so I have to figure everything out myself...

I BELIEVE that you have a "require" statement that is not needed... see eg. "getAccessToken.php" where I read "require_once 'HTTP/OAuth/Consumer.php';"

I just looked through my Raspberry PI (with OAuth installed, at least in theory) and I could not find that file anywhere... In your pdf you said that you copied this folder to use OAuth... perhaps this can be re-written a bit...

I am sorry for this short reply, but I am just too tiered to write more, I will be HAPPY to interact regarding this tomorrow/later and see if I can work it out together with you... now I will let my eyes rest a bit...

Anyway, it looks GREAT, I(/we???) just need to sort this out and I will be a happy camper!!!!



Oh, one more thing - there seems to be some issues with deleting/adding users... my user table keeps expanding and expanding...

dico
Posts: 40
Joined: Thu Jan 18, 2018 11:08 am

Re: fuTelldus - PHP application for sensor-logging

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

JohanS wrote: I BELIEVE that you have a "require" statement that is not needed... see eg. "getAccessToken.php" where I read "require_once 'HTTP/OAuth/Consumer.php';"

I just looked through my Raspberry PI (with OAuth installed, at least in theory) and I could not find that file anywhere... In your pdf you said that you copied this folder to use OAuth... perhaps this can be re-written a bit...

...

Oh, one more thing - there seems to be some issues with deleting/adding users... my user table keeps expanding and expanding...
You are correct, the path in getAccessToken.php was changed so I could get it to work. The original require from Telldus should be "require_once 'common.php';". The common-file has this "require_once 'HTTP/OAuth/Consumer.php';". As written in my PDF I had some problems with the oAuth on my server. I think this should work "out-of-the-box", but my oAuth package was trying to include it's files from my app root-path, and not from the install-path of oAuth. After som forum-reading, the php.ini file should be edited with the correct path - but I didn't have access to my ini file :-(

The "getAccessToken.php" file shouldn't be necessary to use my app. So I just put the link for it under test in settings, to testing the telldus.live connection. But the include/require-part for oAuth could be the same in the files that are necessary. I will look trough my files. But it would be great if you share any errors you find :-)

I will look at the add/delete user part. I haven't bug-tested this part so much, so it's possible it could be a bug in the code :-)

JohanS
Posts: 14
Joined: Thu Jan 18, 2018 11:08 am

Re: fuTelldus - PHP application for sensor-logging

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

Hi again....

Here I leave place for instructions on how to install fuTelldus on a Raspberry PI from scratch. It is rather easy but took me some time to figure out, so I complied all tricks here. Until I have time to write this there are some VERY SHORT tips below - combine them with google and you should get it up and running I think...
1. Do things...
2. Do other things...
... coffee...
100. Finished!



This will again be a short update, perhaps it can help someone out there who needs some help doing this themselves... I found a few tweaks... perhaps it can get me some help as well :)

The brain was working over night... and now I am 99% there... All I had to do was to install HTTP_OAuth (see beow) and copy it in place (as you wanted it in your require_once() statement)... things are looking GREAT and I am VERY HAPPY!!! Just missing a few (critical) things and we should be all set to go!

I just have some issues with the logging of sensor values, right now my startpage says:
---
Ute på altanen (sol)
°
Oppdatert: 43 years since
...
...
---

so there are some issues with saving current values into the database... I THINK I added the crontab correctly but will look more on this later... all graphs etc. are not showing anything except saying that they will show temperature (why not humidity???)...

This is somewhat puzzling because fuTelldus can READ the values when I click "sensors"... so it must be an issue with saving them into the database (crontab's job!)... I will look into this... if you have any thought I would be more than happy to hear them!

Sorry for all short updates, kind of stressed...sadly...

But I will be back! Count on it!

EDIT: I think I found th problem (just need to wait for cron to log the values to see)... cron needs to be restarted - so when you have edited the crontab you need to so "/etc/init.d/cron reload"... now things should work... lets HOPE at least...

EDIT #2: For some reason my php interpreter works different today compared to yesterday. Yesterday I ran the command: "php -q /var/www/fuTelldus_v1/cron_temp_log.php" without ANY problems and the database updated as expected. Today it did not work (debugging). I ended up having to change a line in the file cron_temp_log.php as follows:
Modifyed: require("/var/www/fuTelldus_v1/lib/config.inc.php");
Original: require("./lib/config.inc.php");
They SHOULD be the same... but now the command works - still waiting for cron (now with the modified file..) once everything works I will let ya'll know...
EDIT #4: Tried to revert the change above and now it works as expected, I will still leave this here though in case someone runs into problems with the same thing... So in the end I ended up using the "original" version...

EDIT #3: The crontab is now working, still not sure why I had to edit the cron_temp_log.php file... makes no sense to me... Now I will lean back and watch the magic...
My goal is clearly to write this a bit better "soon" for all who are having the same problems... but reading everything here might help someone in need...I hope...


For those who wants to try this with our own server (raspberry pi works GREAT) here are the steps. If there is time I will uptdate this to include all steps etc. etc. this is just a ROUGH guide...

1. Get a Pi, install debian as per instructed by Raspberru PI (easy)
2. Install apache2, php5, mysql (sudo atpI remember correctly - this should be the thing that helps you to:)
2.5 Install oauth (I do not think this is needed, but if it is "sudo apt-get install libpcre3-dev" and then "pecl install oauth" -if not working then "sudo pecl install oauth")
3. "pear install HTTP_OAuth-0.2.3" (if not let me know and I will see how to do this)
4. Do: "sudo /etc/init.d/apache2 restart" t make sure everything works... it is ok to get errors regarding your hostname

Now, we are almost there... put fuTelldus in place - ADD the files from telldus into any folder (in fuTelldus there is a folder called /lib/packages/telldus - I put a copy there as well, just to be sure)... I put them in a folder in the "root" called simple telldus. Go to this folder with your webrowser and follow the instructions. Now go to the telldus folder and things "should" work...

Ohoh - I forgot: "cp -R /usr/share/php/HTML /var/www/" to work around the "bug" I ran into yesterday (see above)

Now you can add the crontab (crontab -e ... and then follow the suggestions incuded i fuTelldus readme.txt) - NOTE THIS IS NOT WORKING FOR ME YET!!!!
Last edited by JohanS on Thu Apr 11, 2013 8:05 pm, edited 4 times in total.

AcidSleeper
Posts: 28
Joined: Thu Jan 18, 2018 11:08 am

Re: fuTelldus - PHP application for sensor-logging

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

Hey
How can I Tell if my server (Synology ds212j) have OAuth?

JohanS
Posts: 14
Joined: Thu Jan 18, 2018 11:08 am

Re: fuTelldus - PHP application for sensor-logging

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

AcidSleeper wrote:Hey
How can I Tell if my server (Synology ds212j) have OAuth?
Well, there are two different OAuth here - and I THINK all you need is th OAauth php FILES, those are rather easy to "put in place"... assuming you can copy (in a terminal) I would do something like the following (do NOT mess it up by typing the wrong thing):

EDIT: Technically there are MANY more than 2, but there are two that I mentioned in the posts above... END EDIT.

1. cd /path/to/your/fuTelldus
2. cp -R /usr/share/php/HTTP ./

3. did you get an error from #2? In so you need to FIND OAuth, I typically do "sudo find / -name OAuth", my output is:
/var/www/fuTelldus_v1/HTTP/OAuth
/usr/share/php/HTTP/OAuth
/usr/share/php/test/HTTP_OAuth/tests/HTTP/OAuth
pick the "correct" path, in this case #2 and copy it using step #2 above...

This should put the folder OAuth into the same folder as fuTelldus and things should now work...

If you are looking for "the other OAuth" as I talked about earlier in my ramblings then you should look for a file called "oauth.so", on my system it is in:
/usr/lib/php5/20100525+lfs/oauth.so
/usr/share/php5/oauth-1.2.3/modules/oauth.so
/usr/share/php5/oauth-1.2.3/.libs/oauth.so

I guess it would at least be in /usr/share/php5 on most (all?) systems... so look for it there, but my GUESS is that you do not need it.

should you STILL not find the OAuth (as in step 1 & 2 above) you can either install it - if you have the su pasword (see post above on howto install it - if you are LUCKY you can do this as not root, but I think not...)

if you are STILL lost then it should be possible to download a copy of the HTTP-folder from say...me? and put it in your webserver... possible danger here though! I might be a criminal and insert some evil code into these files so I can hack your webserver.... or I might not be...

If you are still lost after all this let me know and I will do my best to help. but be warned, I am new to linux as well (or...I was new about 20 years ago... then I stopped and restarted again now...but rather new since a lot is forgotten over these timespans)...
Last edited by JohanS on Mon Apr 08, 2013 8:26 pm, edited 1 time in total.

JohanS
Posts: 14
Joined: Thu Jan 18, 2018 11:08 am

Re: fuTelldus - PHP application for sensor-logging

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

dico:

Thanks for a GREAT job with this - having sorted out all (??) of my issues things are now up and running!!! and I must say it looks great...

Can I be bold and suggest a few things (more will come I am sure)...
1. The word "jump" and the help associated with it makes me want to write 0 to get all, however I should write 1 to get all... just a VERY small detail.
2. Perhaps one can force fuTelldus to do some basic math if a number larger than 1 is written in the box, to get averages... one can even imagine doing some simple statistical analysis with mean deviations, min, max etc... that would require some samples but could perhaps be interesting (and fun to code?)
3. How about changing the graphs to using google api (or any clones?) here are some suggestions a simple google search gave me... That could be quite amazing in the end (I think)... I do not know these API's, but perhaps one can even dream of having the posibility of selecting what graphs to plot in the same window - that way one can see how the outside temperature is affecting the inside temperature (and the attic etc...) in the same graph!
http://stackoverflow.com/questions/4997 ... nce-charts
Linked from stackoverflow: http://code.google.com/p/time-series-graph/
Linked from stackoverflow: http://www.humblesoftware.com/finance/index
http://stackoverflow.com/questions/1464 ... -chart-api

Anyway - thanks A LOT... I would be happy to write some of this if you want some input... life is hectic right now, but will hopefully be better in a while -- then I would have more time...

Cheers!
Johan

AcidSleeper
Posts: 28
Joined: Thu Jan 18, 2018 11:08 am

Re: fuTelldus - PHP application for sensor-logging

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

Okey my server didnt have http_oauth so I found it ön thé Internet abd copied it to webroot.

I dont have tellstick yet but I will buy it very soon and try the sensorlogging.
Thanks.

dico
Posts: 40
Joined: Thu Jan 18, 2018 11:08 am

Re: fuTelldus - PHP application for sensor-logging

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

Version 2 of fuTelldus: http://fosen-utvikling.no/public/futell ... dus_v2.zip


HOW TO UPGRADE:
I have not focused on upgrading yet, so you have to replace most of the files your self.
I recommend you backup your current files and DB, and replace all files. Then import the SQL file. SQL file should only "CREATE TABLE IF NOT EXISTS".

!! config.inc.php is NOT changed, so you don't need to replace it.
!! There is a new CRON file in this package for notifications
!! There is changes in the database for notifications


HOW TO INSTALL
Please see readme.txt in package.
Also look at attached PDF file for som oAuth notes.


New features:
[*] Read temperature from other people/servers running fuTelldus with XML. See below.
[*] Auto timeago: Automatically updates timeagostring when page is idle, so timeago is always correct.
[*] Autorefresh: Autorefresh page when it's been idle for ca. 15 minutes
[*] Notifications: Create notifications/warnings and receive e-mail when temperature/humidity is to high or low.
[*] Combine temperatures in one chart.
[*] Possible to run cron files manually from settings.
[*] Public chart, to share your chart with friends without needing them to log in (click on sensor under sensors to find link)

BUGFIX:
[*] Clearfix-class added for footer in index.php
[*] End table-tag missing in sensors_data.php
[*] Added language files to message/confirmbox under settings_general.php
[*] Fixed href to delete users in settings_users.php
[*] Fixed redirect after user-change, to prevent creating new users on next update.

SMALL CHANGES:
[*] Added location (clientName) under xml
[*] XML files moved to new public folder
[*] Pagetitle/logo in top linked to "startpage".
[*] New gui for sensorvalues in mainpage.
[*] If jump in report.php is 0, it would be forced to 1
[*] Chart files renamed from graph.php to chart.php



Test XML sharing:
Here is an URL to my sensor outdoor, if you want to test sensor sharing. Add this under settings.
http://robertan.com/app/telldus/fuTelld ... rID=871223


TODO:
[*] Look at other chart-packages or make some more advanced features in the current charts.
[*] Create compare-feature, to compare temperatures in a chart from ex. this and last month.
[*] Schedule devices with temperature and humidity
[*] Create a combined chart for humidity


Please be free to share any suggestions or bugs with me. If you change the language files to another language, i would be happy to implement it in the package.

I know oAuth could be a pain in the ass, but I see some of you in the forum are already trying this on different hardware. So please continue to share your findings :-)
My experience with webservers on raspberry and synology, is that the CPU is to slow to run MySQL with a great userexperience. I haven't tried fuTelldus on any of them yet, but I would like to know how your experience is.

Personally i have some issues with 2 of my 6 sensors at the moment. They haven't been updated since 17:07 today. I think the problem is the sensor itself or Telldus Live - because Telldus Live page haven't got any values since then either.

dico
Posts: 40
Joined: Thu Jan 18, 2018 11:08 am

Re: fuTelldus - PHP application for sensor-logging

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

JohanS wrote: Thanks for a GREAT job with this - having sorted out all (??) of my issues things are now up and running!!! and I must say it looks great...
That's great :-)
JohanS wrote: 1. The word "jump" and the help associated with it makes me want to write 0 to get all, however I should write 1 to get all... just a VERY small detail.
2. Perhaps one can force fuTelldus to do some basic math if a number larger than 1 is written in the box, to get averages... one can even imagine doing some simple statistical analysis with mean deviations, min, max etc... that would require some samples but could perhaps be interesting (and fun to code?)
3. How about changing the graphs to using google api (or any clones?) here are some suggestions a simple google search gave me... That could be quite amazing in the end (I think)... I do not know these API's, but perhaps one can even dream of having the posibility of selecting what graphs to plot in the same window - that way one can see how the outside temperature is affecting the inside temperature (and the attic etc...) in the same graph!
http://stackoverflow.com/questions/4997 ... nce-charts
Linked from stackoverflow: http://code.google.com/p/time-series-graph/
Linked from stackoverflow: http://www.humblesoftware.com/finance/index
http://stackoverflow.com/questions/1464 ... -chart-api
I'm using http://www.rgraph.net/ atm. I've looked at http://www.highcharts.com/ that is used in http://templight.se/ by another person in this forum, but Google charts looks great. RGraph is very easy and great HTML5 charts, but they are more "static" and not so functional as others.

I think that the jump-function (and the report?) will not be necessary if I use a more dynamic chart that have build in range, zoom, etc.. So I will look at some alternatives, starting with google's.

EDIT: Without looking at the code, I think the Highcharts will be the most dynamic to use: http://www.highcharts.com/stock/demo/. It's free for open source and looks great (?) :-)

JohanS wrote: Anyway - thanks A LOT... I would be happy to write some of this if you want some input... life is hectic right now, but will hopefully be better in a while -- then I would have more time...
Please write anything you feel are improvements or new features. I use the bootstrap-framework for design, so it should be easy to write something :-)

kayrune
Posts: 6
Joined: Thu Jan 18, 2018 11:08 am

Re: fuTelldus - PHP application for sensor-logging

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

Was almost finished setting up V1 when you release V2, so I tried to upgrade database but I got following error from mysql:

ERROR 1062 (23000) at line 35: Duplicate entry '1' for key 'PRIMARY'

I seem to have it working I get sensor, but when I do api-connect test I get nothing, also when I do cron test I get nothing on screen.

I fint the following in apache error log:

PHP Warning: require_once(/home/roberkwk/php/HTTP/OAuth/Consumer.php): failed to open stream: No such file or directory in /var/www/fuTelldusV2/inc/settings_telldus_test_api.php on line 6, referer: http://192.168.10.200/fuTelldusV2/index ... lldus_test

I find the /home/roberkwk a bit odd.. Some path that is hardcoded and shouldn't be ?


also got this error when running the cron

PHP Fatal error: require(): Failed opening required './lib/config.inc.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/fuTelldusV2/cron_temp_log.php on line 10

I changed path to lib/config.inc.php (removed ./) and seems to work.

kayrune
Posts: 6
Joined: Thu Jan 18, 2018 11:08 am

Re: fuTelldus - PHP application for sensor-logging

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

Suggestion

Make a checkbox for sensors you want public, then make the login page show shared sensors like on "home" page, and you can click on them for graph.

Also a question, why does the "home" page show logged value, when there is a live connection, couldn't you just show the live reading ?

dico
Posts: 40
Joined: Thu Jan 18, 2018 11:08 am

Re: fuTelldus - PHP application for sensor-logging

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

kayrune wrote: ERROR 1062 (23000) at line 35: Duplicate entry '1' for key 'PRIMARY'
Yes, you would get an error if you still have the default admin account in DB. I think it depends on your config for ex. phpmyadmin - but it should create the databases anyway (IF NOT EXIST).
If table is not created, you have to do one of the following:
- Remove the line from SQL
- Copy the notification part in the SQL file and create the DB manually
- Remove the default admin account (remember to create a new one :-))
kayrune wrote: I seem to have it working I get sensor, but when I do api-connect test I get nothing, also when I do cron test I get nothing on screen.
I fint the following in apache error log:
PHP Warning: require_once(/home/roberkwk/php/HTTP/OAuth/Consumer.php): failed to open stream: No such file or directory in /var/www/fuTelldusV2/inc/settings_telldus_test_api.php on line 6, referer: http://192.168.10.200/fuTelldusV2/index ... lldus_test
I find the /home/roberkwk a bit odd.. Some path that is hardcoded and shouldn't be ?
I think i'm going to remove the API connect test, because it's more or less just the default API files from Telldus - and they have no real function in the web-app.
kayrune wrote: also got this error when running the cron

PHP Fatal error: require(): Failed opening required './lib/config.inc.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/fuTelldusV2/cron_temp_log.php on line 10

I changed path to lib/config.inc.php (removed ./) and seems to work.
This should depend on your webserver and path-config in php.ini. For linux webserver the ./ should be understandable - but it have no real meaning, so I would remove it in the next version :-) Maybe I will check for the full document root...

kayrune wrote:Suggestion
Make a checkbox for sensors you want public, then make the login page show shared sensors like on "home" page, and you can click on them for graph.
Also a question, why does the "home" page show logged value, when there is a live connection, couldn't you just show the live reading ?
Good idea to make the login-page more dynamic :-)

The home/main -page show logged DB-values because of the request-time against the live servers.
The index-page loads at 667ms, and the ?page=sensors loads in 5.74s on my server atm. This is because sensor-page pulls data directly from Telldus Live.
Sensor page also store the sensor-data in DB for reference in charts and so on - So I think I'm going to read all data from DB and add a sync button instead.

Post Reply