Welcome to the new home of the Cumulus Support forum.

Latest Cumulus release v1.9.4 (build 1099) - 28 November 2014
Latest Cumulus MX release v3.0.0 build 3046 - 02 January 2019. See the Wiki for download

Mobile presentation for Cumulus 1

Discussion and questions about Cumulus weather station software version 1. This section and its subforums are the main place to get help with Cumulus. Anything which is not specific to the type of weather station goes in here; for anything specific to a type of weather station, please use the appropriate subforum. Use the 'website development' section for any questions relating to creating or running a web site for Cumulus data. Discussion of the stations themselves in these sections is fine.
Post Reply
User avatar
Vagspel
Posts: 59
Joined: Wed 11 Jan 2017 12:29 pm
Weather Station: Davis Vantage 2 Plus
Operating System: W7

Mobile presentation for Cumulus 1

Post by Vagspel » Fri 10 Mar 2017 11:12 am

Hi,
After a bit of thinking and realizing that the price for to fix apps for IOS and Android was to high :-) I did a simple mobile page using the info in Cumulus realtime.txt.
Check out the result at http://www.o-vader.se/mobil.php.
One small problem that I need to solve is dd:mm:yy to our standard yyyy:mm:dd but is is not a big deal.
Feel free to copy and use the script and ad your own data and meta tags.
Translate the "td-header" data into your own language.

<?php
$data = file_get_contents('http://www.yourdomain.xx/realtime.txt');
$d = explode(" ", $data);
?>

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="keywords" content=" weather station, Temperatur, ">
<meta name="description" content=" weather station, Temperatur, ">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<meta http-equiv="refresh" content="60">

<style>
.td-header {
/* Font storlek i pixlar */
font-size: 24px;
font-weight: bold;
width: 50%;
}

.td-data {
/* Font storlek i pixlar */
font-size: 24px;
}

table {
width: 100%;
}
body {
background-color: #c8c8c8;
}

</style>

<title>Mobilsidan Öckerö väder</title>

<script>
Put your Google analytics script here if you are using it
</script>
</head>
<body>
<h2>Name of your weathestation</h2>
<table>
<tr>
<td class="td-header">Datum</td>
<td class="td-data"><?php echo $d[0]; ?></td>
</tr>
<tr>
<td class="td-header">Tid</td>
<td class="td-data"><?php echo $d[1]; ?></td>
</tr>
<tr>
<td class="td-header">Temperatur</td>
<td class="td-data"><?php echo $d[2] . " °C"; ?></td>
</tr>
<tr>
<td class="td-header">Upplevd temp</td>
<td class="td-data"><?php echo $d[54] . " °C"; ?></td>
</tr>
<tr>
<td class="td-header">Rel. fuktighet</td>
<td class="td-data"><?php echo $d[3] . " %"; ?></td>
</tr>
<tr>
<td class="td-header">Luftryck</td>
<td class="td-data"><?php echo $d[10] . " hPa"; ?></td>
</tr>
<tr>
<td class="td-header">Medelvind</td>
<td class="td-data"><?php echo $d[5] . " m/sek"; ?></td>
</tr>
<tr>
<td class="td-header">Byvind 10 min</td>
<td class="td-data"><?php echo $d[40] . " m/sek"; ?></td>
</tr>
<tr>
<td class="td-header">Vindriktning</td>
<td class="td-data"><?php echo $d[7] . " grader"; ?></td>
</tr>
<tr>
<td class="td-header">Vindriktning</td>
<td class="td-data"><?php echo $d[11] . " "; ?></td>
</tr>
<tr>
<td class="td-header">Soltimmar</td>
<td class="td-data"><?php echo $d[55] . " Tim"; ?></td>
</tr>
<tr>
<td class="td-header">Sol</td>
<td class="td-data"><?php echo $d[45] . " W/m2"; ?></td>
</tr>
</table>
</body>
</html>

