Page 1 of 3
UV and Ozone
Posted: Wed 21 Oct 2015 8:47 am
by gluepack
As I don't have a UV sensor, so get no data via Cumulus, I didn't bother with the UV gauge. However, as I get a UV forecast through temis.nl anyway, I decided to use that. What I hadn't realised was that the output from them includes an ozone column value for the same coordinates, so I modified the solar radiation gauge code (as I don't have that either) to display that value too.
http://www.jerbils.info/saratoga/wxgauges.php
uvdu04.jpg
Re: UV and Ozone
Posted: Wed 21 Oct 2015 10:21 am
by water01
Very good, I presume you will not mind if I steal the code?

Re: UV and Ozone
Posted: Wed 21 Oct 2015 10:53 am
by gluepack
If you can find it, lol!
Actually, I have a slight problem as I modified the uv forecast php to echo json_encode the two values to make them available to the js code.
Now that I have replaced the code with the test code, those two values get displayed on the home page above the ajax console as it also uses the uv forecast php.
Err... any idea how I stop that?
Re: UV and Ozone
Posted: Wed 21 Oct 2015 11:12 am
by laulau
Maybe this :
Code: Select all
ob_start();
require_once "curconditions.php" ;
ob_end_clean();
Re: UV and Ozone
Posted: Wed 21 Oct 2015 11:13 am
by water01
Call the UV code in the gauges code instead of in the main index page would be the way I would do it and was planning to, and then populate the variable there rather than trying to carry it over from the index page.
Not sure about laulau's solution as I am not familiar with what curconditions.php contains as I assume it is a Saratoga script?
Re: UV and Ozone
Posted: Wed 21 Oct 2015 11:25 am
by gluepack
Struggling to google alternatives but I think that laulau's solution, based on what I have read, will not only get rid of echos but prints as well.
"Call the UV code in the gauges code instead of in the main index page"... not sure what you mean by that. The problem is that it gets called by both ajax-dashboard and wxgauges. I'll look at calling it from the gauges.js instead. However, it is straining my knowledge re client/server.
Easiest thing is to do what I did in testing, have two copies of the uv retrieval code, lol!.
Re: UV and Ozone
Posted: Wed 21 Oct 2015 12:08 pm
by water01
gluepack wrote:
"Call the UV code in the gauges code instead of in the main index page"... not sure what you mean by that.
What I meant was that the results are retrieved from temis.nl by using get-UV-forecast-inc.php which sets up the URL, gets the data and sets up the arrays, so I would include that in my gauges page this setting up the right variables.
Re: UV and Ozone
Posted: Wed 21 Oct 2015 12:20 pm
by gluepack
Umm.. that is what I am doing but I have modified it so that it echos back the uv/du values for gauges.js to use. Unfortunately, as the ajax-dashboard calls the same php, the echo'd variables get displayed above the dashboard.
Temporarily, I have reverted back to using two copies of get-UV-forecast-inc.php, one that echos back and one that doesn't, until I can find a better solution.
Re: UV and Ozone
Posted: Wed 21 Oct 2015 5:47 pm
by water01
OK I have got mine going.
http://www.dmjsystems.co.uk/weather/gauges-ss.php
No problem with variables used
Code: Select all
$UVfcstUVTODAY = $UVfcstUVI[0];
$UVfcstOZONE = $UVfcstOZN[0];
echo '<script>';
echo 'var UVfcstUVTODAY = ' . json_encode($UVfcstUVTODAY) . ';';
echo 'var UVfcstOZONE = ' . json_encode($UVfcstOZONE) . ';';
echo '</script>';
to pass the new variables from PHP to jscript.
Re: UV and Ozone
Posted: Wed 21 Oct 2015 7:04 pm
by gluepack
Lol, there are no problems with my variables but you don't understand. I have an ajax console on my home page that calls the same php and the echos are displayed on it. Meanwhile, until I can figure it out, I'll live with two versions of the php.
By the way, if you are going to display my images, you might want to change your css file to size them correctly. I used different tipimg params to do that

Re: UV and Ozone
Posted: Wed 21 Oct 2015 7:54 pm
by water01
Just fixed that thank you. Took me a while to figure that one out as it was a combination of the css and the js

Re: UV and Ozone
Posted: Thu 22 Oct 2015 8:16 am
by gluepack
I should have scrolled down at sometime I guess. The additional gauges css has screwed up the placement of the trailing information on that page. Now I have to figure out how to resolve that.
Update: well, having failed to find anything about saving css and reverting back to it, I just wrapped the included footer with a second main-copy div with a style size and that seems to have worked. For someone who much prefers definitives, I do seem to end up with a lot of scrappy workarounds. I guess that is the nature of dealing with css, html, javascript and php when you are not an expert in any of them. How I miss the days of fifty years ago when you could turn to the person next to you with a question about coding and get an immediate straight answer.
Re: UV and Ozone
Posted: Fri 30 Oct 2015 12:48 pm
by gluepack
I noticed that someone else had added labels underneath their gauges. I had wanted to do this myself but was concerned that I would have to modify the js to do it. As it turns out, it was just a matter of adding a new div for each gauge (with a style override for one gauge to line up the label) in the calling saratoga template.
Code: Select all
<div class="gauge">
…
<div class="gauge-label">Temperature</div>
</div>
Well, plus an update to the css file and an appropriate base image.
Code: Select all
.gauge-label {
background-image: url(label.jpg);
background-repeat: no-repeat;
font-family: Verdana, Helvetica, sans-serif;
color: #022B40;
height: 25px;
width: 125px;
font-size: 15px;
padding-top: 2px;
margin-top: 6px;
margin-right: auto;
margin-left: auto;
text-align: center;
}
http://jerbils.info/saratoga/wxgauges.php thanks to Sun Prairie Weather.
Re: UV and Ozone
Posted: Sat 31 Oct 2015 3:03 pm
by ace2
Can this be used with HTM instead of PHP for my area and if so, what would i need to change??
Re: UV and Ozone
Posted: Sat 31 Oct 2015 3:18 pm
by water01
If you mean the SteelSeries gauges, yes they can no problem. See here
https://cumulus.hosiene.co.uk/viewtopic.php?f=21&t=7186
The Ozone and UV gauges are using the data obtained by using the uvforecast.php code obtainable here
http://saratoga-weather.org/scripts-UVforecast.php which has instructions on how to incorporate into your page.