Page 1 of 3

RecentOutsideTemp - one year ago?

Posted: Sat 23 Jan 2016 11:25 am
by wetterfrosch1971
Hi,

is it possible to show on webspace the temperature from one year ago ?
With <#RecentOutsideTemp> is max. 1 week possible.
If is possible to show the temperature from 1 year ago?

thanks for info.
Frank

Re: RecentOutsideTemp - one year ago?

Posted: Sat 23 Jan 2016 11:32 am
by steve
You can go back a week with the 'recent data' web tags. To make accessing the data efficient, it is held in memory. If it held a year's worth of data at a 1-minute interval, Cumulus would use a huge amount of memory, and its performance would probably suffer. By far the best way to compare with a year ago is to use an SQL database - a number of people do this.

Re: RecentOutsideTemp - one year ago?

Posted: Sat 23 Jan 2016 12:18 pm
by wetterfrosch1971
Hi,

However, the values have to be stored somewhere in Cumulus, because I can call up the temperature graphic from one year ago.

Can I access this data anyway?

or can I use this data for a SQL-database?

thanks for help.
Frank

Re: RecentOutsideTemp - one year ago?

Posted: Sat 23 Jan 2016 12:50 pm
by steve
wetterfrosch1971 wrote:However, the values have to be stored somewhere in Cumulus, because I can call up the temperature graphic from one year ago.
They are in the monthly data logs, they're not held in memory. Searching through flat files on disk every time a web tag is processed is probably not a good idea. That's the approach I've taken, anyway.

There is information in the wiki about importing Cumulus log files into a MySQL database, and several examples in the forum of people using MySQL for their web sites.

Re: RecentOutsideTemp - one year ago?

Posted: Sat 23 Jan 2016 3:15 pm
by PaulMy
Hi Frank,
I have my dayfile.txt and most of my monthly log files in a MySQL database but only use a small amount of it as not very familiar with using it. Forum assistance here has helped my get the Top 10 and a couple of other displays http://www.komokaweather.com/komokaweat ... isdate.php and http://www.komokaweather.com/komokaweat ... maxmin.php

However, another way is to use the Meteotemplates which is based on MySQL www.komokaweather.com/j-template

Enjoy,
Paul

Re: RecentOutsideTemp - one year ago?

Posted: Sat 23 Jan 2016 3:40 pm
by wetterfrosch1971
Hi Paul,

thank you for your Information.

It is the right way for me.

I need only the temperature from one year ago, but I don´t know how I use "SQL", because I´m a beginner.

I want to show the temperature from one year ago in the cumulus-index.htm (nearly the actually temperatur), is this possible?

thanks for help
frank

Re: RecentOutsideTemp - one year ago?

Posted: Sat 23 Jan 2016 5:43 pm
by PaulMy
I want to show the temperature from one year ago in the cumulus-index.htm (nearly the actually temperatur), is this possible?
I am sure it is possible but how to actually do it is beyond my knowledge, sorry. But I can give you an example of what I have been able to do and this might be something you can look to modify for your use.

In addition to my dayfile in MySQL I also have dayfile.txt in my /weather folder where all my Cumulus template files are http://www.komokaweather.com/weather/index.htm. I presume a php script can be written to get data from that dayfile.txt such as high temp, or any other data in the file, and then have that executed in your index.htm.

I have something similar in my indexT.htm

Code: Select all

			<!-- BT Sager Forecaster v.2014-01-31 -->
			<p><b>Sager 12-24 Hour Forecast:</b>
				<a href = "bt-sager.php" style = "text-decoration:none;" target = "_blank"><script src = "bt-sager-wc.php" type="text/javascript"></script></a></p>
			<!-- End of BT-Sager Forecaster -->
			
			<table width="100%"  border="0" cellpadding="0" cellspacing="0">
				KomokaWeather Conditions at local time <#time format="hh:nn am/pm"> on <#date format="dddd dd mmmm yyyy"> (use Browser Refresh to update)
				<br />
				<!-- added for curconditions.php -->				
					<?php echo $condOut; ?>
				<!-- End -->
That displays the BT-Sager Forecast and JennyLeez CurrentConditions text in weather/index page http://www.komokaweather.com/weather/index.htm. You should similarly be able to add code to your indexT.htm so that index.htm includes the PHP script that gets the 1 year ago temperature(s) from dayfile.txt and places that variable wherever you want with an <?php echo $dayfilevariable; ?>

Not sure if that example makes sense as I may have gotten it wrong or incomplete, but with the help of several people here I have been able to get such things added and working... thanks mcrossley, BCJKiwi, Jennyleez, beteljuice and daj!

Enjoy,
Paul

Re: RecentOutsideTemp - one year ago?

Posted: Tue 26 Jan 2016 7:14 pm
by wetterfrosch1971
Hi,

I have the solution.

I have a PHP-script.
This script must include in the index.htm from cumulus but it works only if I rename the index.htm to index.PHP.

But if I rename the index.htm to index.php, than then the file no longer works because cumulus must be have index.htm and not index.PHP.

Can I rename the index somewhere in cumulus-system, so it works with index.php?

Thanks for help.
Peter

Re: RecentOutsideTemp - one year ago?

Posted: Tue 26 Jan 2016 8:15 pm
by PaulMy
Very good work. You should also be able to duplicate the modified indexT.htm as indexT.php and have it processed and uploaded by Cumulus as one of the extra FTP files I would think. You would then have both index.htm, as one of the Standard Cumulus web files, and index.php, as the extra file, on your website.

