fuTelldus - PHP application for sensor-logging

Moderator: Telldus

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

Re: fuTelldus

Post by dico »

fatuus wrote:Vill vi sätta upp en GitHub och jobba på att utveckla fuTelldus tillsammans??

Vad säger du @dico ?? Är det okay för dig?

--

Do we want to put up a GitHub and work on developing fuTelldus together ??

Hi, sorry I haven't been able to continue much developing on fuTelldus lately – as I been busy on so many other projects.

There is already a project in github for fuTelldus here: https://github.com/dico/fuTelldus. There are also some forks that I haven’t had time to review yet.

I would be happy for anyone who would continue the development of fuTelldus, and add anyone as collaborators for fuTelldus in github. Send me a mail/message if you want me to add you :-)

The license given for fuTelldus also let you start a new github-project of fuTelldus if it’s preferable.
thomp
Posts: 15
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by thomp »

Hi, i am new to fuTelldus. I tried installing to my Synology nas, but I seem to get stuck with HTTP_OAuth problems. i get this when I go to the Sensors or Lights tab:

Warning: require_once(HTTP/Request2.php): failed to open stream: No such file or directory in /volume1/web/fuTelldus/HTTP/OAuth/Consumer/Request.php on line 24 Fatal error: require_once(): Failed opening required 'HTTP/Request2.php' (include_path='.:/var/packages/PEAR/target') in /volume1/web/fuTelldus/HTTP/OAuth/Consumer/Request.php on line 24
I did download "some" packages and put the files in /fuTelldus/HTTP. But I am not sure I downloaded the right files and I can't see what I need in the installation guide video.

Can anybody help point me to the files I need to download?

Thanks,
/Thomas
petzno
Posts: 116
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by petzno »

pain123 wrote:Have finally managed to get a working Events page, where I to begin with can enable and disable my events! If you are interested then send a PM to know how to do!
:clap:
/A
Why don't you share this on the github that is made for this project, so we can have the development moving?
https://github.com/dico/fuTelldus
petzno
Posts: 116
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by petzno »

Anyone got the cron for schedule to work? As earlier mentioned I can also only get it to work with manually executing the cron file.
Letalis
Posts: 10
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by Letalis »

Works like a charm.
Thanks for your work And Merry Crhistmas.
Vaffel
Posts: 13
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by Vaffel »

Hi!

Thanks for the great webpage, Dico.

Have anyone tried to install any of the github forks to Dicos package?

I've tried and pederUs fork and that works perfectly. However, I'm most interessted in the (apparent) large updates made by jensleis and androidemil, however, upon installing I only get a blank white page when I try to access it :/
Any special trick I am missing for their proper installation?


Thanks!
dofhus
Posts: 4
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by dofhus »

Hi all,

First of thank you for a great work on the fuTelldus!

Everything works fine except when i try to implement the code below. I get the following error:

PHP Parse error: syntax error, unexpected end of file in /var/www/telldus/inc/chart_highchart.php on line 186, referer: http://192.168.1.33/telldus/index.php?p ... ergeCharts

Unfortunately my knowledge is very poor, perhaps anyone could help me out?

regards,
Dan

pederU wrote:Hi there.

I have made a combined chart for all the sensors.

Code: Select all

<script src="lib/packages/Highstock-1.3.1/js/highstock.js"></script>
<script src="lib/packages/Highstock-1.3.1/js/modules/exporting.js"></script>