The filname should be .php
//Gunnar
You do not have the required permissions to view the files attached to this post.
Last edited by Vagspel on Sun 12 Mar 2017 2:49 pm, edited 1 time in total.
Gunnar
www.o-vader.se
www.o.vader.se/mobil.php for mobile phones

User avatar
PaulMy
Posts: 1750
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis Vantage Pro 2+ w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: Mobile presentation for Cumulus 1

Post by PaulMy » Fri 10 Mar 2017 3:44 pm

Thanks Gunnar, I've given it a try to test on my new Galaxy S7 http://www.komokaweather.com/weather/cu-mobile.php

Enjoy,
Paul

sfws
Posts: 462
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Final post in top ten topic
Operating System: Tempermental Win. 10 PC
Location: Moving

Re: Mobile presentation for Cumulus 1

Post by sfws » Fri 10 Mar 2017 5:12 pm

Vagspel wrote:<td class="td-header">Datum</td>
<td class="td-data"><?php echo $d[0]; ?></td>
Vagspel wrote:One small problem that I need to solve is dd:mm:yy to our standard yyyy:mm:dd
A simple way is change to

Code: Select all

<td class="td-header">Datum</td>
<td class="td-data"><?php echo "20" . substr($d[0],-2,2) . "-" . substr($d[0],3,2) . "-" . substr($d[0],0,2); ?></td>

User avatar
Vagspel
Posts: 59
Joined: Wed 11 Jan 2017 12:29 pm
Weather Station: Davis Vantage 2 Plus
Operating System: W7

Re: Mobile presentation for Cumulus 1

Post by Vagspel » Fri 10 Mar 2017 5:18 pm

Thanks, I will try this :-)
//Gunnar

Works perfect :D
Thanks again!
//G
Gunnar
www.o-vader.se
www.o.vader.se/mobil.php for mobile phones

User avatar
PaulMy
Posts: 1750
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis Vantage Pro 2+ w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: Mobile presentation for Cumulus 1

Post by PaulMy » Fri 10 Mar 2017 5:28 pm

Thanks sfws, I made that change...

and if I may ask further, what PHP code would I use to show "Yes" if sun shining and "No" if not to replace my archaic 0=No 1-Yes?

Code: Select all

<tr>
<td class="td-header">Sun Shining</td>
<td class="td-data"><?php echo $d[57] . " (0=N 1=Y)"; ?></td>
</tr>
http://www.komokaweather.com/weather/cu-mobile.php

Enjoy,
Paul

User avatar
Vagspel
Posts: 59
Joined: Wed 11 Jan 2017 12:29 pm
Weather Station: Davis Vantage 2 Plus
Operating System: W7

Re: Mobile presentation for Cumulus 1

Post by Vagspel » Fri 10 Mar 2017 10:24 pm

PaulMy,
Try this!
echo "Sun : " . $RTpieces[57] . " (0=N 1=Y)";
echo "\r\n";
echo "Sun : ";
if ($RTpieces[57] == "0") {
echo "No!";
} else {
echo "YES!";
}
//Gunnar
Gunnar
www.o-vader.se
www.o.vader.se/mobil.php for mobile phones

User avatar
PaulMy
Posts: 1750
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis Vantage Pro 2+ w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: Mobile presentation for Cumulus 1

Post by PaulMy » Fri 10 Mar 2017 11:02 pm

Thanks Gunnar,
I had to reverse the conditional statement as it was displaying YES when there was no sunshine and Cumulus realtime.txt had 0 in the last field.

Code: Select all

<tr>
<td class="td-header">Sun Shining</td>
<td class="td-data">
<?php if ($RTpieces[57] == "1") {
echo "YES!";
} else {
echo "NO!";
}
?>
</td>
</tr>
Will see if it works correctly when next the sun is shinning.

Enjoy,
Paul

User avatar
Vagspel
Posts: 59
Joined: Wed 11 Jan 2017 12:29 pm
Weather Station: Davis Vantage 2 Plus
Operating System: W7

