uvForecastBlock v3.0 and API

Post Reply
User avatar
meteocaldas
Language Admin
Language Admin
Posts: 111
Joined: Fri Aug 25, 2017 7:56 pm
Location: Caldas da Rainha, Portugal
Station model: OS WMR-88A
Software: Cumulus
Contact:

uvForecastBlock v3.0 and API

Post by meteocaldas » Tue Dec 05, 2017 10:38 am

My weather station sends data from Cumulus realtime.txt and MT parses this file.

After instaling the new update (v3.0) for the uvForecast block, I have noticed that it displays "OWN" (what would mean that it is displayng the UV value from my station).
It also shows a zero value all the time, instead of the forecasted darksky value, that should be displayed for stations without UV hardware.

I looked at the script, and I think that the problem is here:

Code: Select all

$apiData = file_get_contents("../../../meteotemplateLive.txt");
	$apiData = json_decode($apiData, true);

	if(array_key_exists("UV", $apiData)){
		$uv = $apiData['UV'];
		echo "own";
	}
	else{
		$fIOURL = "https://api.darksky.net/forecast/".$fIOKey."/".$stationLat.",".$stationLon."?units=si&lang=".$fIOLanguage;
When it reads meteotemplateLive.txt, he finds a "UV":0, value on it (parsed from realtime.txt), so it assumes that I have UV sensor with a current value of zero, and skips the part where it would go parse the darksky forecasted value.

I had already noticed exactly the same problem with the currentBlock where the UV icon also shows up, displaying a permanent zero.
I checked the Meteotemplate setup where there is an option to tell if we have solar sensor (Yes or No), looking if I had missed to select any UV option (Yes or No), but there was no such option.
I only managed to solve the problem after removing the UV part from the currentBlock script.

Most probably the problem is this:
When Cumulus realtime.txt has the field UV=0, it is not possible to determine if this is a realtime UV value, or if it simply means that the station has no UV sensor.
Unfortunatelly, the API is going to read it as a realtime value and assume that the station has UV sensor.
This is the reason why MT is displaying the permanent zero value, both in currentBlock and in uvForecastBlock (and probably in other parts of MT).

Is there any way to solve this problem, other than removing the UV part from the scripts?
(The easiest way seems to be adding a UV Yes or No option in MT config, to complement the solar option it already has)

Image
Last edited by meteocaldas on Tue Dec 05, 2017 11:37 am, edited 1 time in total.

User avatar
Jachym
Site Admin
Site Admin
Posts: 1686
Joined: Fri Aug 18, 2017 10:12 pm
Location: Brno, Czech Republic
Station model: WH1080
Software: Meteobridge
Contact:

Re: uvForecastBlock v3.0 and API

Post by Jachym » Tue Dec 05, 2017 11:36 am

Hi,
the "own" word shouldnt be there, I added it there for testing purposes and then forgot to delete it.

With regards to UV, if the data going to Meteotemplate includes UV then it assumes you have a UV sensor. This again is a problem of Cumulus because the other programs simply dont send UV to the API. To make it easier MT this way is able to determine if you have or do not have UV sensor without you having to specify it all the time.

So if the API receives UV data, it will show the UV sensor and read the values from it

Cumulus should not be showing 0 if you dont have the sensor, rather something like "null" or "-". If it shows 0, then the template automatically assumes it is a real number.

User avatar
Jachym
Site Admin
Site Admin
Posts: 1686
Joined: Fri Aug 18, 2017 10:12 pm
Location: Brno, Czech Republic
Station model: WH1080
Software: Meteobridge
Contact:

Re: uvForecastBlock v3.0 and API

Post by Jachym » Tue Dec 05, 2017 11:47 am

OK I fixed it, the "own" word should be gone

User avatar
meteocaldas
Language Admin
Language Admin
Posts: 111
Joined: Fri Aug 25, 2017 7:56 pm
Location: Caldas da Rainha, Portugal
Station model: OS WMR-88A
Software: Cumulus
Contact:

Re: uvForecastBlock v3.0 and API

Post by meteocaldas » Tue Dec 05, 2017 11:50 am

HI Jachym, thanks for the reply.
I understood that it is a Cumulus problem, but I din't understant if there is other solution for cumulus users, other than delete or change the UV parts in both currentBlock and uvForecast blocks?
How can I have the darksky forecasted value showing in UV block without altering the script?
Cumulus users will always have a zero UV displayed?
Thanks.

Image

User avatar
Jachym
Site Admin
Site Admin
Posts: 1686
Joined: Fri Aug 18, 2017 10:12 pm
Location: Brno, Czech Republic
Station model: WH1080
Software: Meteobridge
Contact:

Re: uvForecastBlock v3.0 and API

Post by Jachym » Tue Dec 05, 2017 11:53 am

OK, I dont know how Cumulus works, but just to make sure, are you saying that if a user has no UV sensor, then cumulus shows 0? It should show something like "-", or nothing (""), or "null", but not 0

User avatar
Jachym
Site Admin
Site Admin
Posts: 1686
Joined: Fri Aug 18, 2017 10:12 pm
Location: Brno, Czech Republic
Station model: WH1080
Software: Meteobridge
Contact:

Re: uvForecastBlock v3.0 and API

Post by Jachym » Tue Dec 05, 2017 12:05 pm

If it is possible to determine difference between UV 0 and "no UV value" in Cumulus then I could implement this in the API for Cumulus. But it must be different, obviously I cannot label UV 0 as "no value" because UV 0 is realistic

User avatar
meteocaldas
Language Admin
Language Admin
Posts: 111
Joined: Fri Aug 25, 2017 7:56 pm
Location: Caldas da Rainha, Portugal
Station model: OS WMR-88A
Software: Cumulus
Contact:

Re: uvForecastBlock v3.0 and API

Post by meteocaldas » Tue Dec 05, 2017 12:16 pm

Jachym wrote: Tue Dec 05, 2017 11:53 am OK, I dont know how Cumulus works, but just to make sure, are you saying that if a user has no UV sensor, then cumulus shows 0? It should show something like "-", or nothing (""), or "null", but not 0
My current realtime.txt is

05/12/17 12:01:40 14.1 52 4.4 11.2 5.4 135 0.0 0.0 1032.0 SE 2 km/h C mb mm 127.2 0.0 0.0 448.6 0.0 14.2 61 13.4 +1.8 14.1 11:58 7.4 00:56 16.9 10:07 22.3 11:18 1033.0 08:11 1031.0 03:11 1.9.4 1099 19.8 14.1 14.1 0 0.00 0 117 0.0 1 1 0 ESE 1211 m 10.7 0.0 412 0

using this wiki to understand all the fields
http://wiki.sandaysoft.com/a/Realtime.txt

So my station that has no UV hardware, is showing "0". It will show "0" to represent No UV sensor or to represent a real time value of zero.
The same goes for solar radiation value.
However since MT has a setup option to select Yes or no for Solar sensor, this is not affecting API and everything is fine with solar values.
That is why I think that the only solution for UV in Cumulus, will be to add a setup UV yes or no option in a future MT version
Last edited by meteocaldas on Tue Dec 05, 2017 12:21 pm, edited 1 time in total.

User avatar
Jachym
Site Admin
Site Admin
Posts: 1686
Joined: Fri Aug 18, 2017 10:12 pm
Location: Brno, Czech Republic
Station model: WH1080
Software: Meteobridge
Contact:

Re: uvForecastBlock v3.0 and API

Post by Jachym » Tue Dec 05, 2017 12:18 pm

Hi,
if Cumulus reports UV as 0 when there is no UV sensor, then Im afraid I have to say it is a very bad software design and not much I can do Paulo. This would have to be fixed by Steve which I seriously doubt he will do given he said he is unlikely to make any further changes to Cumulus. I cannot do anything, sending 0 when there is no UV sensor is incorrect and the problem is on Cumulus part. Other programs dont do this and thats how it should be. I know this is not the answer people with Cumulus wanted to hear, but sadly it is the reality.

User avatar
Jachym
Site Admin
Site Admin
Posts: 1686
Joined: Fri Aug 18, 2017 10:12 pm
Location: Brno, Czech Republic
Station model: WH1080
Software: Meteobridge
Contact:

Re: uvForecastBlock v3.0 and API

Post by Jachym » Tue Dec 05, 2017 12:20 pm

Solar values - yes, you are right, there is a select box for this, however this is only because it has been there right since version 1 of Meteotemplate. Back then there was no API and so this was the only way to tell if the user has or does not have a solar sensor. And there was no UV support at all back then. Then the API allowed detecting this automatically so adding extra boxes is something that would add redundant setting to the already quite long setup. I try to make it as simple as possible for the users so i dont want to add extra parameters when it is unnecessary.

User avatar
meteocaldas
Language Admin
Language Admin
Posts: 111
Joined: Fri Aug 25, 2017 7:56 pm
Location: Caldas da Rainha, Portugal
Station model: OS WMR-88A
Software: Cumulus
Contact:

Re: uvForecastBlock v3.0 and API

Post by meteocaldas » Tue Dec 05, 2017 12:26 pm

Ok, Jachym, I understand, it is really a Cumulus problem, and there is little to do about it, other than customizing the scripts for the UV part :(
Anyway from now on, you are aware of the problem... and I am sure sooner or latter you will come out with a solution... as you always do :)
Thank you so much Jachym.

Image

User avatar
Jachym
Site Admin
Site Admin
Posts: 1686
Joined: Fri Aug 18, 2017 10:12 pm
Location: Brno, Czech Republic
Station model: WH1080
Software: Meteobridge
Contact:

Re: uvForecastBlock v3.0 and API

Post by Jachym » Tue Dec 05, 2017 12:34 pm

Hi Paulo,
Im afraid this time I will have to say I will not come up with a solution. Simply because I cannot. If there is a problem in the design of the software that is sending the data, then I cannot solve it. Sending UV as 0 when there is UV sensor and having no differentiation between "no sensor" and "UV 0" is IMHO serious flaw in the design of realtime.txt. Other programs have this handled correctly. This is why I said in the wiki that unfortunately Cumulus only has "limited support". I implemented it in a way that works, but is not ideal. I did ask Steve about creating an update mechanism similar to WD, Meteobridge, WeatherCar and WeeWx, but he was not interested. Im not blaming him, I understand he has little time for this, but in that case all I can say is use different SW if you want to get the best of Meteotemplate.

User avatar
meteocaldas
Language Admin
Language Admin
Posts: 111
Joined: Fri Aug 25, 2017 7:56 pm
Location: Caldas da Rainha, Portugal
Station model: OS WMR-88A
Software: Cumulus
Contact:

Re: uvForecastBlock v3.0 and API

Post by meteocaldas » Tue Dec 05, 2017 12:43 pm

You are right Jachym, and I will follow your advise!
I am about to buy a new weather station and Cumulus is not going to be amongst the SW options :D
Thanks.

Update: I made a small script change to skip API, and my uvForecast block is now displaying the darksky forecasted current value., instead of the zero value.
If your situation is like mine (using Cumulus without UV HW, but willing to display forecasted UV value), PM me and I will send you the solution for this particular case .


Image

User avatar
Johnny
Developer
Developer
Posts: 313
Joined: Sat Aug 19, 2017 10:16 pm
Location: Watford, Hertfordshire, England
Station model: Davis Vantage Pro2 Plus
Software: Meteobridge
Contact:

Re: uvForecastBlock v3.0 and API

Post by Johnny » Wed Dec 06, 2017 8:44 am

Hi Paulo, can I just point out that the first weather station I bought and used with Cumulus had no UV sensor, so when I set up the station configuration in Cumulus I selected a station from the list that has no UV sensor, in my case this was a 'Fine Offset'

A year or so later I bought a new station which did have the UV sensor, I altered the station settings in Cumulus to 'Fine Offset with UV/Light sensor'. As soon as you do this a new display is added to the main display window showing the solar information (see image below)

So what I'm saying here is should you not be selecting a station from the list in Cumulus that represents your station without a UV sensor and maybe Cumulus might stop reporting that zero.

Just a thought.

Cumulus Station Settings.JPG
Cumulus Station Settings.JPG (28.9 KiB) Viewed 19212 times
Attachments
Cumulus Solar Display.JPG
Cumulus Solar Display.JPG (17.78 KiB) Viewed 19212 times
Image
Davis Vantage Pro2 Plus: http://www.watfordweather.uk

User avatar
meteocaldas
Language Admin
Language Admin
Posts: 111
Joined: Fri Aug 25, 2017 7:56 pm
Location: Caldas da Rainha, Portugal
Station model: OS WMR-88A
Software: Cumulus
Contact:

Re: uvForecastBlock v3.0 and API

Post by meteocaldas » Wed Dec 06, 2017 11:54 am

Johnny wrote: Wed Dec 06, 2017 8:44 am So what I'm saying here is should you not be selecting a station from the list in Cumulus that represents your station without a UV sensor and maybe Cumulus might stop reporting that zero.
Hi Johnny, thank you so much for your hint!
My station is Oregon WMR88 and since it is listed in Cumulus as WMR88/WMR100 I never tried any other station!
Later this afternoon, I will go offline, and test to see how cumulus reacts with other stations, and I will let you know the result :)
Anyway your hint goes far beyond this problem, it just gave me the idea that I can buy a Fine-Offset and keep Cumulus instead of choosing another SW, avoiding all problems due to the change (I am afraid of loosing 3 years of data), and allowing me to keep the current structure of my site that is all based in Cumulus)
Now you gave me someting to think about for the next days (thanks!)... :D
Meanwhile, the uvForecast problem with the "Cumulus zero UV" was solved, for my particular case, just by quoting the API lines in the script, and I am very happy with the final result. (Thanks Jachym!)
Image