<?php

	// Set how long back you want to pull data
	$showFromDate = time() - 86400*$config['chart_max_days']; // 86400 => 24 hours 

	/* TEMP SENSOR 01: Get sensors
	--------------------------------------------------------------------------- */
	$query = "SELECT * FROM ".$db_prefix."sensors WHERE user_id='{$user['user_id']}' AND monitoring='1'";
	$result = $mysqli->query($query);

	$count=0; // added counter to count the senesors
	while ($row = $result->fetch_array()) {
		echo "<div class='container'>";
		unset($temp_values);
		$joinValues = "";
		unset($hum_values);      // added humidity variables
		$joinhumValues = "";
		unset($showHumidity);
		unset ($sensorDataNow);
		
		/* Get sensordata and generate graph
		--------------------------------------------------------------------------- */
		$queryS = "SELECT * FROM ".$db_prefix."sensors_log WHERE sensor_id='{$row["sensor_id"]}' AND time_updated > '$showFromDate' ORDER BY time_updated ASC ";
		$resultS = $mysqli->query($queryS);

		while ($sensorData = $resultS->fetch_array()) {
			$db_tempValue = trim($sensorData["temp_value"]);
			$db_humValue = trim($sensorData["humidity_value"]);      //retrive humidity values
		
			$timeJS = $sensorData["time_updated"] * 1000;
			$temp_values[]        = "[" . $timeJS . "," . round($db_tempValue, 2) . "]";
			$hum_values[]         = "[" . $timeJS . "," . round($db_humValue, 2) . "]";      // do something with values
			$sensorDataNow[]=$sensorData["humidity_value"];
		}
		if ($sensorDataNow["[humidity_value]">0]) $showHumidity=1;	// Looks fore humidity greater then 0
		$joinValues = join($temp_values, ',');
		$joinhumValues = join($hum_values, ',');      // do something more with values

		// Desides if to plot the humidity or not
		if ($showHumidity==1) {
			$seriesOptions [$count] = "{name: '(" .$lang['Temperature'].") {$row['name']}', type: 'spline', data: [$joinValues], tooltip: {valueDecimals: 1, valueSuffix: '°C'}}";
			$count++;
			$seriesOptions[$count]="{name: '(" .$lang['Humidity'].") {$row['name']}', type: 'spline', data: [$joinhumValues], visible: false, yAxis: 1, tooltip: {valueDecimals: 1, valueSuffix: '%'}}";
			$count++;
		}
		else {
			$seriesOptions [$count]= "{name: '(" .$lang['Temperature'].") {$row['name']}', type: 'spline', data: [$joinValues], tooltip: {valueDecimals: 1, valueSuffix: '°C'}}";
			$count++;
			}
		echo "</div>";
	}
	rsort($seriesOptions); // sorts the sensors
	$joinSeriesData= join($seriesOptions, ',');
	$seriesData="[$joinSeriesData]";

echo <<<end
<script type="text/javascript">
		
$(function () {
Highcharts.setOptions({
	global:{
    	useUTC: false
        }
});
	$('#container').highcharts('StockChart', {

		chart: {
            type: 'spline',
            zoomType: 'x', //makes it possible to zoom in the chart
            pinchType: 'x', //possible to pinch-zoom on touchscreens
            backgroundColor: '#FFFFFF', //sets background color
            shadow: true //makes a shadow around the chart
        },
        
        rangeSelector: {
        	enabled: true,
        	buttons:[{
            	type: 'hour',
                count: 1,
                text: '1h'
            }, {
            	type: 'hour',
                count: 12,
                text: '12h'
            }, {
            	type: 'day',
                count: 1,
                text: '1d'
            }, {
            	type: 'week',
                count: 1,
                text: '1w'
            }, {
            	type: 'month',
                count: 1,
                text: '1m'
            }, {
            	type: 'month',
                count: 6,
                text: '6m'
            }, {
            	type: 'year',
                count: 1,
                text: '1yr'
            }, {
            	type: 'all',
                text: 'All'
            }],
        	selected: 2
        },

        title: {
            text: '{$lang['Combine charts']}'
        },

        plotOptions: {
            spline: {
                marker: {
                    enabled: false //hides the datapoints marker
                },
            },
        },

		legend: {
            align: "center",
            layout: "horizontal",
            enabled: true,
            verticalAlign: "bottom",
			shadow: true,
			borderColor: 'silver',
			borderWidth: 1,
			borderRadius: 5
		},

        xAxis: {
            type: 'datetime',
        },
		
        yAxis: [{
			opposite: false,
            title: {
                text: '{$lang['Temperature']} (°C)',
            },
            labels: {
                formatter: function () {
                    return this.value + '\u00B0C';
                },
                format: '{value}°C',
                    style: {
                    color: '#777'
                },
            },
        }, 
				{
            opposite: true, //puts the yAxis for humidity on the right-hand side
            showEmpty: false, //hides the axis if data not shown
            title: { // added humidity yAxis
                text: '{$lang['Humidity']} (%)',
                   style: {
                    color: '#31EBB3'
                }, // set manual color for yAxis humidity 
            },
            labels: {
                formatter: function () {
                    return this.value + '%';
                },
                format: '{value}%',
                  style: {
                    color: '#31EBB3'
                },
            },
        }],

        series: $seriesData,
	    });
});
</script>

