Author Topic: Change image + text forecast web saratoga when there is rain rate  (Read 263 times)

0 Members and 1 Guest are viewing this topic.

Offline CarlosLSev

  • Member
  • *
  • Posts: 20
Hello my knowledge in php is basic I want to do the following: I use the Saratoga template. In ajax-dashboard.php en Summary / Temperature We have the current forecast. Image + text I want to change both the image and the text when the rain intensity is greater than 0. If the intensity is 0 it remains unchanged I have this code to read realtime.txt And the piece of code I use is this. If there is no intensity of rain it works, but if there is, I get the 2 images and the 2 texts. What am i doing wrong? As I can do to wue when it rains only my image and personalized text come out.   
Script
Code: [Select]
<?php                                 // Script que lee el fichero realtime 
$realtime "./realtime.txt";                 
$archivo fopen($realtime"r");
$linea=fgets($archivo);
fclose($archivo);
$dato explode(" "$linea);

///////////Script que muestra un texto si no hay  intensidad de lluvia y si hay intensidad muestra texto y una imagen/////////////////////
//$lluvia = $dato[8]; //Intensidad lluvia realtime
$lluvia 0.1;  //Desmarcar para probar manualmente
?>

The code is this.
Code: [Select]
if ($lluvia > 0.0)     // Si la intensidad de agua es superior a 0.0 se activa
       $llueve='<img src="imagenes/nube.jpg"width="55px"><br><img src="imagenes/rain.gif"width="55px"><br>Esta lloviendo';

 else ?> 

                            <img src="<?php echo $condIconDir newIcon($iconnumber?>
alt="<?php $t1 fixupCondition($Currentsolardescription);
  echo $t1?>
"
title="<?php echo $t1?>" height="58" width="55" />   

<td class="data1" style="text-align: center;border: none"><span class="ajax" id="ajaxcurrentcond">
  <?php echo $t1
echo  $llueve
   
?>


« Last Edit: April 18, 2021, 05:33:03 PM by CarlosLSev »

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8307
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Change image + text forecast web saratoga when there is rain rate
« Reply #1 on: April 18, 2021, 07:10:48 PM »
I'm not sure why you feel the need to add this function .. that function already exists in CU-defs.php as CU_RainRateIcon().  It's enabled by Settings-weather.php entries
Code: [Select]
# Weather Station sensors and options for dashboard
$SITE['conditionsMETAR'] = 'LEZL';  // set to nearby METAR for current conditions icon/text
#  comment out conditionsMETAR if no nearby METAR.. conditions icon/text will not be displayed
#
$SITE['overrideRain']   = true; // =true then rain rate will set rain words instead of METAR rain words
#                               // =false - no change to METAR rain words (station rain rate not used)

Did you find that the built-in function was not working on your site?
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline CarlosLSev

  • Member
  • *
  • Posts: 20
Re: Change image + text forecast web saratoga when there is rain rate
« Reply #2 on: April 19, 2021, 10:05:30 AM »
I'm not sure why you feel the need to add this function .. that function already exists in CU-defs.php as CU_RainRateIcon().  It's enabled by Settings-weather.php entries
Code: [Select]
# Weather Station sensors and options for dashboard
$SITE['conditionsMETAR'] = 'LEZL';  // set to nearby METAR for current conditions icon/text
#  comment out conditionsMETAR if no nearby METAR.. conditions icon/text will not be displayed
#
$SITE['overrideRain']   = true; // =true then rain rate will set rain words instead of METAR rain words
#                               // =false - no change to METAR rain words (station rain rate not used)

Did you find that the built-in function was not working on your site?



Thanks for your reply. On my website, when it is raining, the image and text showed cloudy, or very cloudy.

According to your template, if the rain gauge of the weather station detects rain, said image and text should indicate in real time a rain image and rain text. It is right? The configuration seems correct.
Tomorrow it will rain in my area, I will check if this is true, otherwise I would make a capture.
Thank you very much for your time, I will tell you.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8307
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Change image + text forecast web saratoga when there is rain rate
« Reply #3 on: April 19, 2021, 01:38:20 PM »
Yes, it should work as you expect.  I think it may be malfunctioning on your site is due to your Settings.php entry of
Code: [Select]
$SITE['uomRain'] = ' l';     // =' mm', =' in'
  You should change that to be
Code: [Select]
$SITE['uomRain'] = ' mm';     // =' mm', =' in'
The conversion routines do not know how to handle =' l' (for liters, I assume), so even a heavy rain may not be handled by the function.  Change Settings.php as above and it should work fine for your site when it rains.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline CarlosLSev

  • Member
  • *
  • Posts: 20
Re: Change image + text forecast web saratoga when there is rain rate
« Reply #4 on: May 02, 2021, 04:27:57 PM »
Hello, after a few rains I can confirm that it works correctly. Even with the l instead of mm. Perhaps my error was that the Cutags.php file was updated every 5 minutes, since it is this file that causes the image and text to change, and I did not take that delay into account. That's why I thought it didn't work.
Greetings, sorry for the confusion and congratulations on your templates