Likely will also need to change any links on your website from index.htm to index.php (including the navigating menu at the bottom).

Would you mind sharing the PHP script?

Regards,
Paul

Re: RecentOutsideTemp - one year ago?

Posted: Tue 26 Jan 2016 8:38 pm
by wetterfrosch1971
here are the php-script.
for work, you must upload all cumulus monthly-log-Datei from last year on the webserver, for example "jan15log.txt"
and rename to "january.txt"
this must be make with all the monthly log datei

Code: Select all

<?php
  
  
  date_default_timezone_set('Europe/Berlin'); //actually Date and Time (timezone middle europe)
  $now  = time();
  $now -= $now % 60;  //remove the seconds-display
  $past = strtotime(date('d-m-Y H:i', $now) . ' - 1 year'); //subtract 1 year

  
  $lines = file(strtolower (date('F')).'.txt'); //read the monthly-log-Datei 
                                                             //the Datei must be on Webspace as january.txt...etc  
                                                             //the Datei must be in the same file on webspace in wich this php-scipt saved

  foreach ($lines as $row){
    $row = explode(';', $row);

    $teileDat  = explode('.',$row[0]);
    $teileZeit = explode(':',$row[1]);

    $datstamp = mktime($teileZeit[0],$teileZeit[1],'00',$teileDat[1],$teileDat[0],$teileDat[2]);

   

    if($datstamp === $past)   //compare the actually date/time (subtract 1 year) with the date/time one year ago
    {
      // results found
      
      echo $row[2].'<br>'; //print temperature from last year
	 
	  
    }
    else {
      // no results

    }
}


?>

Re: RecentOutsideTemp - one year ago?

Posted: Wed 27 Jan 2016 2:00 am
by PaulMy
Thanks Peter,
Unfortunately my PHP as well as HTML knowledge is severely lacking. I was able to get some output, but not correct and in a long table with today's dates repeated on each line and temperatures which I suspect is each temp recorded for a day but not last year this date. I have other methods of showing the temp last year for this date, as well as for each of the prior years, just thought I could try it and learn.

Good luck with your endeavour.
Paul

Re: RecentOutsideTemp - one year ago?

Posted: Wed 27 Jan 2016 2:28 pm
by wetterfrosch1971
The problem with you is the date and time Display.

the script works with the german time and date Display, but in England the time and date Display are other.

I don´t can explain, becaus my english is very bad.

the script compares the actually date and time (less one year) with the date and time from the log.txt-data from last year.
in the script is this here:

Code: Select all

if($datstamp === $past){
when this is right, than will be displayed the temperature from last year.
when this is wrong, it will be no Display.

you must upload all the 12 monthly-log data from last year on your Webspace and rename in to january.txt, february.txt...(small letters)

I hope you understand my bad english.
Frank

Re: RecentOutsideTemp - one year ago?

Posted: Wed 27 Jan 2016 3:08 pm
by PaulMy
Hi Frank,
And thanks for the explanation, and your English is quite good.

I thought it was date related and I have changed the time zone to America/Toronto. I also may have a difference in date format and data separator. I have uploaded all of the monthly log files going back to 2008 but not yet changed all the names - only Jan15log.txt to january. Unlike your working understanding of English, my understanding of the German comments in the script is lacking and Google is not always the answer.

I had thought of also getting the temp for the date for each of the prior years but that will require quite some modification which is likely beyond what I can do, but giving it a try is my satisfaction. As I mentioned earlier, I have been able to get the data from MySQL and have it in another script. However your enquiry initiated my attempt to follow your lead.

Best regards,
Paul

Re: RecentOutsideTemp - one year ago?

Posted: Wed 27 Jan 2016 4:47 pm
by wetterfrosch1971
Hi,

I´ve translate the German comments in to english, look in to the script in my early post.

the Datum and time in the txt-datei is in the german Version, look:

Code: Select all

22.01.15;20:25;1,2;98;0,9;2,5;5,0;46;0,0;0,0;1016,9;0,6;23,4;25;5,0;1,2;1,2;0;0;0,00;0,00;-1,1;0;0,0;45;0,0;0,0
22.01.15;20:26;1,4;98;1,1;4,4;7,2;82;0,0;0,0;1016,9;0,6;23,4;25;7,2;1,4;1,4;0;0;0,00;0,00;-1,3;0;0,0;90;0,0;0,0
22.01.15;20:27;1,2;98;0,9;5,2;7,2;67;0,0;0,0;1016,9;0,6;23,4;25;7,2;-0,3;1,2;0;0;0,00;0,00;-1,6;0;0,0;45;0,0;0,0
22.01.15;20:28;1,2;98;0,9;4,6;7,2;71;0,0;0,0;1016,9;0,6;23,4;25;6,1;1,2;1,2;0;0;0,00;0,00;-1,5;0;0,0;360;0,0;0,0
22.01.15;20:29;1,2;98;0,9;4,2;7,2;59;0,0;0,0;1016,9;0,6;23,4;25;3,6;1,2;1,2;0;0;0,00;0,00;-1,5;0;0,0;360;0,0;0,0
and the same date and time code must be the actually date and time who works in the script,
for example: date = 22.01.15 (day month year) and time = 20:25 (hour Minute)

Re: RecentOutsideTemp - one year ago?

Posted: Wed 27 Jan 2016 7:48 pm
by PaulMy
Thanks again Frank,
I am not at home right now but will look at it again this evening, and your date/time format example will certainly help as it is different than in my log files so I will try to modify the script to match mine.

Regards,