fuTelldus - PHP application for sensor-logging

Moderator: Telldus

kayrune
Posts: 6
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by kayrune »

dico wrote:
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...
Are you sure? I'm no programmer but have some linux experience. I guess if php was chrooted in fuTelldus folder it would work. But in my case I think the ./ would move out of the fuTelldus folder (to /var/www). If cron_temp_log.php is located in root of fuTelldus folder shouldn't it allways be safe to use "lib/config.inc.php" as path ?
dico wrote:
kayrune wrote:why does the "home" page show logged value, when there is a live connection, couldn't you just show the live reading ?
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.
That makes sense, for me there is no latency at all for any pages, but I currently only have 1 sensor set up, maybe with more there would be latency issues.
dico
Posts: 40
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by dico »

kayrune wrote: Are you sure? I'm no programmer but have some linux experience. I guess if php was chrooted in fuTelldus folder it would work. But in my case I think the ./ would move out of the fuTelldus folder (to /var/www). If cron_temp_log.php is located in root of fuTelldus folder shouldn't it allways be safe to use "lib/config.inc.php" as path ?
Pretty sure :-)

Quote from PHP manual: http://us.php.net/manual/en/ini.core.ph ... clude-path
Using a . in the include path allows for relative includes as it means the current directory. However, it is more efficient to explicitly use include './file' than having PHP always check the current directory for every include.
A more descriptive phrase found in stackoverflow, but it looks like this sentence is (re)moved from the link to the PHP manual.
http://stackoverflow.com/questions/5793 ... lude-calls
Files for including are first looked for in each include_path entry relative to the current working directory, and then in the directory of current script. E.g. if your include_path is libraries, current working directory is /www/, you included include/a.php and there is include "b.php" in that file, b.php is first looked in /www/libraries/ and then in /www/include/. If filename begins with ./ or ../, it is looked only in the current working directory.
AcidSleeper
Posts: 28
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by AcidSleeper »

Dico:
I have written a Swedish langagepack and updated thé code in one file. Thé text languages was hardcoded.
Some mailadres I could send thé files?
dico
Posts: 40
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by dico »

AcidSleeper wrote:Dico:
I have written a Swedish langagepack and updated thé code in one file. Thé text languages was hardcoded.
Some mailadres I could send thé files?
E-mailaddress can be found in readme.txt (in root) :-)
JohanS
Posts: 14
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by JohanS »

dico wrote:
kayrune wrote: Are you sure? I'm no programmer but have some linux experience. I guess if php was chrooted in fuTelldus folder it would work. But in my case I think the ./ would move out of the fuTelldus folder (to /var/www). If cron_temp_log.php is located in root of fuTelldus folder shouldn't it allways be safe to use "lib/config.inc.php" as path ?
Pretty sure :-)

Quote from PHP manual: http://us.php.net/manual/en/ini.core.ph ... clude-path
Using a . in the include path allows for relative includes as it means the current directory. However, it is more efficient to explicitly use include './file' than having PHP always check the current directory for every include.
Just a comment there - I had to change this from ./lib/something to the full path including /var/www/fuTelldus_v1/... in order to get the the cronjob working (see post above - among all the incoherent things). I just edited it back to the "original version" and lo and behold, now it works again!!! I have NO IDEA of why, I am 100% sure it did not work before, hence the EDIT #2 in the previous post... But there could potentially be some issues with the "./" in php (although back in the days when I did php3/4 this was never ever any issues so I cannot see why it should be now)...

Just trying to keep the thread alive - or at least showing that I am :)
kayrune
Posts: 6
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by kayrune »

Suggestion:

it may not be a problem now, but as the thread grows it's confusing. So add download link to V2 in first post.
dico
Posts: 40
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by dico »

Version #3 released!
(Some new screenshots in the first post)

DOWNLOAD:
Version 03: http://fosen-utvikling.no/public/futell ... dus_v3.zip (released 13.04.2013)


Install
Read the readme.txt file
(and read the forum thread)


