Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

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

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

wbtag <#IsRaining>, where can I change the output value ?

Discussion and questions about Cumulus weather station software version 1. This section is the main place to get help with Cumulus 1 software developed by Steve Loft that ceased development in November 2014.
Post Reply
wetterfrosch1971
Posts: 123
Joined: Sun 06 Apr 2014 1:15 pm
Weather Station: wh1080
Operating System: windows7
Location: south-west-germany

wbtag <#IsRaining>, where can I change the output value ?

Post by wetterfrosch1971 »

Hi,

webtag "<#IsRaining>"
is it possible to change the output value "1" into the word "it´s raining" and the output value "0" into the word "it´s dry" ?

when it is possible, where I can find the values ?

Thank you for help.
Frank
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: wbtag <#IsRaining>, where can I change the output value

Post by mcrossley »

You could do it JavaScript in the client browser, or in PHP if you use that server side.

Code: Select all

<script>document.write(<#IsRaining>==0 ? "it's dry" : "it's raining");</script>
pecked out on my phone!
wetterfrosch1971
Posts: 123
Joined: Sun 06 Apr 2014 1:15 pm
Weather Station: wh1080
Operating System: windows7
Location: south-west-germany

Re: wbtag <#IsRaining>, where can I change the output value

Post by wetterfrosch1971 »

I want post on my Homepage:

"it´s raining" or "it´s dry"

or can I use the rain-rate webtag?

for post:

"no rain"
"little rain"
"strong rain"
"very stron rain"
etc...

I can not php or Java, becaus I´m only a user.
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: wbtag <#IsRaining>, where can I change the output value

Post by steve »

Note that the <#IsRaining> web tag only works if you have an RG11 rain sensor (as mentioned in the wiki) and it is set to 'it's raining' mode (apologies if you knew this and do have an RG-11). Otherwise, you will need to use the rain rate, as you suggest. So, for a simple yes/no, you could use:

Code: Select all

<script>document.write(<#rrate>==0 ? "it's dry" : "it's raining");</script>
For a more complicated version with several outcomes, you would need to use an if/else if/... construct.
Steve
wetterfrosch1971
Posts: 123
Joined: Sun 06 Apr 2014 1:15 pm
Weather Station: wh1080
Operating System: windows7
Location: south-west-germany

Re: wbtag <#IsRaining>, where can I change the output value

Post by wetterfrosch1971 »

Code: Select all

<script>document.write(<#rrate>==0 ? "it's dry" : "it's raining");</script>
it don´t work, because if no rain, rrate are 0,0

I tried to change the script into

Code: Select all

<script>document.write(<#rrate>==0,0 ? "it's dry" : "it's raining");</script>
but it doesen´t work ;-(

what must I do?

Thank you for help.
Frank
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: wbtag <#IsRaining>, where can I change the output value

Post by steve »

Ah, yes, good point. Javascript comparisons baffle me at times, and Javascript doesn't understand decimal commas. We really need Mark to give us the definitive answer, but this might work:

Code: Select all

<script>document.write('<#rrate>'==='0,0' ? "it's dry" : "it's raining");</script>
Steve
wetterfrosch1971
Posts: 123
Joined: Sun 06 Apr 2014 1:15 pm
Weather Station: wh1080
Operating System: windows7
Location: south-west-germany

Re: wbtag <#IsRaining>, where can I change the output value

Post by wetterfrosch1971 »

yes, it works.

thank you.
wetterfrosch1971
Posts: 123
Joined: Sun 06 Apr 2014 1:15 pm
Weather Station: wh1080
Operating System: windows7
Location: south-west-germany

Re: wbtag <#IsRaining>, where can I change the output value

Post by wetterfrosch1971 »

another question:

how must I write the script if I want only print "it´s raining" without "it´s dry"?

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

Re: wbtag <#IsRaining>, where can I change the output value

Post by mcrossley »

steve wrote:Ah, yes, good point. Javascript comparisons baffle me at times, and Javascript doesn't understand decimal commas. We really need Mark to give us the definitive answer, but this might work:

Code: Select all

<script>document.write('<#rrate>'==='0,0' ? "it's dry" : "it's raining");</script>
Yes, that will be OK in this case.

If you want a more general solution that will work with either dot or comma decimals I would use...

Code: Select all

<script>document.write('<#rrate>'.replace(',','.')==='0.0' ? "it's dry" : "it's raining");</script>
or even more generally (in case the decimal is dropped, or more decimal places are added, or IsRaining produces an unexpected string )...

Code: Select all

<script>document.write(parseFloat('0<#rrate>'.replace(',','.'))===0 ? "it's dry" : "it's raining");</script>
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: wbtag <#IsRaining>, where can I change the output value

Post by mcrossley »

wetterfrosch1971 wrote:another question:

how must I write the script if I want only print "it´s raining" without "it´s dry"?

Thank you
Try...

Code: Select all

if (parseFloat('0<#rrate>'.replace(',','.')) > 0) {document.write("it's raining");}
wetterfrosch1971
Posts: 123
Joined: Sun 06 Apr 2014 1:15 pm
Weather Station: wh1080
Operating System: windows7
Location: south-west-germany

Re: wbtag <#IsRaining>, where can I change the output value

Post by wetterfrosch1971 »

Code: Select all

<script>document.write('<#rrate>'==='0,0' ? "it's dry" : "it's raining");</script>
a last question:

I will post a Image instead of the words "it´s raining" and "it´s dry"
the Images are on my webspace (for example http://www.webspaceXYZ.de/image-dry.jpg" and http://www.webspaceXYZ.de/image-rain.jpg").

how do I change the code?

many thanks for help

EDIT:
question has been done
Post Reply