***closed*** weather34 for WeatherDisplay (clientraw and WDapi)

My AQI is reading “offline”. Is this normal between data updates?


Capture.PNG

The date-time seemed to be in “UTC” for other test-sites. Now it is in local as far as i can see.
Try this script for a few days, I changed only line 93 from gmdate() to date()
As the time difference here in wester Europe between UTC and local is small, this error was not found when testing.

PM or mail me if there are still problems.
Wim

P.S. better version attached at 15:21 UTC


gov_aqi_block.php.zip (3.09 KB)

Thanks, also for the mail.
The array [100] → [109] covers only 1 hour divided in 10 data points.
“total rain of the last hour” = latest data point [100] minus oldest point [109];
w34_livedata.php line 132 is changed from

	$weather["rain_lasthour"]       = convert_precip ($wd[100],$from,$to);

to

	$value                          = (float) $wd[100] - (float) $wd[109];  # 2019-01-14
	$weather["rain_lasthour"]       = convert_precip ($value ,$from,$to);   # 2019-01-14

Wim


w34_livedata.php.zip (5.4 KB)

Hi,

I have had this version up and running for the last few days now, however I can’t seem to get the graphs working. I have set up the WD API and tested with success and I have set up the SQL table and I can see the data arriving every minute, however I can’t seem to generate the graphs. The ‘Today’ graph seems to be populated with some demo data and does not seem to change. Am I missing something?

I can switch the source of the graph data from WU and that works fine.

Is there any ideas what I am doing wrong?

The link to my site is,

http://micklehamweather.com/pwsWD/

Thanks,
Neil

I can not check your settings, so I attach a screenshot. How did you set these two settings?
It works like this:
If all database settings are OK:
WDapi or the stationcron will store 1 record in the database

If charts are set to Database
=> stationcron will store one line in results.csv

In hindsight, it is more logical to let WD-api add the lines to the .csv when it is loading the DB-record.
But that file can grow very rapidly when the upload interval is set to frequently.

Just before and after midnight the two other cron-scripts will add 1 line to year and monh csv files and clean todays data from the database.
The result.csv (= this days data) is then cleared also.

===
As far as I can see, based on the file-contents, you set WDapi to upload to the database, but are not running a cron-job.

Wim

P.S. I added another post below about the sun-block


I do not understand the sun block on your site.
These should be the settings (for Melbourne) in pwsWD/w34_settings1.php. Could you check them?

                   $TZ = "Australia/Melbourne";
                  $lat = (float) "-37.813611";
                  $lon = (float) "144.963056";

I attach the latest version of the script, for easier reference it displays the hours around the 24-hr clock.
You have to add the azimuth script also.
At noon there should be sun, at midnight it should be dark.

Wim


sun_block.php.zip (2.94 KB)

azimuth.php.zip (3.64 KB)

Azimuth/elevation not working in new Sun block here - http://swanston.maui.co.uk/pws/

Yes, stupid me. I wanted to check how the beta-sun script would work in Australia.
I forgot that others could also download that script. Will do it with PM’s from now on.
For the new sun script you need the Niko’s version of the Azimuth/elevation script also, it is attached.
Succes, PM me if you have more problems with this version.
Wim


azimuth.php.zip (3.64 KB)

No worries, sun/azimuth working now! And so is the rain last hour, I think: I’ll check that when we get more rain :slight_smile:

Thanks Wim.

I checked my settings and you were correct I had set WDapi to upload to the database, I have now changed it to ‘stationcron job will the database load’ - however I am still having issues.

I think I understand how it works now, I originally had WDapi to upload to the database and I could see the data coming into my SQL table on 1 minute intervals (but obviously not populating the .csv files). Since I have changed to the cronjob load option, nothing is coming into my SQL table. It seems like the cronjobs in WD are not running. If I manually run the following link, it will work but nothing is happening in WD.

http://micklehamweather.com/pwsWD/w34_cron_stationcron.php

I have checked and double checked the links in WD but I can’t seem to work it out why it won’t work. I have included some of my settings, maybe I have missed something!

Re the sun block on my site, I have checked my settings and they match what you had suggested so again I am not sure what has happened there!

I have attached a copy of what I can currently see.

Thanks again for your help with this.

Neil


Sun Capture.PNG

The WDapi works fine, so you can set that to upload the SQL table.

I agree that it seems the cron-jobs are not running as they should. They run OK when manually started. But they do not appear to be run by WD.
Please check first if there are no spaces or other strange characters before or after the cron links.
If all seems OK on your end, contact Brian Hamilton maybe he can see in the logs what the problem is.

Re the sun block on my site, I have checked my settings and they match what you had suggested so again I am not sure what has happened there! I have attached a copy of what I can currently see. Thanks again for your help with this. Neil
The problem with the sun-block is not something you can see. Only visitors from another timezone see a strange circle. Attached a screenshot hot is looks when I visit your site

Wim


Thanks Wim - all good now, I have it working!

