Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.0.0 (build 4022) - 11 May 2024

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

Legacy Cumulus 1 release 1.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

PHP script to display monthly/yearly snow depth totals from diary.db

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

Moderator: daj

surban21
Posts: 29
Joined: Wed 07 Dec 2016 1:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 10

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by surban21 »

@PaulMy

I think I found the issue.

At the top of snowSumData.php for $myDbase enter the following if this the directory you're wanting to use:
$myDbase = 'sqlite:\KomokaWeather\CumulusMX\data\diary.db'; // <-- enter directory where diary.db located. DO NOT remove sqlite:
Then at the bottom of the same php file look for:
/* Writes the arrays to a text file to be called later from snowSummary.php Put this back when done testing
and for "file_put_contents" enter the direct path such as;
'C:\KomokaWeather\CumulusMX\webMX\snowSumDataT.txt'
This should get you running as it seemed to work for me. Good luck and let me know.
User avatar
PaulMy
Posts: 3873
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by PaulMy »

Hi Steve,
Unfortunately after several hours not getting anywhere. I have tried it in two separate instances of CMX and just can't get it to produce a snowSumData.txt file. If have tried numerous differences in the snowSumData.php settings lines 31 and 157 to see if I could find the correct one but no luck. MXdiags says it is processing program, and have used php-win.exe and php.exe but the same result. I have checked the CumulusMX\data folder Properties and it has Read only ticked. When I change that and Save the next time looking at it it is again ticked Read only.

I tried to run it from Run as C:\Programs-Added\PHP\php-8.2.1-nts-Win32-vs16-x64\php.exe C:\KomokaWeather\CumulusMX\webMX\snowSumData.php
and it just flashes to a DOS screen without any info.

Also tried it from the DOS cmd (I really don't know how it all works, but just tried to follow similar to the Run for HansR Cumulusutils) and that shows:

Code: Select all

C:\>Programs-Added\PHP\php-8.2.1-nts-Win32-vs16-x64\php.exe C:\KomokaWeather\CumulusMX\webMX\snowSumData.php

Fatal error: Uncaught PDOException: could not find driver in C:\KomokaWeather\CumulusMX\webMX\snowSumData.php:39
Stack trace:
#0 C:\KomokaWeather\CumulusMX\webMX\snowSumData.php(39): PDO->__construct('sqlite:\\KomokaW...')
#1 {main}
  thrown in C:\KomokaWeather\CumulusMX\webMX\snowSumData.php on line 39
and

Code: Select all

C:\>Programs-Added\PHP\php-8.2.1-nts-Win32-vs16-x64\php.exe C:\KomokaWeather\CumulusMXwll\webMX\snowSumData.php

Fatal error: Uncaught PDOException: could not find driver in C:\KomokaWeather\CumulusMXwll\webMX\snowSumData.php:39
Stack trace:
#0 C:\KomokaWeather\CumulusMXwll\webMX\snowSumData.php(39): PDO->__construct('sqlite:KomokaWe...')
#1 {main}
  thrown in C:\KomokaWeather\CumulusMXwll\webMX\snowSumData.php on line 39

C:\>
Line 39 in snowSumData.php is

Code: Select all

$pdo = new PDO($myDbase);
So presumably it can't find the \CumulusMX or \CumulusMXwll\data\diary.db but beyond me to fully understand and how to fix it :oops:

Any further thoughts, or suggestions to try?

Enjoy,
Paul
VP2+
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
Image
surban21
Posts: 29
Joined: Wed 07 Dec 2016 1:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 10

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by surban21 »

@PaulMy

Out of curiosity check the php.ini file in the PHP folder that you installed. Inside the php.ini, do a search for sqlite and look for (extension=pdo_sqlite) and (extension=sqlite3). If either of these have a semi-colon (;) in front of them, remove only the semi-colons and save the ini file. This potentially could be the problem regarding the driver error. I seem to remember I had to remove these semi-colons.

Then continue with setting up my files per instructions like you have been doing.

Thanks for continuing to get my file to work. :D

Steve
User avatar
PaulMy
Posts: 3873
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by PaulMy »

Thanks Steve,
Both had the semi-colon and I have removed them.
A step further but not yet there. This now the response in the CMD screen.

Code: Select all

C:\>C:\>Programs-Added\PHP\php-8.2.1-nts-Win32-vs16-x64\php.exe C:\KomokaWeather\CumulusMX\webMX\snowSumData.php
The process cannot access the file because it is being used by another process.
C:\>
I don't know which files it is referring to but have stopped both CMXs so that neither the External Programs nor CMX is accessing the \data or WebMX folders, and still the same message.

Enjoy,
Paul
VP2+
C1 www.komokaweather.com/komokaweather-ca
MX https://komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX https://komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX https:// komokaweather.com/cumulusmx4/index.htm
Image
User avatar
Dador
Posts: 226
Joined: Thu 24 Nov 2011 2:22 pm
Weather Station: Davis VP2 Plus & Ecowitt
Operating System: Windows 10
Location: Rybnik, Poland
Contact:

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by Dador »

Steve,

if I only check "Snow Falling" in the weather log, should one day be added in "Snow Events"?

Yesterday I had a snowfall, but no permanent snow cover. I marked it in my dairy, wrote it down. However, the script at the end of the day did not summarize the event.
surban21
Posts: 29
Joined: Wed 07 Dec 2016 1:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 10

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by surban21 »

@Dador,

As of the way I understand diary.db, because of the way diary.db overwrites the snowDepth value if you enter a value more than once in a day, it will overwrite the previous value. For example, if this morning you enter 7.5 in the snow depth box inside the CMX weather diary editor and later that day you entered 2.5, it won't add it to the 7.5 already entered. Instead, it will replace the 7.5 with 2.5 for that day. Also diary.db only accepts number values in the snow depth entry in the weather diary editor.

All this to say, one must decide what they want to record for consistency. Either record snowfall only OR snow laying only. I found that using either of the snow falling or snow laying check boxes in the weather editor was of little use at this time and I did not incorporate them into my scripts. However, your question has given me an idea on how to possibly record non-measurable snow events as trace "T" and count it in the snow event days in my script. I will try utilizing the snow falling check box in the weather diary editor to be my trigger for a non-measurable snow event so that it would be counted as a snow event in my scripts.

As I mentioned on my first post, I'm unfortunately not a programmer and I'm figuring this stuff out as I go along. I've learned a lot by doing these scripts BUT I have so much more to learn and figure out how I can do things.

Now to directly answer your question, as of now my scripts are only able to count measurable snowfall as snow event days.

Thanks for your input Dador,
Steve
User avatar
Dador
Posts: 226
Joined: Thu 24 Nov 2011 2:22 pm
Weather Station: Davis VP2 Plus & Ecowitt
Operating System: Windows 10
Location: Rybnik, Poland
Contact:

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by Dador »

Ok,
I'm glad you want to develop your script. I'll be following this thread and waiting for updates.

Good luck.

PS. If you plan to update the script quite often, you might want to consider extracting the translation file so that you don't have to enter it every time?
surban21
Posts: 29
Joined: Wed 07 Dec 2016 1:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 10

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by surban21 »

Updated to ver 0.6

Now allows trace "T" snow recording. If no measurable snowfall for the day but it snowed then ONLY tick the Snow Falling checkbox in CMX and save. This will record the day as a snow event and will place a "T" in that month column unless or until there is measurable snowfall for that month. The snow event day tally will not be affected.

The download zip file is on the first page of this thread if you're interested.
User avatar
Dador
Posts: 226
Joined: Thu 24 Nov 2011 2:22 pm
Weather Station: Davis VP2 Plus & Ecowitt
Operating System: Windows 10
Location: Rybnik, Poland
Contact:

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by Dador »

Everything works well. :clap:
surban21
Posts: 29
Joined: Wed 07 Dec 2016 1:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 10

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by surban21 »

Now updated to ver 0.7 - 01-24-2023

New- added one decimal place after integer type numbers displaying snow depth values. ie; 3 now becomes 3.0
New- ability to set date format in user defined area inside snowSumData.php
New- ability to set decimal type (comma or period) in user defined area of snowSumData.php
Fixed- snowSumData.php sql's lastSnow and firstSnow in northern hemisphere to read concatenated years properly.

The zip file can be downloaded from the first post on this thread. Thanks
User avatar
Dador
Posts: 226
Joined: Thu 24 Nov 2011 2:22 pm
Weather Station: Davis VP2 Plus & Ecowitt
Operating System: Windows 10
Location: Rybnik, Poland
Contact:

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by Dador »

Hi Steve,

what do you think about this idea?
You do not have the required permissions to view the files attached to this post.
surban21
Posts: 29
Joined: Wed 07 Dec 2016 1:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 10

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by surban21 »

Daniel,

I've already been tossing this around. Good call :D I'll play around with it and see about incorporating this.

Steve
surban21
Posts: 29
Joined: Wed 07 Dec 2016 1:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 10

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by surban21 »

Updated to ver 0.8 - 01-28-2023


ver 0.8
New- added totals in the html table, "Snowfall Depths each Month Summed Over All Years"
Fixed- problem when entering data on 31st of month putting value in following month. Fixed in sql query in snowSumData.php.

The zip file can be downloaded from the first post on this thread
surban21
Posts: 29
Joined: Wed 07 Dec 2016 1:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 10

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by surban21 »

Updated to ver 0.9 - 02-24-2023

ver 0.9
  • New- re-wrote large portion of the code to incorporate using the SnowLying check box in CMX to count the amount of days that snow is on the ground. ie; snowpack or ground cover.
  • New- modified the table row highlighter to work properly due to now having a rowspan of 3 for each year
  • Advisory- For those that have already installed my previous scripts, you will need to install all version 0.9 scripts except for snowSumData.txt. You will not loose any data.
The zip file can be downloaded from the first post on this thread
User avatar
Dador
Posts: 226
Joined: Thu 24 Nov 2011 2:22 pm
Weather Station: Davis VP2 Plus & Ecowitt
Operating System: Windows 10
Location: Rybnik, Poland
Contact:

Re: PHP script to display monthly/yearly snow depth totals from diary.db

Post by Dador »

Hi Steve,

I see you've put some effort into writing the code. Lots of changes, but for the better. It's clearer now. Good job. :D
Post Reply