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 - More logistics for me to think about. I guess the simple solution would be to install just the php program and reference that directory. For example where I have C:\xamp\php\php-win.exe, you'd likely put C:\php\php-win.exe. However, as I have just recently discovered CumulusMX only allows one program to be placed in each of the external program slots. I haven't tried this, but I suppose a way around that would be to make one .bat file to run php and the parameter for my file along with CUtils and its parameter then put the .bat file in CumulusMX external program to run. BUT that makes things a bit more complicated. I see now where it would be nice to have CMX be able to run more than one external program with its parameters. Unless I'm missing something. Still I wouldn't use anything other than CMX for my weather recording.

Thanks for giving it a go Paul. I'll have to rethink this but not so sure I can implement mine any differently as I need to parse snowSumData.php to grab the data from the db and do the other things needed.

Regards,
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 »

Hi,
Anything I can test for you, just let me know.

If I am able to get it working I'd see about adding the data from my Cumulus1 Log (going back to 2008) into CumulusMX diary which started in Dec 2019.

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 »

I just might take you up on that @PaulMy. I'll continue to do some code cleaning but in the meantime here's hoping to a pain free install.Thank you.

Regards,
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.5 - Cleaned up some of the code in snowSummary.php making it easier reading and a bit more efficient. Same features as ver 0.4. If interested the zip file can be downloaded from the first post. Thanks
User avatar
Dador
Posts: 225
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 »

I downloaded and installed the script according to the instructions. Everything seems to be working:

https://cmx.pogodarybnik.pl/snow/snowSummary.php

However, I'm having trouble getting it to work in a CMX page template. The script doesn't work with the include function. I do not know why. I have several different scripts, but only this one doesn't work properly for me.

https://cmx.pogodarybnik.pl/snieg.htm
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 »

However, I'm having trouble getting it to work in a CMX page template. The script doesn't work with the include function. I do not know why. I have several different scripts, but only this one doesn't work properly for me.
@Dador - I haven't really run this using the CMX supplied webfiles as I use Silver Acorns MXUI Template v 2.2.5. However, I believe if you rename snieg.htm to snieg.php and include the snowSummary.php file where you need it inside your template it should work with some minor tweaking needed. The include should look something like this <?php include_once("./snowSummary.php"); ?>

Change your menu to call snieg.php instead of snieg.htm.

Good luck and thanks,
Steve
User avatar
Dador
Posts: 225
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 »

surban21 wrote: Sun 15 Jan 2023 4:21 pm @Dador - I haven't really run this using the CMX supplied webfiles as I use Silver Acorns MXUI Template v 2.2.5. However, I believe if you rename snieg.htm to snieg.php and include the snowSummary.php file where you need it inside your template it should work with some minor tweaking needed. The include should look something like this <?php include_once("./snowSummary.php"); ?>

Change your menu to call snieg.php instead of snieg.htm.

Good luck and thanks,
Steve
Due to the fact that I have the entire CMX template in htm, I forgot about php. :bash:

Thanks for the hint, now everything works. ;)

Sometimes the simplest solutions are the hardest to come up with.
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 »

Glad you have it working @Dador! BTW - there was a minor glitch in snowSummary.php where the days snowfall over amounts ie; >=1 and < 3 section is actually for inches. I have fixed this and it is in the zip file on the first page. You only need to grab the snowSummary.php file and replace it with the one you already have. If you want since you have done some modifications just go to the section in the snowSummary.php that you already have and go to the section commented as "# Displays Total Number of Days with Snowfall Amounts for each Month Summed Over All Years" change the code as below:

All ($hemi == 'N') to ($unit == 'in') and all ($hemi == 'S') to ($unit == 'cm')

OR - what you are doing works too. LOL :D


Thanks
Steve
User avatar
Dador
Posts: 225
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 »

surban21 wrote: Sun 15 Jan 2023 4:56 pm
OR - what you are doing works too. LOL :D
Yes, I decided to copy some of the code and add my ranges. As you can see, I also translated everything into Polish.
I'll have a snowfall in a couple of days and see how that works out as I complete the weather diary.

Looks good, doesn't it? :D

As you can see your script works. :clap:
Add a footer with the author, that is with you.
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,
Still looking how I can run this script.
From the How to:
After deciding which one you're going to use enter the path and filename to your php executable file. ie; c:\xampp\php\php-win.exe. Inside the php folder there is usually a php.exe and a php-win.exe. php-win.exe will run silently whereas php.exe will briefly display a command window each time it is run. (alternatively, if the php path is included in your operating system variables path then you only need to enter php or php-win and not the entire path).
What do I need to download/install for that xampp\php\php-win.exe to be added to my PC so I can run it in External Programs? Or is there another way?

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: 225
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 »