Upgrade
Upgrade from version 1 or 2 can be a bit tricky, because the database is changed. Ex. notifications renamed to schedule with new fields, new table for devices, new config fields...
I recommend that you backup your old version (FILES and DATABASE), delete the old stuff and upload/import the new version (FILES and DATABASE).

Table: futelldus_sensors_log (that holds your temperature data) is same as before, so I recommend that you particularly take backup or don't delete this one.
config.inc.php for your database connection is also unchanged.

"cron_notifications.php" in version 2 is renamed to "cron_schedule.php" - so you need to edit your cron file (if upgrade from v2).

I will try to make the upgrade more easy with a GUI in the feature, when all the core features and most of the bugs are out of the way.


New features:
[*] Turn on/off sync for sensor/device-list from Telldus Live in config (to speed up things)
[*] Control your lights
[*] Schedule - Send commands when temperature is high/low
[*] Swedish language added (author: AcidSleeper in forum)
[*] New chart type, Highcharts. Switch between old and new charttype in settings.
[*] Select sensors for public view - in a new own public page (without login)

Changes:
[*] sensors.php changed with check for list-sync from Telldus Live
[*] Telldus-test-connection under settings removed
[*] Notifications in version 2 renamed to Schedule (new feature)
[*] Removed ./ in front of lib-path for CRON files

Bugs:
[*] settings_user.php was missing language-variable for "Languages" headline



My next priority will be to create some better charts and maybe phase out the old chart.
dico
Posts: 40
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by dico »

Bug in version 3
- Can't delete schedule-task

Edit line 328 in "inc/settings_schedule.php"

From:

Code: Select all

echo "<li><a href='?page=settings_exec&action=deleteNotification&id={$row['notification_id']}'>Delete</a></li>";
To:

Code: Select all

echo "<li><a href='?page=settings_exec&action=deleteSchedule&id={$row['notification_id']}'>Delete</a></li>";
JohanS
Posts: 14
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by JohanS »

Hi!