Image

User avatar
Johnny
Developer
Developer
Posts: 313
Joined: Sat Aug 19, 2017 10:16 pm
Location: Watford, Hertfordshire, England
Station model: Davis Vantage Pro2 Plus
Software: Meteobridge
Contact:

Re: uvForecastBlock v3.0 and API

Post by Johnny » Wed Dec 06, 2017 1:41 pm

Hi Paulo, let us know how you get on. Just wanted to mention that your home page looks great, I really like the the three colours you're using for min, max and average - really nice touch. I'm guessing these are manual tweaks you've made yourself?

http://www.meteocaldas.com/mtp/indexDesktop.php

I'm definitely going to add some tunes to my site when I have a bit more time - I think this is a great idea. :)
Image
Davis Vantage Pro2 Plus: http://www.watfordweather.uk

User avatar
meteocaldas
Language Admin
Language Admin
Posts: 111
Joined: Fri Aug 25, 2017 7:56 pm
Location: Caldas da Rainha, Portugal
Station model: OS WMR-88A
Software: Cumulus
Contact:

Re: uvForecastBlock v3.0 and API

Post by meteocaldas » Wed Dec 06, 2017 3:31 pm

Johnny wrote: Wed Dec 06, 2017 1:41 pm Hi Paulo, let us know how you get on. Just wanted to mention that your home page looks great, I really like the the three colours you're using for min, max and average - really nice touch. I'm guessing these are manual tweaks you've made yourself?
I'm definitely going to add some tunes to my site when I have a bit more time - I think this is a great idea. :)
Hi Johnny, thaks for the comment about MeteoCaldas site.
Yes it is all made with manual tweeks to suit my own preferences and taste. The 3 colors you like are #ffccaa #aaccff and #aaffcc that are the colors that in my opinion, are perfect to replace red, green and blue, when the background is very dark.
Jachym has created a superb customizable template (Thanks Jachym!), with an huge amount of possible choices of background colors, but he has to rely only on two font colours (white or black) to avoid color nonsenses for the template, and there is no other way to do it better!
However, once you have choosen a background and stay with it, then it is easy to customize font color or sizes even with minimum knowledge of html and php.