Paul,
take a look at it.

Settings -> Internet settings -> External Programs.

The script is executed once a day. And it works :)
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 »

@PaulMy
I guess the simple solution would be to install just the php program and reference that directory. For example where I have C:\xamp\php\php-win.exe, you'd likely put C:\php\php-win.exe.
You can grab php at https://windows.php.net/download#php-8.2 and chose the appropriate install. I recommend the "Thread Safe" version.

As far as I know snowSummary.php must be processed on your local computer so it can grab your diary.db info. That's where the php program comes in.

Regards,
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,
That is exactly what I needed. I have downloaded the program and have it set to run, and MXdiags indicate it does,

Code: Select all

2023-01-17 17:05:01.770 Interval: Processing extra file[14] - C:\KomokaWeather\CumulusMXwll\web-additions\ecowitt-extrasensorsT.txt
2023-01-17 17:05:01.773 Interval: Processing extra file[15] - C:\KomokaWeather\CumulusMXwll\webMX\snowSumDataT.txt
2023-01-17 17:05:01.774 Interval: Executing program C:\Programs-Added\PHP\php-8.2.1-nts-Win32-vs16-x64\php-win.exe C:\KomokaWeather\CumulusMXwll\webMX\snowSumData.php
2023-01-17 17:05:01.779 Interval: External program started
CMX is updating snowSumData.txt to my remote but it is empty http://www.komokaweather.com/cumulusmxw ... umData.txt
The cumulusmx.db is in the usual \CumulusMXwll\data folder and I add to it every day.
Nothing else in MXdiags that I can detect.

Any thoughts?

Enjoy,
Paul
You do not have the required permissions to view the files attached to this post.
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
The cumulusmx.db is in the usual \CumulusMXwll\data folder and I add to it every day
Is this cumulusmx.db just the diary.db renamed? Does your db have the same data table/structure as diary db? If both of these are true then maybe some adjustment is needed in snowSumData.php in the user settings area at the top. Take a look at the database line "$myDbase = 'sqlite:\CumulusMX\data\diary.db';" and see if adjustments are necessary. In your screenshots your entries appear correct.

It appears to me there is no connection to your db. Also grab the updated snowSummary.php version from the zip file as there was a minor glitch in the way cm was called. This was the only file in the zip that was updated. Just copy it to your remote server directory and overwrite the existing one.

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 »

Hi Steve,
That was my error in mentioning cumulusmx.db, The diary is in C:\KomokaWeather\CumulusMX\data\diary.db.

I have updated all the files from v_0_5. I have been trying but not successful as yet. One CMX that I have been trying is C:\KomokaWeather\CumulusMX which uploads to website www.komokaweather.com/cumulusmx. The CMX External Program - Interval has

Code: Select all

C:\KomokaWeather\CumulusMX\webMX\snowSumData.php
the default downloaded \webMX\snowSumData.php file had:

Code: Select all

$myDbase = 'sqlite:\CumulusMX\data\diary.db'; // <-- enter directory where diary.db located. DO NOT remove sqlite:
After an Interval run there was no new snowSumData.txt created in \webMX\, only the copied-in empty snowSumDataT.txt and snowSumData.php
MXdiags shows:

Code: Select all

2023-01-18 10:20:02.060 Interval: Executing program C:\Programs-Added\PHP\php-8.2.1-nts-Win32-vs16-x64\php-win.exe C:\KomokaWeather\CumulusMX\webMX\snowSumData.php

I then edited the \webMX\snowSumData.php by adding KomokaWeather\:

Code: Select all

$myDbase = 'sqlite:\KomokaWeather\CumulusMX\data\diary.db'; // <-- enter directory where diary.db located. DO NOT remove sqlite:
After the next Interval run again no new snowSumData.txt created in \webMX.
The MXdiags shows:

Code: Select all

2023-01-18 10:25:01.692 Interval: Executing program C:\Programs-Added\PHP\php-8.2.1-nts-Win32-vs16-x64\php-win.exe C:\KomokaWeather\CumulusMX\webMX\snowSumData.php
I have also tried other edits in the snowSumData.php like:

Code: Select all

$myDbase = 'sqlite:C:\KomokaWeather\CumulusMX\data\diary.db'; ...
And after the next interval Run the same result, no new snowSumData.txt created.

Maybe I've overlooked the obvious but have double/triple checked.

Is it possible that my install of CMX in C:\KomokaWeather\CumulusMX is the issue?
I have not found any other logging of the External Program activity so can't determine what the issue may be. Is there any setting possible to log the process of the External Program or the script?

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