Re: Mobile presentation for Cumulus 1

Post by Vagspel » Sat 11 Mar 2017 9:07 am

Np Paul, hope that it will work when the sun comes up :D
Creds to Bengt http://www.ockero.nu that wrote the code :clap:
//Gunnar
Gunnar
www.o-vader.se
www.o.vader.se/mobil.php for mobile phones

User avatar
PaulMy
Posts: 1750
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis Vantage Pro 2+ w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: Mobile presentation for Cumulus 1

Post by PaulMy » Sat 11 Mar 2017 4:13 pm

Thanks Gunnar and Bengt too!
One step backwards and two steps forward... my previous code did not work for the sun shinning as it did not change when the sun was ON or OFF. Decided to become a PHP expert (not)and Googled PHP If/Else and after many trials and errors I've got it working correctly, I think. Earlier this morning we had several times of sun shinning and not, so I could verify while testing, but now waiting for sun shinning again. I did try by hard coding "1" and "0" and with that it did work so on the right track.

It shows up quite well on my Galaxy S7 and Tab E (both of these and Android are new to me) http://www.komokaweather.com/weather/cu-mobile.php and like the realtime refresh updates. Will have to learn what's the difference between webpage and Apps. Through the Meteotemplate I have created an Android App which is somewhat similar to what you guys have done except that it has the Meteotemplate graphics in stead of the data description text. I haven't figured out how to add or change anything on this yet.

Enjoying, and learning...
Paul

User avatar
Vagspel
Posts: 59
Joined: Wed 11 Jan 2017 12:29 pm
Weather Station: Davis Vantage 2 Plus
Operating System: W7

Re: Mobile presentation for Cumulus 1

Post by Vagspel » Sat 11 Mar 2017 4:40 pm

There is something wrong with the mobil.php when opened in Edge!
Warning: file_get_contents(realtime.txt) [function.file-get-contents]: failed to open stream: Stale file handle in /home/content/96/5379896/html/weather/cu-mobile.php on line 2
//Gunnar
Gunnar
www.o-vader.se
www.o.vader.se/mobil.php for mobile phones

User avatar
PaulMy
Posts: 1750
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis Vantage Pro 2+ w/Envoy USB
Operating System: Windows-8
Location: Komoka, ON Canada
Contact:

Re: Mobile presentation for Cumulus 1

Post by PaulMy » Sat 11 Mar 2017 4:54 pm

Hi Gunnar,
If you refresh then it will show correctly. I get this occasionally on other scripts and templates, including Saratoga, that rely on the realtime.txt. I have noticed it a few times on this new cu-mobile.php as well but a refresh/reload fixes it - at least on my Windows 8 PC, Galaxy S7 and Tab E devices. I have researched that Stale file handle error a lot but have not found any resolution. I have experimented with various realtime.txt realtime interval settings but without success. One template I use had a lot of this error, about once a minute, and working with the author we were not able to determine why, and then it just disappeared and has not shown for me on that template for months. There were quite a number of updates for that template so that might have been the reason it stopped giving the error but we have not determined what that might have been. To try to avoid that error I duplicated the realtime.txt as realtimeT.txt and have Cumulus process this and upload in real time but that also had given that Stale file handle error. Unless I stumble on to something else to try I have to live with it.

Enjoy,
Paul

User avatar
Vagspel
Posts: 59
Joined: Wed 11 Jan 2017 12:29 pm
Weather Station: Davis Vantage 2 Plus
Operating System: W7

Re: Mobile presentation for Cumulus 1

Post by Vagspel » Sat 11 Mar 2017 4:59 pm

Ok, I will check with Bengt and see if he has any idea of what the problem can be.
Take away <script> Put your Google analytics script here if you are using it </script>.
I put it there just to show you where I have my Analytic script.
//G
Gunnar
www.o-vader.se
www.o.vader.se/mobil.php for mobile phones

Post Reply