By talking about customization, the perfect exemple is my new block, OUTLOOK (added yesterday and still with some unsolved problems, like translation).
This is another example of how fantastic this template is! You think of one special block, work on it... and at the end, you can easily add it to MT!
Image

Image

I have plenty of time for this hobby (and MT is indeed my main hobby!) because I am retired, so please feel free to send me a PM everytime you'll need any hints for your customization, and it will be a pleasure to reply. ;)

Image
http://www.meteocaldas.com/mtp
Last edited by meteocaldas on Thu Dec 07, 2017 12:00 pm, edited 2 times in total.

User avatar
Johnny
Developer
Developer
Posts: 313
Joined: Sat Aug 19, 2017 10:16 pm
Location: Watford, Hertfordshire, England
Station model: Davis Vantage Pro2 Plus
Software: Meteobridge
Contact:

Re: uvForecastBlock v3.0 and API

Post by Johnny » Thu Dec 07, 2017 9:46 am

Thanks Paulo, I'll take you up on that offer in the new year and get back to you.
Image
Davis Vantage Pro2 Plus: http://www.watfordweather.uk

User avatar
Fraggboy
Forecaster
Forecaster
Posts: 193
Joined: Wed Sep 27, 2017 2:45 pm
Location: Sunny California
Station model: Bloomsky II + Storm
Software: Bloomsky
Contact:

