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
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
Web Tag IsRaining in HTML
Moderator: mcrossley
-
Ken22
- Posts: 97
- Joined: Tue 14 Jan 2014 3:08 pm
- Weather Station: Ecowitt WS90/HP2560,GW1200,WN32
- Operating System: Windows 10 Pro
- Location: Massachusetts, USA
- Contact:
Web Tag IsRaining in HTML
IsRaining returns either a 0 or 1.
Is it possible on my index.htm to convert this to either a "Yes" or "No"?
I know just enough about HTML to get myself in trouble.
Is it possible on my index.htm to convert this to either a "Yes" or "No"?
I know just enough about HTML to get myself in trouble.
- De Hout
- Posts: 92
- Joined: Thu 09 Oct 2014 5:40 pm
- Weather Station: Davis Vantage Pro2+ FARS
- Operating System: Windows 11 | CU v1.9.4 (10992)
- Location: Alkmaar, The Netherlands
- Contact:
Re: Web Tag IsRaining in HTML
Something like this will do.
Replace the #IsRaining webtag in your index.htm with the code below.
Replace the #IsRaining webtag in your index.htm with the code below.
Code: Select all
<div id="RainStatus"></div>
<script>
let rain = '#IsRaining';
if (rain === '0') {
rain = 'No';
} else {
rain = 'Yes';
}
document.getElementById("RainStatus").innerText = rain;
</script>
-
Ken22
- Posts: 97
- Joined: Tue 14 Jan 2014 3:08 pm
- Weather Station: Ecowitt WS90/HP2560,GW1200,WN32
- Operating System: Windows 10 Pro
- Location: Massachusetts, USA
- Contact:
Re: Web Tag IsRaining in HTML
I seem to be missing something here. Here is what I have tried:
Code: Select all
<span data-cmxdata="IsRaining"></span>
ZZZ
<div id="RainStatus"></div>
<script>
let rain = '#IsRaining';
rain = '0';
if (rain === '0') {
rain = 'No';
} else if (rain === '1') {
rain = 'Yes';
} else {
rain = 'Error'
}
document.getElementById("RainStatus").innerText = rain;
</script>
*** This produces:
0 ZZZ
No
---------------------------------
<span data-cmxdata="IsRaining"></span>
ZZZ
<div id="RainStatus"></div>
<script>
let rain = '#IsRaining';
if (rain === '0') {
rain = 'No';
} else if (rain === '1') {
rain = 'Yes';
} else {
rain = 'Error'
}
document.getElementById("RainStatus").innerText = rain;
</script>
*** This produces:
0 ZZZ
Error
-----------------------------------------------
<span data-cmxdata="IsRaining"></span>
ZZZ
<div id="RainStatus"></div>
<script>
let rain = <span data-cmxdata="IsRaining"></span>;
if (rain === '0') {
rain = 'No';
} else if (rain === '1') {
rain = 'Yes';
} else {
rain = 'Error'
}
document.getElementById("RainStatus").innerText = rain;
</script>
*** This produces:
0 ZZZ
---------------------------------------------
<span data-cmxdata="IsRaining"></span>
ZZZ
<div id="RainStatus"></div>
<script>
let rain = data-cmxdata="IsRaining";
if (rain === '0') {
rain = 'No';
} else if (rain === '1') {
rain = 'Yes';
} else {
rain = 'Error'
}
document.getElementById("RainStatus").innerText = rain;
</script>
*** This produces:
0 ZZZ
Any clarification would be appreciated.
- mcrossley
- Posts: 14384
- Joined: Thu 07 Jan 2010 9:44 pm
- Weather Station: Davis VP2/WLL
- Operating System: Bullseye Lite rPi
- Location: Wilmslow, Cheshire, UK
- Contact:
Re: Web Tag IsRaining in HTML
You cannot use #IsRaining in a JavaScript, the old way of doing it would be to use the web tag <#IsRaining>.
The new web site loads all the data into an object called "cmx_data".
To access IsRaining you would use
Or just use cmx_data.IsRaining rather than assigning it to the variable "rain" then using that.
The new web site loads all the data into an object called "cmx_data".
To access IsRaining you would use
Code: Select all
let rain = cmx_data.IsRaining;-
Ken22
- Posts: 97
- Joined: Tue 14 Jan 2014 3:08 pm
- Weather Station: Ecowitt WS90/HP2560,GW1200,WN32
- Operating System: Windows 10 Pro
- Location: Massachusetts, USA
- Contact:
Re: Web Tag IsRaining in HTML
Still not working:mcrossley wrote: ↑Fri 29 Nov 2024 4:27 pm The new web site loads all the data into an object called "cmx_data".
To access IsRaining you would useCode: Select all
let rain = cmx_data.IsRaining;
Code: Select all
<span data-cmxdata="IsRaining"></span>
ZZZ
<div id="RainStatus"></div>
<script>
let rain = cmx_data.IsRaining;
if (rain === '0') {
rain = 'No';
} else if (rain === '1') {
rain = 'Yes';
} else {
rain = 'Error'
}
document.getElementById("RainStatus").innerText = rain;
</script>
XXX
0 ZZZ
XXX
- mcrossley
- Posts: 14384
- Joined: Thu 07 Jan 2010 9:44 pm
- Weather Station: Davis VP2/WLL
- Operating System: Bullseye Lite rPi
- Location: Wilmslow, Cheshire, UK
- Contact:
Re: Web Tag IsRaining in HTML
We need to see a link to the test page please.
- De Hout
- Posts: 92
- Joined: Thu 09 Oct 2014 5:40 pm
- Weather Station: Davis Vantage Pro2+ FARS
- Operating System: Windows 11 | CU v1.9.4 (10992)
- Location: Alkmaar, The Netherlands
- Contact:
Re: Web Tag IsRaining in HTML
My initial code contains an error. The webtag should be <#IsRaining>
This script works on my webserver, although I have tested it with <#IsSunUp> instead of <#IsRaining> which is not a valid webtag for Cumulus 1.
Or do webtags work differently with CMX?
Code: Select all
<div id="RainStatus"></div>
<script>
rain = '<#IsRaining>';
if (rain === '0') {
rain = 'No';
} else {
rain = 'Yes';
}
document.getElementById("RainStatus").innerText = rain;
</script>
Or do webtags work differently with CMX?
- mcrossley
- Posts: 14384
- Joined: Thu 07 Jan 2010 9:44 pm
- Weather Station: Davis VP2/WLL
- Operating System: Bullseye Lite rPi
- Location: Wilmslow, Cheshire, UK
- Contact:
Re: Web Tag IsRaining in HTML
The web tags work the same, but the pages are constructed differently - they are no longer all processed and uploaded like C1.
- mcrossley
- Posts: 14384
- Joined: Thu 07 Jan 2010 9:44 pm
- Weather Station: Davis VP2/WLL
- Operating System: Bullseye Lite rPi
- Location: Wilmslow, Cheshire, UK
- Contact:
Re: Web Tag IsRaining in HTML
Ah, your script will execute immediately.
You need the script to wait until the cmx_data object has been populated with the data.
The data load is encapsulated in a promise, so something like this (untested) should work
You need the script to wait until the cmx_data object has been populated with the data.
The data load is encapsulated in a promise, so something like this (untested) should work
Code: Select all
$(document).ready(function() {
dataLoadedPromise.then(function() {
let rain = cmx_data.IsRaining === '0' ? 'No' : 'Yes' ;
document.getElementById("RainStatus").innerText = rain;
});
});
-
Ken22
- Posts: 97
- Joined: Tue 14 Jan 2014 3:08 pm
- Weather Station: Ecowitt WS90/HP2560,GW1200,WN32
- Operating System: Windows 10 Pro
- Location: Massachusetts, USA
- Contact:
Re: Web Tag IsRaining in HTML
Yes, it works perfectly.
Your help is greatly appreciated.
My page is now perfect until I think of some new way to make it better.