<div id="container" style="height: 600px"></div>    
end;

?>
dofhus
Posts: 4
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by dofhus »

Hi Vaffel,

I had the same problem, i changed a part in the fuTelldus.sql file that gave me errors then it worked, but ended up with a lot of other errors but perhaps it can help you?

INSERT INTO `futelldus_users` (`user_id`, `mail`, `password`, `language`, `admin`, `chart_type`) VALUES
(1, 'admin', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', '', 1, '');

I removed the `chart_type` and also the last "" on the row below.

Kind regards,
Dan
Vaffel wrote:Hi!

Thanks for the great webpage, Dico.

Have anyone tried to install any of the github forks to Dicos package?

I've tried and pederUs fork and that works perfectly. However, I'm most interessted in the (apparent) large updates made by jensleis and androidemil, however, upon installing I only get a blank white page when I try to access it :/
Any special trick I am missing for their proper installation?


Thanks!
Vaffel
Posts: 13
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by Vaffel »

Thanks for the tip. I tried that, but still, I only get a white empty page when trying. Not so easy to debug someone elses work...
Vaffel
Posts: 13
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by Vaffel »

Ah. I finally got it to "work". That is Androidemils version dev_1. The page loads, but I got a whole load of error messages throughout the webpage.

None of the functions actually work, but all the pages loads at least. I'll see if I can figure out what's wrong. What I can tell, all the functions look very nice and interesting, and what I feel lack in the Telldus Live page :)
androidemil
Posts: 1
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by androidemil »

Hi!

I'm still using the version 3 of fuTelldus made by Dico and this is my notes from my installation on Synology that hopefully can help someone (especially with setting up the scheduling of fetching data). I also have some error messages on my fork and havent had time to fix it due to twins at home :)

Download fuTelldus v3: http://www.telldus.com/forum/viewtopic. ... 64&p=20107
Based on instructions from here: http://fosen-utvikling.no/public/futell ... lldus.html
1. Activate web station and PHP (with error messages)
2. Create the folder web/fuTelldus and copy everyting in the fuTelldus zip file (version 3) to that folder
3. Install PHPMyAdmin on your synology
4. Open config.inc.php in PHPMyAdmin folder under /volume1/web
Change $cfg['Servers'][$i]['AllowNoPassword'] = false;
to $cfg['Servers'][$i]['AllowNoPassword'] = true;
5. Change access rights on config.inc.php to chmod 644

6. Enter http://xxx.xxx.x.xx/phpMyAdmin/ (xxx.xxx.x.xx = ip to your synology) in your web browser and you should get a login popup
7. Click OK without username and password and you should get into phpMyAdmin
8. Logout and login with root as username and empty password
Comment: rekommendation to change and have a password set...
9. Create a database called futelldus (in the tab named Databases and as Collation in the dropdown)
10. Choose the database futelldus and choose tab import
11. Click on choose file and choose the file fuTelldus.sql from web/fuTelldu on your Synology
12. Click Run to import and create tables, indexes, etc
13. Enter http://xxx.xxx.x.xx/fuTelldus and you should get following error message
' Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'USERNAME'@'localhost' (using password: YES) in /volume1/web/fuTelldus/lib/base.inc.php on line 18 Connect Error: 1045'

14. Open web/fuTelldus/lib/config.inc.php and change to following

Code: Select all

	$username 	= "root"; 					// Mysql username
	$password 	= ""; 					// Mysql password if defined
	$db_name 	= "futelldus"; 				// Mysql DB

15. Open http://xxx.xxx.x.xx/fuTelldus/ and login with admin/admin
16. Choose edit on your userprofile of the admin user and enter the telldus API keys which you can get on api.telldus.com
Public key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Private key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Token secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