Re: uvForecastBlock v3.0 and API

Post by Fraggboy » Thu Dec 07, 2017 4:57 pm

Paulo,

Would you be willing to share your OUTLOOK block source with me? I really love that block! It's clean, sharp, and provides great information!
Image

User avatar
meteocaldas
Language Admin
Language Admin
Posts: 111
Joined: Fri Aug 25, 2017 7:56 pm
Location: Caldas da Rainha, Portugal
Station model: OS WMR-88A
Software: Cumulus
Contact:

Re: uvForecastBlock v3.0 and API

Post by meteocaldas » Thu Dec 07, 2017 11:47 pm

Fraggboy wrote: Thu Dec 07, 2017 4:57 pm Would you be willing to share your OUTLOOK block source with me? I really love that block! It's clean, sharp, and provides great information!
Hi Fraggboy, despite the good look of the block, it is still "under construction", and "testing", because the current script is kind of "messy" as it mixes Wunderground wih darksky data, in such a way that a programmer would laught at me :lol:

Since Meteotemplate is my main hobby, I am just playing around to satisfy my own curiousity in creating a new block and checking how far I can go.
As a matter of fact, my main goal is not to create a personal block. My intention is just to create a good hint, and wait that Jachym will like this idea and will create the outlook block, integrating it in MT ;)
I have already posted this hint in a new topic, here:
http://meteotemplate.com/forum/viewtopi ... 3467#p3467

So my friend, be patient like me... and let's hope than in the next days we will have the great joy of having this block available from MT ;)

User avatar
Fraggboy
Forecaster
Forecaster
Posts: 193
Joined: Wed Sep 27, 2017 2:45 pm
Location: Sunny California
Station model: Bloomsky II + Storm
Software: Bloomsky
Contact:

Re: uvForecastBlock v3.0 and API

Post by Fraggboy » Fri Dec 08, 2017 3:25 pm

I saw your request post and I'm hoping that it's added to the "Block Family".. :)
Image

Post Reply