Welcome to the Cumulus Support forum.

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

Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 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

UV colour depending on the number ie None Low Medium High Very High

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

Moderator: daj

User avatar
dazza1223
Posts: 867
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by dazza1223 »

HansR wrote: Tue 07 Jun 2022 2:16 pm
mcrossley wrote: Tue 07 Jun 2022 2:11 pm
freddie wrote: Tue 07 Jun 2022 2:03 pm Do you need to declare uvword before the first if statement? Sorry, I'm not very au fait with javascript.
Yes it would be best to do that...

Code: Select all

var uv = rawdata[45];
var uvword;
if (uv=="0"){ uvword="None";} else
if (uv=="3"){ uvword="<span ...
All true but I don't think it is the cause of failing.
Maybe @dazza could elaborate on what exactly fails? Does it show anything in the UVone element or does it show erroneous something?
As you compare strings is that truly the content of the rawdata or is it e.g. "0 " with as result the if statements all fail and you get an empty string in the html element. If uncertain add a console.log statement after each if-clause to see something.

Or go to stackoverflow.
Sorry ive just just upload a test page to my site as i was doing all off line....

so if you can take a look you can see now ? and for the output nope nothing and the rawdata is the realtime.txt line 44 but it 45 as it count from 1

https://www.davisworthing.co.uk/test.php
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by mcrossley »

or JavaScript is fun and fluid and lets you get away with all sorts of stuff. TypeScript - boo! :lol:
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by mcrossley »

Dazza, I do not see any content on your test page, but wow! That is some refresh rate - every 20 milliseconds!

You problem now is the UV value you are comparing against seems to be the UVI * 100. The value currently is 160, so that falls through to your last clause where uvword=""
User avatar
HansR
Posts: 5963
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bookworm
Location: Wagenborgen (NL)
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by HansR »

mcrossley wrote: Tue 07 Jun 2022 3:05 pm or JavaScript is fun and fluid and lets you get away with all sorts of stuff. TypeScript - boo! :lol:
:lol: That's why it is so popular. I am a fan!
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
User avatar
dazza1223
Posts: 867
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by dazza1223 »

mcrossley wrote: Tue 07 Jun 2022 3:09 pm Dazza, I do not see any content on your test page, but wow! That is some refresh rate - every 20 milliseconds!

You problem now is the UV value you are comparing against seems to be the UVI * 100. The value currently is 160, so that falls through to your last clause where uvword=""
woops yh just spotted that 20 milliseconds :bash:

and the UV in the realtime.txt reads like 1.5

so maybe like this

if (uv=="1.5"){ uvword="<span style=\"border: solid 1px; color: black; background-color: #A4CE6a;\">&nbsp;Low&nbsp;</span>";} else
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
User avatar
HansR
Posts: 5963
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: GW1100 (WS80/WH40)
Operating System: Raspberry OS/Bookworm
Location: Wagenborgen (NL)
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by HansR »

freddie wrote: Tue 07 Jun 2022 2:32 pm :lol: that's why I only touch it when necessary
To the point image
Hans

https://meteo-wagenborgen.nl
CMX build 4017+ ● RPi 3B+ ● Raspbian Linux 6.1.21-v7+ armv7l ● dotnet 8.0.3
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by mcrossley »

Your script is reading field 45 for the UV, that is the Solar Rad value, UV is in field 43.
User avatar
dazza1223
Posts: 867
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by dazza1223 »

im going bye this

https://cumuluswiki.org/a/Realtime.txt

44 13 UV Index <#UV>


but ive have tried 43/44 but it doesn't seem to work
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by mcrossley »

The Wiki uses 1 relative field field numbers, your code uses 0 relative, it should be 43.

You next problem is you if statements, they are doing compares against specific values. I think what you intended was to use >= rather than ==

I'd also drop the use of strings in your compares and use exact numeric comparisons rather than relying on JS laxness that Freddie loves! :lol:
Maybe another day for that.
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by mcrossley »

mcrossley wrote: Tue 07 Jun 2022 4:54 pm The Wiki uses 1 relative field field numbers, your code uses 0 relative, it should be 43.

You next problem is you if statements, they are doing compares against specific values. I think what you intended was to use <= rather than ==

I'd also drop the use of strings in your compares and use exact numeric comparisons rather than relying on JS laxness that Freddie loves! :lol:
Maybe another day for that.
freddie
Posts: 2475
Joined: Wed 08 Jun 2011 11:19 am
Weather Station: Davis Vantage Pro 2 + Ecowitt
Operating System: GNU/Linux Ubuntu 22.04 LXC
Location: Alcaston, Shropshire, UK
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by freddie »

mcrossley wrote: Tue 07 Jun 2022 4:54 pm rather than relying on JS laxness that Freddie loves! :lol:
:lol:
Freddie
Image
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by mcrossley »

Oh go on I'll do it, just to close the thread!

Code: Select all

var uv = rawdata[43] * 1;
var uvword;	
if (uv<=0){ uvword="None";} else
if (uv<=3){ uvword="<span style=\"border: solid 1px; color: black; background-color: #A4CE6a;\">&nbsp;Low&nbsp;</span>";} else
if (uv<=6){ uvword="<span style=\"border: solid 1px; color: black; background-color: #FBEE09;\">&nbsp;Medium&nbsp;</span>";} else
if (uv<=8){ uvword="<span style=\"border: solid 1px; color: black; background-color: #FD9125;\">&nbsp;High&nbsp;</span>";} else
if (uv<=11){var uvword="<span style=\"border: solid 1px; color: #FFFFFF; background-color: #F63F37;\">&nbsp;Very&nbsp;High&nbsp;</span>";} else
{ uvword="eek!";}
$("#UVone").html(uvword);
User avatar
dazza1223
Posts: 867
Joined: Sun 25 Jan 2015 8:41 pm
Weather Station: Davis Vantage Pro 2 plus
Operating System: Raspberry pi 4 (4gb)
Location: Worthing
Contact:

Re: UV colour depending on the number ie None Low Medium High Very High

Post by dazza1223 »

sorry mark but i got busy with things so i dint see your last post..... but thank you so much i knew what you meant by it but thank you for doing it for me
Have fun and keep learning

dazza :D

https://www.davisworthing.co.uk

Image
Post Reply