17. Choose the tab Sensors and you might get the following error message:
'Warning: require_once(HTTP/OAuth/Consumer.php): failed to open stream: No such file or directory in /volume1/web/fuTelldus/inc/sensors.php on line 13 Fatal error: require_once(): Failed opening required 'HTTP/OAuth/Consumer.php' (include_path='.:/usr/syno/php/lib/php') in /volume1/web/fuTelldus/inc/sensors.php on line 13'
18. Download PEAR_package_fuTelldus.zip in web/fuTelldus and upack it into same folder (http://www.telldus.com/forum/viewtopic. ... 64&p=20107)
Comment: This is not the full OAuth extension since it is hard to install the full one on Synology. If OAuth support comes to synology, this step should be unnecessary)
19. Enter sensors tab again and you might get an error 'Fatal error...', in that case you need to restart apache (or the synology station)
20. Recommendation, create a new user and remove admin

========== Scheduling ============
21. Create two shell scripts with the names cron_temp_log.sh and cron_schedule.sh in folder /volume1/web/fuTelldus/ with following content
OBS: Important to create file with UNIX style EOL (End Of Line), should be fine if done through synologys editor.
cron_temp_log.sh

Code: Select all

#!/bin/ash
cd "/volume1/web/fuTelldus/"
php -q /volume1/web/fuTelldus/cron_temp_log.php
cron_schedule.sh

Code: Select all

#!/bin/ash
cd "/volume1/web/fuTelldus/"
php -q /volume1/web/fuTelldus/cron_schedule.php
22. Create CRON jobs to fetch temperatures and other notifications
Start putty and login into shell as root user
vi /etc/crontab
Add following rows (important that it is tab separated, at this point it is not possible to create reccuring runs on minutes through synology interface)

Code: Select all

*/15	*	 *	*	*	root	ash /volume1/web/huset/cron_temp_log.sh
*/5	*	*	*	*	root	ash /volume1/web/huset/cron_schedule.sh
Restart CRON scheduler (or synology station)
/usr/syno/etc/rc.d/S04crond.sh stop
/usr/syno/etc/rc.d/S04crond.sh start
Vaffel
Posts: 13
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by Vaffel »

Thanks for the tutorial, AndroidEmil!

Will you ever fix your fork? I'm currently not using Synology, but am very interessted in all the other functions, plugins, and charts that's in your version of fuTelldus. I guess some of the functions were made/introduced by Jensleis, but I cannot seem to get that version to work either.
sonny
Posts: 4
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by sonny »

Hi

I need an easy to use sensor logging utility for use with the Tellstick Net and a Windows pc. I tried to download and install the fuTellus, but I do not have enough knowledge to do it it seems :-(

Is there an another alternative - "Tellstick Net sensor logging for dummies"?

Thanks in advance!
disktant
Posts: 34
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by disktant »

petzno wrote:Anyone got the cron for schedule to work? As earlier mentioned I can also only get it to work with manually executing the cron file.
My schedule runs and I get Email notifikations, but my heaters won't turn on
cant figure out why ?

#1458926: Vardagsrum
If Temperature is Lower than than 5°
Element vardagsrum (On)
csom
Posts: 20
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by csom »

Heggholmen wrote:Hi,
Have installed fuTelldus on my WindowsHomeServer 2011 - and it looks to work half way. I can se my "devices" - and use them, but I don't have the sensor list. Anyone got an idee on how to solve it?

Have also notices that when I try to add a new user - the user table isn't updated. I also found out that sensors is not saved in the database - when "echo" the variables from sensors.php - it shows infoformation.

New observation - when I add a sensor manual in "futelldus_sensors" - the cron_temp_log.php inserts new data when it's runed... Soo - why isn't "sensors" list updated:/
I seem to have the same problem.

I'm running Mac OS X server with apache. I got fuTelldus up and running except the sensor page. I also have the same issue with creating users. it seems that fuTelldus can't write to my mysql. the cronscript does not write any sensor data to my database like the creating user part where nothing gets saved to database either. Everything else is working, devices shows up.

Anyone have a suggestion how to solve this?

/Pär
Post Reply