Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4017) - 17 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Comparing with one year ago

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

User avatar
dazza1223
Posts: 860
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: Comparing with one year ago

Post by dazza1223 »

hey mate thank you for that demo it made it more easier :D to work out i took what u said go to "https://www.w3schools.com/html/default.asp

ive leaned a lote to night bye watching video and reading so thank u for puting me on the right tracks
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Comparing with one year ago

Post by sfws »

It was a decade ago, after leaving paid work, while acting as a full time carer for my late mum that I first taught myself HTML to pass the time between carer duties. Looking back, it was a miserable time coping with her terminal illness, but I did feel better for learning that skill and I have found it a useful way of keeping my brain working in my retirement.

I am glad I have inspired you to follow your own learning path.
User avatar
dazza1223
Posts: 860
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: Comparing with one year ago

Post by dazza1223 »

im sor sorry to here about when u hade to go through with your mum :cry: um i leaning html more better but i ive tryed to do

some mode off the code u gave me

<td class="table_two"><?=$required_fields[4];?>&nbsp;<#tempunit></td>
<td class="table_two">at&nbsp;<?=$required_fields[5];?></td>
</tr>

im trying to put all this code so it look very tidy but for the hell can i do it so do u mind place the code in the line above plz

<?php
echo "$required_fields[17]";
?> <#windunit>(
<?php
$return = calculateBeaufort($required_fields[17],'<#windunit>');
echo "$return";
?>)</td>
<td>at&nbsp;
<?php
echo (calculateTime($required_fields[18]));
?> </td>
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Comparing with one year ago

Post by sfws »

The shorter format is only available if the only instruction within the PHP script section within the HTMl is an echo.
This bit of php

Code: Select all

<?php
$return = calculateBeaufort($required_fields[17],'<#windunit>');
echo "$return";
?>
has an instruction that is not an echo followed by an echo.
To express it just as an echo (and therefore use the shorter <?= format), it would need to be expressed differently as just an output

Code: Select all

<?=calculateBeaufort($required_fields[17],'<#windunit>');?>
The alternative is to separate the two PHP instructions out:
Type the call to the function (that can be placed anywhere provide the returned string is defined before it is used, therefore the php snippet

Code: Select all

<?php
$return = calculateBeaufort($required_fields[17],'<#windunit>');
?>
is placed before the HTML table (i.e. before <table>) and that leaves just the echo (that has to be placed where it is to appear) to put

Code: Select all

<td class="table_two"><?= $required_fields[17] . ' <#windunit>(' .  $return;?>)</td>
within the table cell within the table.
Last edited by sfws on Tue 11 Feb 2020 8:09 am, edited 1 time in total.
User avatar
dazza1223
Posts: 860
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: Comparing with one year ago

Post by dazza1223 »

yep that did the trick thank you

http://www.davisworthing.co.uk/new/tod_yes_yerar.php

take a look if u see any error can u pont them out as ive been on the for 6 hr trying to sort it and i must say ur very good with php


ps i wood like to remove this lin as it taking up to much room (F3=Gentle breeze)
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Comparing with one year ago

Post by sfws »