I must be slowly getting old... Tried to install version 3 from scratch... no luck so far. I will keep trying tomorrow, try to follow my own steps in my "guide" that I only half-finished and see if I can get it up and running... right now - no go :/(

Reason for posting: In case I find the "error" I will update here and help all other users who end up with a "fail" as well...

P.S. fuTelldus (version 1) runs perfect on a Raspberry pi... once version 3 is working next goal will be to get it to work on a NetGear NAS...

Cheers!
Johan
dico
Posts: 40
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by dico »

JohanS wrote: I must be slowly getting old... Tried to install version 3 from scratch... no luck so far. I will keep trying tomorrow, try to follow my own steps in my "guide" that I only half-finished and see if I can get it up and running... right now - no go :/(

Reason for posting: In case I find the "error" I will update here and help all other users who end up with a "fail" as well...

P.S. fuTelldus (version 1) runs perfect on a Raspberry pi... once version 3 is working next goal will be to get it to work on a NetGear NAS...
I have added some tutorials in the first post, but not for Raspberry yet. I have one, so if I got some free time, I could make a tutorial for it as well. If you don't ... ? :-)
Hope to develop a upgrade GUI in the future, as mentioned.

I would think the Ubuntu server tutorial would be similar to install on the Raspberry?
JohanS
Posts: 14
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by JohanS »

Hi dico!

Well, the "install" procedure is very similar... but I keep running into problems with the require statements... looking in the apache error log I see:

Code: Select all

[Wed Apr 17 20:29:49 2013] [error] [client 192.168.1.3] PHP Warning:  require(/var/www/fut/lib/base.inc.php): failed to open stream: Permission denied in /var/www/fut/index.php on line 2
[Wed Apr 17 20:29:49 2013] [error] [client 192.168.1.3] PHP Fatal error:  require(): Failed opening required '/var/www/fut/lib/base.inc.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/fut/index.php on line 2
I tried changing the path to relative, absolute, etc. etc. (above it is absolute) and well.. no luck so far...
Well, after further investigateing (reading the error) I saw that this was a problem with permissions, the easy fix is to chmod -R 777 fut (in my case fut) and then things "just work"... I guess I should look into users and groups... I thought I had things figured out... anyway - this is a DANGEROUS fix but for those who dare chmod 777 is the way to go. The REAL way to go is to make sure apache can read that file... (I tried both chown and chgrp so more work is needed from my side I guess...)

When reading about this online it seems like one should use absolute paths all the time (http://stackoverflow.com/questions/5364 ... uired-file, http://stackoverflow.com/questions/5437 ... g-required) by either the FILE or DOCUMENT ROOT "command"... but since I made this absolute "by hand" I cannot see why it is not working.

Hope this helps someone out there...


EDIT:
Well, once it is up and running I feel an urgent need to say that this version surely looks GREAT...fantastic! I REALY like the highcharts... However
1. The combine charts is a bit wonky, if Highcharts are selected would it not make sense that something similar to http://www.highcharts.com/demo/line-basic is shown? Perhaps one for temerature and one for humidity and one where all are combined? That way I can select what to compare over time...

2. After clicking "combine charts" perhaps the option would be called "un-combine charts" and would "get you back to the other state. Perhaps a defalt value can be set in the settings? I would then pick combine charts and have the three charts mentioned above to look at...

3. In the "menu" of the high charts there are lots of white spaces (line breaks) - at least for me. This is a very minor detail...

4. In the settings page "Delte sensorer" is in "no" although I am in "en" mode (being swedish this is not a problem but for others....)

5. I see no humidity in the highcharts (!)

6. Since all the data is there, perhaps one can add an "export as cvs" button somewhere, so people can download the data in some format if needed to manipilate elsewhere... perhaps like:
year, month, day, hour, minute, second, sensor, temperature, humidity, update_time (from Live!), ...???

Please see my comments as being amazed, not as complaints but as trying to give something back... this was just my first minutes with version 3... once I see more in the coming days I hope to give more feedback...

GREAT WORK, I am amazed...

EDIT #2:
When looking at various charts then perhaps this one would be the best: http://www.highcharts.com/demo/spline-irregular-time since it allows for non-linear spacing, and since mostly everyone will run the cronjob AT LEAST once by command then at least one point will be irregular in time... dont know how important this is but just a thought... This "model" also has clickable names hence one can add and remove data as needed "easily"...
End of EDIT #2

EDIT #3:
There seems to be a bug with the time-zone when viewing the data in Highcharts, it is off by -2 hours, I live in Sweden, so I am GUESSING it defaults to GMT... I will see if I can hunt it down before the wife comes home, then I will let you know where it is...
Hunted. I didnt find it (looked in inc/charts_highcharts.php - infact it looks like it should work AND show humidity... well, now off to other adventures for a while...
End of EDIT #3.

P.S. in my error log I did see this:

Code: Select all

[Wed Apr 17 20:50:27 2013] [error] [client 192.168.1.3] PHP Warning:  join(): Invalid arguments passed in /var/www/fut/inc/chart_highchart.php on line 43, referer: http://192.168.1.6/fut/index.php
But I was unable to reproduce it so perhaps it was nothing...???
dico
Posts: 40
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by dico »

JohanS wrote: When reading about this online it seems like one should use absolute paths all the time (http://stackoverflow.com/questions/5364 ... uired-file, http://stackoverflow.com/questions/5437 ... g-required) by either the FILE or DOCUMENT ROOT "command"... but since I made this absolute "by hand" I cannot see why it is not working.
Did you config the webserver from scratch? Perhaps you should look at some web-packages like LAMP (in ubuntu), xampp or WAMP (wamp is probably only for win?)? PHP would look in the ini_include_path for the files needed. You could either set this in the php ini file or just add ini_set in config.inc.php.
Doc: http://php.net/manual/en/function.set-include-path.php

If include path is not set, the (or any) application would need the full document root. This is also the problem with PEAR and oAuth in most cases - because the PEAR installs outside of the web-root and needs to be added in the include path. When I installed PEAR on ubuntu, the include path seams to be updated on install.

JohanS wrote: Well, once it is up and running I feel an urgent need to say that this version surely looks GREAT...fantastic! I REALY like the highcharts... However
1. The combine charts is a bit wonky, if Highcharts are selected would it not make sense that something similar to http://www.highcharts.com/demo/line-basic is shown? Perhaps one for temerature and one for humidity and one where all are combined? That way I can select what to compare over time...

2. After clicking "combine charts" perhaps the option would be called "un-combine charts" and would "get you back to the other state. Perhaps a defalt value can be set in the settings? I would then pick combine charts and have the three charts mentioned above to look at...

3. In the "menu" of the high charts there are lots of white spaces (line breaks) - at least for me. This is a very minor detail...

4. In the settings page "Delte sensorer" is in "no" although I am in "en" mode (being swedish this is not a problem but for others....)

5. I see no humidity in the highcharts (!)

6. Since all the data is there, perhaps one can add an "export as cvs" button somewhere, so people can download the data in some format if needed to manipilate elsewhere... perhaps like:
year, month, day, hour, minute, second, sensor, temperature, humidity, update_time (from Live!), ...???

Please see my comments as being amazed, not as complaints but as trying to give something back... this was just my first minutes with version 3... once I see more in the coming days I hope to give more feedback...
I used highSTOCK charts to get the timeline at the bottom, but I really don't like the highcharts/highstock docs... I couldn't figure out how to get multiple lines in highstock chart, in a seamless way - Because the time is added in the same line as the data, so the mouseover-function would be kind of buggy when it needs the relay on multiple time for each line in the x-axis. Ex. the livingroom-temp and my outside-temp don't have exactly the same timestamp.

So it would probably be best to change from highstock to highchart (like the link you posted). The downside would be that you don't get the timerange at the bottom - and the from/to date filter at the top. So it would be like a more beautiful RGraph. Maybe I will use highstock for single view and highchart for multiple. As mentioned in prev post, I need to use more time on the charts :-)

I got some feedback (not in the forum) that humidity shouldn't be in the same chart (i know it's missing in the highcharts/highstock right now), because of the range in y-axis. But this was a bigger problem with the RGraph being pretty static. Highcharts is more dynamic and you could hide/show temp/humidity in the chart.

To sum up:
1. I will use some time to create different types
2. Hope to remove RGraph, then combining would be in the highchart itself
3. No whitespace in my setup... ?
4. Missing a language variable. Will fix this.
5. Will fix this.
6. Great idea

I'm grateful for every comment, ideas and suggestions :-)
JohanS wrote: EDIT #3:
There seems to be a bug with the time-zone when viewing the data in Highcharts, it is off by -2 hours, I live in Sweden, so I am GUESSING it defaults to GMT... I will see if I can hunt it down before the wife comes home, then I will let you know where it is...
Hunted. I didnt find it (looked in inc/charts_highcharts.php - infact it looks like it should work AND show humidity... well, now off to other adventures for a while...
I'm not sure it's a timezone problem. The highcharts require JS-time and not unix-time. So the unix-time is multiplied with 1000 as written in the highchart docs. The data looks correct when comparing to the RGraph, it's just looks like the highchart cuts away the latest two hours for some reason. I have to test and read some documentation again :-)
rogerthn
Posts: 2
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by rogerthn »

I guess that I should start with Mange mange takk :D

I'm running this on CentOS 6.4 (at home :P ) and when running cron_temp_log.php from crontab or command line I did get some warnings like below.

Code: Select all

PHP Warning:  session_start(): open(/var/lib/php/session/sess_fult322cbjga8ho6pbv8ru8c83, O_RDWR) failed: Permission denied (13) in /var/www/html/Telldus3/cron_temp_log.php on line 3
PHP Warning:  Unknown: open(/var/lib/php/session/sess_fult322cbjga8ho6pbv8ru8c83, O_RDWR) failed: Permission denied (13) in Unknown on line 0
PHP Warning:  Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0
Since I don't like Warnings :wink: I did modify cron_temp_log.php and besides no Warnings I do get some information when testing from browser :o

Changes as below

Code: Select all

diff cron_temp_log.php.ORG cron_temp_log.php
2,5c2,6
< 	ob_start();
< 	session_start();
< 
< 
---
> if (empty($_SERVER['argc'])){
>         echo "Start " . date('Y-m-d H:i:s') . "<br>";
>         ob_start();
>         session_start();
> }
113,114c114,117
< 
< ?>
\ No newline at end of file
---
> if (empty($_SERVER['argc'])){
> 	echo "Done " . date('Y-m-d H:i:s') . "<br>";
> }
> ?>
Modified file enclosed zipped since The extension php is not allowed.

HaDe
Roger
Attachments
cron_temp_log.php.zip
(1.38 KiB) Downloaded 958 times
Image
hord
Posts: 6
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by hord »

Thank you for sharing this great piece of work! This is just what I need (well, not exactly need, but loves to play with;) for my Net and Live!

I followed your Synology guide and installed V3.0. Result: OK - My sensors and lights showed up fine in fuTelldus.

I followed your "Setting up CRON on Synology DSM".
Then this file "/usr/bin/php /volume1/web/fuTelldus/cron_temp_log.php" returned blank via putty, as a good result. (After extracting my PEAR and oAuth files to my web-application root and adding the ini_path in lib/config.inc.php)

The problem is the other cron file:
Then this file "/usr/bin/php /volume1/web/fuTelldus/cron_schedule.php" returned some warnings and errors:

Code: Select all


login as: root
root@192.168.10.110's password:


BusyBox v1.16.1 (2013-03-01 01:20:13 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

DiskStation> /usr/bin/php /volume1/web/fuTelldus/cron_temp_log.php



DiskStation> /usr/bin/php /volume1/web/fuTelldus/cron_schedule.php
PHP Warning:  require(): open_basedir restriction in effect. File(./lib/base.inc
.php) is not within the allowed path(s): (/etc.defaults:/usr/bin/php:/usr/syno/s
ynoman:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services
/web:/var/services/photo:/var/services/blog:/var/services/homes) in /volume1
/web/fuTelldus/cron_schedule.php on line 5

Warning: require(): open_basedir restriction in effect. File(./lib/base.inc.php)
is not within the allowed path(s): (/etc.defaults:/usr/bin/php:/usr/syno/synoma
n:/etc:/var/run:/tmp:/var/spool/php:/volume1/@tmp/php:/var/services/web:/var/ser
vices/photo:/var/services/blog:/var/services/homes) in /volume1/web/fuTelldus/cr
on_schedule.php on line 5
PHP Warning:  require(./lib/base.inc.php): failed to open stream: Operation not
permitted in /volume1/web/fuTelldus/cron_schedule.php on line 5

Warning: require(./lib/base.inc.php): failed to open stream: Operation not permitted
 in /volume1/web/fuTelldus/cron_schedule.php on line 5
PHP Fatal error:  require(): Failed opening required './lib/base.inc.php' (include_path=
'.:/usr/syno/php/lib/php') in /volume1/web/fuTelldus/cron_schedule.php on line 5

Fatal error: require(): Failed opening required './lib/base.inc.php' (include_pa
th='.:/usr/syno/php/lib/php') in /volume1/web/fuTelldus/cron_schedule.php on line 5
DiskStation>
Since you had a nice fix to the cron_temp_log.php faults, I hope you can guide me out of this problem...
(Maybe not needed to say, but the scheduler does not work for me;)

EDIT: Solved! (2013-04-28) Se my next post for details.

Keep up the good work!

Best regards,
Hord
Last edited by hord on Sun Apr 28, 2013 10:47 am, edited 1 time in total.
dico
Posts: 40
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by dico »

hord wrote: Since you had a nice fix to the cron_temp_log.php faults, I hope you can guide me out of this problem...
(Maybe not needed to say, but the scheduler does not work for me;)
Scheduler won't work if the cron doesn't work.

Looks like you don't have permissions or can't find the path. Make sure to add the ini_set to the config file for the synology (as written in the PDF-guide).
Maybe you have to set userrights to you're folder as well - it's not best practice to set full permissions, but it's greats for tests, so try to chmod 777 on you'r fuTelldus root folder. Remember you also need to be logged in as "root" in putty, not as "admin".


Just to inform you all: I'm currently using both of my hands on another project right now. But i'm hoping to focus more on this project in a couple of weeks. I will try to read the forum as much as I can to help those who have problems :-)
Post Reply