fuTelldus - PHP application for sensor-logging

Moderator: Telldus

pederU
Posts: 3
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by pederU »

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;

?>
Nautilus
Posts: 80
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by Nautilus »

pederU wrote:Hi there.

I have made a combined chart for all the sensors.
Great! Will definitely give this a try once I'm back home... :)
Nautilus
Posts: 80
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by Nautilus »

Nautilus wrote:
pederU wrote:Hi there.

I have made a combined chart for all the sensors.
Great! Will definitely give this a try once I'm back home... :)
Works a treat, thanks! :D
frigol33t
Posts: 7
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by frigol33t »

Hi!
I just tested to create a schedule that will send me an email if a sensor value goes below 4 celsius but i´m not recieving any email.
I guess i need to make some SMTP settings somewhere to allow my raspberry pi to send the emails externally.

How can i set it up using my gmail as smtp authentication?
kenthr
Posts: 2
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by kenthr »

Hi!

After installing fuTelldus and added the api keys I do not get an overview of my switches and so on.
I get this error message in my httpd log file:

HTTP_OAuth_Exception: Unable to connect to tcp://api.telldus.com:80. Error: php_network_getaddresses: getaddrinfo failed: Name or service not known in /fuTellus/HTTP/OAuth/Consumer.php on line 257
HTTP_OAuth_Consumer->sendRequest('http://api.telld&hellip;', Array, 'GET') fuTellus/HTTP/OAuth/Consumer/Request.php on line 235

Does anyone have an idea of what could be wrong?
I solved it, it was partly DNS problems and wrong api keys...
X3M King
Posts: 27
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by X3M King »

Just got this right. and i think its working just fine.

BUT

i doesent recive any emails.

where shall i type in the serveradress for sening the mail?
X3M King
Posts: 27
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by X3M King »

frigol33t wrote:Hi!
I just tested to create a schedule that will send me an email if a sensor value goes below 4 celsius but i´m not recieving any email.
I guess i need to make some SMTP settings somewhere to allow my raspberry pi to send the emails externally.

How can i set it up using my gmail as smtp authentication?
did you get this right?
fatuus
Posts: 6
Joined: Fri Mar 17, 2023 9:45 am
Location: Stockholm, Sweden

Re: fuTelldus - PHP application for sensor-logging

Post by fatuus »

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
I´m interested in your settings page and enable and disable events!
droidman
Posts: 1
Joined: Fri Mar 17, 2023 9:45 am

Sv: fuTelldus - PHP application for sensor-logging

Post by droidman »

after playing with fuTelldus for a week, the plan is to mount this old android tablet in the kitchen.... and extend with more house data such as power consumption
uploadfromtaptalk1408698867155.jpg
uploadfromtaptalk1408698867155.jpg (43.64 KiB) Viewed 18358 times
uploadfromtaptalk1408698859452.jpg
uploadfromtaptalk1408698859452.jpg (39.01 KiB) Viewed 18358 times
pederU
Posts: 3
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by pederU »

fatuus wrote:
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
I´m interested in your settings page and enable and disable events!

I second that.
Nautilus
Posts: 80
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by Nautilus »

pederU wrote:
fatuus wrote:
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
I´m interested in your settings page and enable and disable events!

I second that.
Yes, why not share it here please? :)
comaglove
Posts: 7
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by comaglove »

How does email notifications works? Cant find anywhere to fill in, for example, SMTP, and so on.
fatuus
Posts: 6
Joined: Fri Mar 17, 2023 9:45 am
Location: Stockholm, Sweden

Re: fuTelldus - PHP application for sensor-logging

Post by fatuus »

Sometimes I get error code 500 in my cron_temp_log.php file. Someone else??
Michael_MMX
Posts: 14
Joined: Fri Mar 17, 2023 9:45 am

Re: fuTelldus - PHP application for sensor-logging

Post by Michael_MMX »

jnsfi wrote:I'm also interested to join development and I am currently doing touch screen UI over fuTelldus. :)

Image

Image

Image
Nice! Will you share the files for the GUI?
fatuus
Posts: 6
Joined: Fri Mar 17, 2023 9:45 am
Location: Stockholm, Sweden

Re: fuTelldus

Post by fatuus »

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 ??
Post Reply