dazza1223 wrote:take a look, if u can see any errors can u point them out
The "Temperature Average" line has used syntax for time-stamp instead of syntax for value cell - remove "at&nbsp;" before figure, add units after figure (copy "Temperature Range" row).
Otherwise looks good.
dazza1223 wrote: (F3=Gentle breeze) is taking up to much room
In the
function calculateBeaufort(
area change the following line:

Code: Select all

$beaufort='F' . ($i2 - 1) . '=' . $speedArray[$i2-1][4];
into

Code: Select all

$beaufort='F' . ($i2 - 1);
User avatar
dazza1223
Posts: 860
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: Comparing with one year ago

Post by dazza1223 »

:bash: doh sorry I ment just remove Gentle breeze and leve the f3 all the same thank u for all the help u gave me


Ps have u got a website?
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Comparing with one year ago

Post by sfws »

dazza1223 wrote:I meant just remove Gentle breeze and leave the f3 ...


Ps have u got a website?
I understood fully what you meant, and provided code change to do exactly that in my last reply. You will see earlier in this thread some discussion about the shorter or longer format of exactly that part of the display.

I can see I did write the script with the option of either display, but I simplified the final PHP script version I posted to make it friendlier. I selected to provide the longer display as most users understand enough PHP to take something out (the bit removed in my previous reply), but those users may not know how to add extra.


My server is local, not shared online, as I am using a very tempermental windows 10 PC that constantly fails now. Plus, as I have posted many times before, I accept the dubious quality of my weather station and consequently statistics produced are often rubbish. The only use of my weather station is to produce something that varies in its content, that I can try my different scripts on.
User avatar
dazza1223
Posts: 860
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: Comparing with one year ago

Post by dazza1223 »

o i see ok i will have a bach at it to night thanks and u saying ( scripts) how meny have you made as i will like some more off them it u got any :D
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Comparing with one year ago

Post by sfws »

I have not looked again at the code that I shared in this topic, but on my own private web server I still have a PHP script based on what was in this topic.
Without re-reading all my posts, I recall commenting that finding the right day's statistics to display (whether taken by JavaScript from dayfile.txt or by a PHP script from a daily summary database table) was made more complex by coping with both missing past data and the existance in some years of leap days.

The recent leap day proved my 2nd point:

Code: Select all

<?php
	#================================================
	# Work out date for one year ago - there is a leap year problem
	# I want last day of February compared with last day of that month in previous year
	# My test below showed that PHP subtract one year does not work like that
	$leap_day = new DateTime('2020-02-29');
	$leap_day ->	sub(new DateInterval('P1Y')); // subtract 1 year
	$test_day = $leap_day	-> format('Y-m-d'); // ISO format for output of yyyy-mm-dd
	echo "one year before leap day is $test_day";
	// returns "one year before leap day is 2019-03-01"
	# this is not what I want
	#================================================
	$working_date 	= new DateTime($previousDay);
		$working_date	->	sub(new DateInterval('P1Y')); // subtract 1 year
		$aYearAgo		= $working_date	-> format('Y-m-d'); // ISO format for output of yyyy-mm-dd
		if(substr($previousDay,5,2) == '29')
		{
			$aYearAgo	=  substr($aYearAgo, 0, 4) . substr($previousDay,0,7). '28';# compensate if this year is leap year, because was set to 1 March
		}elseif( checkdate ( substr($aYearAgo,5,2), '29', substr($aYearAgo, 0, 4)) && substr($aYearAgo,5,2) == '02' && substr($previousDay,8,2) == '28')
		{
			$aYearAgo	=  substr($aYearAgo, 0, 4) . substr($previousDay,0,7). '29';# compensate for 28 Feb this year if last year is leap year
		}
Of course having just started weather recording at a new home I only have just over 40 days of statistics (so a year ago does not exist in my database table), however I have recently resurrected the database tables for 2 previous homes and I'm exploring the idea of a "join table" approach to be able to see my old weather information as well as my current statistics.
User avatar
meteo19
Posts: 89
Joined: Tue 03 May 2016 8:13 pm
Weather Station: Davis VP2+/DP1500 SmartHub
Operating System: Microsoft Windows 7 Pro
Location: Ségur-Le-Château, France
Contact:

Re: Comparing with one year ago

Post by meteo19 »

Hello
First bravo and thank you for your very good script that I have been using for several years. I have made some adaptations, I would like to calculate in addition the total rain on this date and a year before but I can't do it can you help me if possible in this script. Thank you very much and sorry for my very bad English. :oops:

Attached is the JS file
searchDayfile.js
Your script in operation
http://www.meteosegur.fr/Base-segur/wxh ... -avant.php
You do not have the required permissions to view the files attached to this post.
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Comparing with one year ago

Post by sfws »

Thank you for using my script, and especially for praising it. I really appreciate that.
meteo19 wrote: Fri 19 Jun 2020 5:00 pm I would like to calculate in addition the total rain on this date and a year before but I can't do it can you help me if possible in this script.
The script uses what is stored in dayfile.txt, and in your copy of my JavaScript is what Cumulus calls the total rain (the amount falling in each day).

Code: Select all

case 14: $('#rain').prepend(parameter_array[i,1]);		break;
So you can use it to see how much rain fell on any other date such as exactly a year ago, as you already do on your site, so I don't understand why you want me to tell you how to do it:

Code: Select all

	Hier ( Jeudi 18 Jun 2020)      Un an avant ( Mardi 18 Jun 2019)
Pluie 	   2,4 mm 	  	                  0,0 mm
Perhaps by total rain you mean something different, total for month to a date in this year and total for a month to that date in previous year (or total for year or season).
If you do, then MX keeps the old month.ini and year.ini log files (renaming them with month and year added to file name), but those only give you total rain in a completed past month or completed past year. The only way in JavaScript to get the rain up to the same date as yesterday is to read that dayfile.txt and look at every day preceding the date a year ago (back to start of month or year) the daily rain totals and sum them.

The easier alternative is to get MX to upload the daily summary log file to a database table. ExportMySQL.exe dayfile does that for past days, and MX (I see you are using latest release) can automatically update the latest day at the start of the next day (see the Cumulus MX article in Wiki to learn more). Writing a SQL query to find almost any statistic you want for a year ago is I believe much easier than writing JavaScript.
User avatar
meteo19
Posts: 89
Joined: Tue 03 May 2016 8:13 pm
Weather Station: Davis VP2+/DP1500 SmartHub
Operating System: Microsoft Windows 7 Pro
Location: Ségur-Le-Château, France
Contact:

Re: Comparing with one year ago

Post by meteo19 »

Good evening
You understood that it was rain until the same date as yesterday. I will try with MySQL. Thanks for your help.
Good evening from France.

Patrick
Post Reply