The issue was a leading blank space at the start!! It was hard to spot - but now that I have noticed it, it’s quite obvious…sorry! :oops:

Neil

Hi Neil,

Thank you! I had same problem and could not find it.
Solved!

Brgds,
Oebel

I’m having a problem using wdapi.

It seems to be set correctly, but when I press the test in WD I get “Success: Bad data”. and the database does not get updated.

This is what I get when I manually execute wdapi:

Notice: Undefined variable: file_contents in C:\Abyss Web Server\htdocs\pwsWD\w34_WDapi.php on line 71

Notice: Undefined offset: 2 in C:\Abyss Web Server\htdocs\pwsWD\w34_WDapi.php on line 74

Notice: Undefined offset: 10 in C:\Abyss Web Server\htdocs\pwsWD\w34_WDapi.php on line 75

Notice: Undefined offset: 9 in C:\Abyss Web Server\htdocs\pwsWD\w34_WDapi.php on line 76

Notice: Undefined offset: 39 in C:\Abyss Web Server\htdocs\pwsWD\w34_WDapi.php on line 77

Notice: Undefined offset: 6 in C:\Abyss Web Server\htdocs\pwsWD\w34_WDapi.php on line 78

Notice: Undefined offset: 5 in C:\Abyss Web Server\htdocs\pwsWD\w34_WDapi.php on line 79

Notice: Undefined offset: 41 in C:\Abyss Web Server\htdocs\pwsWD\w34_WDapi.php on line 80

Notice: Undefined offset: 4 in C:\Abyss Web Server\htdocs\pwsWD\w34_WDapi.php on line 81

Notice: Undefined offset: 8 in C:\Abyss Web Server\htdocs\pwsWD\w34_WDapi.php on line 82

Notice: Undefined offset: 7 in C:\Abyss Web Server\htdocs\pwsWD\w34_WDapi.php on line 83
Bad Data:


Capture2.PNG

Step 1: save the uploaded data which is put after the URL by WD in the form URL?d=all_your_data_fields
The first part of the return message “succes” signals that some data (at least 50 characters) was received and is saved as a text-string for later use
2. Then the WDapi checks if a database exits “If not” the script ends.
You have set you will use a database so the settings are read to check if WDapi needs to upload to the database
The database name, password a.s.o. are checked if they are not empty, if empty the script ends without a message.
Then it checks if “WDapi or the cronjob” must upload. If the cronjob should do it => no message and the WDapi script ends.

  1. The WDapi script connects to the database, in your case the connection is OK, otherwise there would have been an error message

  2. The fields for the database are created from the text string
    AND NOW the data is inserted in the database

$result = mysqli_query($conn,"INSERT INTO weatherstation(time, outsideTemp, barometer, raintoday, UV, windgust, windSpeed, radiation, dewpoint, rainrate, direction, date, lightning)
VALUES('$updated', '$temp', '$barometer', '$raintoday', '$uv', '$windgust', '$windspeed', '$solar', '$dewpoint', '$rainrate', '$direction', '$date', '$lightning')");	
if ($result == false) 
     { die ('Bad Data: '. mysqli_connect_error()); }

The only thing which does not works is the insert, probably the credentials for the userid are set to low.
I will read the documentation to find a better clue what is wrong, as the error message displayed is empty, try the attached replacement script
Use PHPADMIN or your cPanel and give this weather34 user all credentials possible.

Check http://wd34.weather-template.com//documentation/WD34-SQL-2019-01.pdf point 2.1: you could try load some data with PHPadmin, just to see if there is an error message.

When you use the WDapi in your browser you get those messages as the fields are not available URL?d=all_your_data_fields


w34_WDapi.php.zip (2.21 KB)

with your new script I now get an error number 1366


Capture.PNG

OK, it was the UV value which was causing the problem.
Please test this version,
Wim


w34_WDapi.php.zip (2.24 KB)

Hi Wim,

Can you tell me what the little temperature below the main temperature is supposed to represent (see attachment)? I assume it some kind of trend, however mine seems to be way off and it has been like this since the start. How is this calculated?

If it helps, here is a link to my site.

http://micklehamweather.com/pwsWD/

Thanks,
Neil


Capture 1.PNG

Compare your site with the demo-site. It should be the temperature trend.
Most of the times it should be between -1 and + 1.
The script compares “current temp” with “temp 15 minutes” ago.
But you WD file as uploaded contains 2 extra spaces.
All fields after these two spaces are misaligned and current temp is now compared to lowest dewpoint today.

Please update to the latest WD release as this is an old problem.
Or use clientraw.txt for your data.

Why do I always ask for the link to the site?
To check a lot of values with this script: http://micklehamweather.com/pwsWD/w34_module_test.php
One can check the calculated “Live data values” or the WDapi values with the field-names.
All the uploaded files, as long as they are in the default folders, can also be inspected this way.
And any individual script can be run with error-reporting on.
Wim

Thanks again Wim - I have updated to the latest version of WD and it is working fine.

Neil