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

Adding a 24 hour trend to current conditions

Please DO NOT use this to publish your entire wish. This Forum is for specific suggestions to enhance the usability of Cumulus MX for all users, NOT your personal requirements. Please check this forum and the rejected forum to make sure you are NOT posting a DUPLICATE suggestion. It will be heavily monitored by Admin and Mark Crossley to determine the feasibility and the difficulty of the suggestion. Those Topics that are deemed inadmissible will moved to the rejected Forum. The remaining Topics will be the Accepted list of future developments, and when our voluntary development group adds it to a build, the build number will be added to the Topic title.
Post Reply
inmyrvm
Posts: 44
Joined: Thu 19 Nov 2020 9:16 pm
Weather Station: Davis VP2
Operating System: Windows 10

Adding a 24 hour trend to current conditions

Post by inmyrvm »

I searched around the forum and didn't see this posted but I suspect it's not difficult. I'd like to add a 24 hour trend to my current conditions. For example, on the "Now" page have the current temperature and then next to it have a plus or minus trend from 24 hours ago to show whether it's warmer or cooler than yesterday. Obviously the data is available to do this and there is the trends page with very nice graphics, but I like the trend number next to the current value for quick reference. Has anyone done this on their own? When I used Virtual Weather Station years ago it had specific tags for conditions 24 hours ago so it was just a matter of adding that tag to the web page. I suspect it would be a similar process in MX but I'm just not familiar enough with how to do that.

Thanks.

Update: Just noticed a similar thread in the CumulusMX current section of the message board (viewtopic.php?f=40&t=18669) but no definitive solutions yet. Maybe not as simple as I assumed. Hoping someone might have some ideas. Apologies if this wasn't quite the right board section for this topic. I'm still very new to this.
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: Adding a 24 hour trend to current conditions

Post by mcrossley »

You would have to add a little bit of JavaScript to the page to subtract the two values and display the the result.

Something like- untested - (where "id_name" is the id you allocate to the span or whatever to contain the text)

Code: Select all

let diff = <#temp> - <#RecentOutsideTemp h=24>;
if (diff > 0) {
    diff = '+' + diff;
}
$('#id_name').text(diff);
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Adding a 24 hour trend to current conditions

Post by beteljuice »

Just noticed a similar thread in the CumulusMX current section of the message board (viewtopic.php?f=40&t=18669) but no definitive solutions yet.
The suggestions offered half way down the first page are valid provided that your page is Template driven.

The problem for that gentleman (when we eventually found out) was that he wanted to create a data file (on his PC) to upload for use by a third-party.
Image
......................Imagine, what you will KNOW tomorrow !
inmyrvm
Posts: 44
Joined: Thu 19 Nov 2020 9:16 pm
Weather Station: Davis VP2
Operating System: Windows 10

Re: Adding a 24 hour trend to current conditions

Post by inmyrvm »

Thank you for those! I liked the addition of the code include a "+" to make it obvious it's a trend, but I must be missing something in the syntax because it's not writing the output to the page. I looked up javascript examples and tried a few things but nothing was working. Also I wasn't sure what the purpose was of #id_name. Is that how the output gets written to the page? Here's what I tried (just added the document.write at the end):

<script>let diff = <#temp> - <#RecentOutsideTemp d=1>;
if (diff > 0) {
diff = '+' + diff;
}
$('#id_name').text(diff);
document.write(diff);
</script>

With the other response referencing the example from an earlier thread I was able to make that work using this code:

<script>document.write((<#RCtemp>*10 - <#RCRecentOutsideTemp d=1>*10) / 10);</script>

The original code without the extra math gave me a long decimal but this truncated it to one decimal. But that code didn't have the + symbol for positive trends which I really like and can't seem to get in there.

Thanks,

Mike
User avatar
beteljuice
Posts: 3292
Joined: Tue 09 Dec 2008 1:37 pm
Weather Station: None !
Operating System: W10 - Threadripper 16core, etc
Location: Dudley, West Midlands, UK

Re: Adding a 24 hour trend to current conditions

Post by beteljuice »

$('#id_name').text(diff); Is JQuery, the plain old javascript version would be ...

Code: Select all

document.getElementById("a_name").innerHTML = diff;

and the html ..

Delta T24 <span id="a_name">?</span>

but you can just

Delta T24 <script>document.write(diff)</script>
Where ? is replaced by the value of diff

NOTE: if using $("#id_name") or document.getElementById( .... the actual script code needs to be at the bottom of your page (somewhere below <element id= ...)

Whereas ...

With the other code, break it down a bit ...

Code: Select all

<script>
diff = (<#RCtemp>*10 - <#RCRecentOutsideTemp d=1>*10) / 10;
if (diff > 0) {
diff = '+' + diff;
}
</script>
If using document.write( ... the script code needs to be ABOVE the document.write

Fun isn't it :lol:
Image
......................Imagine, what you will KNOW tomorrow !
inmyrvm
Posts: 44
Joined: Thu 19 Nov 2020 9:16 pm
Weather Station: Davis VP2
Operating System: Windows 10

Re: Adding a 24 hour trend to current conditions

Post by inmyrvm »

That worked out perfectly. Thanks for the help. :clap:

Mike
Post Reply