I see you're using the WeeWX Weather-display skin to create testtags.php and clientraw.txt.
You can use the following Weewx-currentconds.php script to get the metar sky conditions for you <?php
/*
File: Weewx-currentconds.php
Purpose: provide a current conditions and icon from a WeeWX running the WD bridge software
Add a include("Weewx-currentconds.php") after an include for testtags.php ($SITE['WXtags']) and
configure a metar in $SITE['conditionsMETAR'] entry.
Set $SITE['overrideRain'] = true; to enable local rain to override sky conditions from metar.
Author: Ken True - webmaster@saratoga-weather.org
//Version 1.00 - 14-Apr-2019
*/
// --------------------------------------------------------------------------
// allow viewing of generated source
if (isset($_REQUEST["sce"]) and strtolower($_REQUEST["sce"]) == "view" ) {
//--self downloader --
$filenameReal = __FILE__;
$download_size = filesize($filenameReal);
header("Pragma: public");
header("Cache-Control: private");
header("Cache-Control: no-cache, must-revalidate");
header("Content-type: text/plain");
header("Accept-Ranges: bytes");
header("Content-Length: $download_size");
header("Connection: close");
readfile($filenameReal);
exit;
}
#-------------------------------------------------------------------------------------
# function processed WD variables
#-------------------------------------------------------------------------------------
global $SITE,$Debug;
if(isset($SITE['conditionsMETAR'])) { // override with METAR conditions for text and icon if requested.
include_once("get-metar-conditions-inc.php");
list($Currentsolardescription,$iconnumber) = mtr_conditions($SITE['conditionsMETAR'], $time, $sunrise, $sunset);
if(isset($currentrainratehr) and
(!isset($SITE['overrideRain']) or (isset($SITE['overrideRain']) and $SITE['overrideRain'])) ) {
print "<!-- Weewx-currentconds before: Currentsolardescription='$Currentsolardescription' icon='$iconnumber' -->\n";
print $Debug;
list($Currentsolardescription,$iconnumber) =
WWX_RainRateIcon($Currentsolardescription,$iconnumber,$currentrainratehr,$uomrain,$time,$sunrise,$sunset);
print "<!-- Weewx-currentconds after: Currentsolardescription='$Currentsolardescription' icon='$iconnumber' -->\n";
}
}
#-------------------------------------------------------------------------------------
# WeeWX support function - WWX_RainRateIcon
#-------------------------------------------------------------------------------------
function WWX_RainRateIcon($inText,$inIcon,$inRate,$inUOM,$time,$sunrise,$sunset,$lastRain='0000-00-00T00:00:00') {
global $Debug;
/*
Rainfall intensity is classified according to the rate of precipitation:
Light rain — rate is < 2.5 mm (0.098 in) per hour
Moderate rain — rate is between 2.5 mm (0.098 in) - 7.6 mm (0.30 in) or 10 mm (0.39 in) per hour
Heavy rain — rate is > 7.6 mm (0.30 in) per hour, or between 10 mm (0.39 in) and 50 mm (2.0 in) per hour
Violent rain — rate is > 50 mm (2.0 in) per hour
*/
$Debug .= "<!-- WWX_RainRateIcon in='$inText' icon='$inIcon' rate='$inRate' uom='$inUOM' -->\n";
$newText = ''; // assume no changes
$newIcon = $inIcon;
$rate = $inRate;
if(preg_match('|in|i',$inUOM)) { // convert to mm/hr rate
$rate = $inRate * 25.4;
}
if(substr($lastRain,0,4) <> '0000') {
if($rate < 0.001 and time()-strtotime($lastRain) < 30*60) {
$newText = 'Moderate Drizzle';
}
}
if ($rate > 0.0 and $rate < 2.5) { $newText = 'Light Rain'; }
if ($rate >=2.5 and $rate < 7.6) { $newText = 'Moderate Rain'; }
if ($rate >=7.6 and $rate < 50.0) { $newText = 'Heavy Rain'; }
if ($rate >= 50.0) { $newText = 'Violent Rain'; }
if($newText <> '' or $rate == 0.0) {
if ($newText <> '' and $inText <> '') {$newText .= ', ';}
$newText .=
preg_replace('/(Light|Moderate|Heavy|Violent|Extreme){0,1}\s*(Rain|Mist|Drizzle), /i','',$inText);
$newIcon = mtr_get_iconnumber ($time,$newText,$sunrise,$sunset);
} else {
$newText = $inText;
}
$Debug .= "<!-- WWX_RainRateIcon out='$newText' icon='$newIcon' rate='$rate' mm/hr -->\n";
return(array($newText,$newIcon));
}
?>
In your home page, after the include for $SITE['WXtags'], add an include("Weewx-currentconds.php"). It will use your testtags.php data and the METAR listed in Settings-weather.php $SITE['conditionsMETAR'] to set $Currentsolardescription and $iconnumber for you to work with the dashboard. It's the same code I used for other weather software that didn't have the unique WD metar settings.
Also, you'll need to edit ajaxWDwx.js to prevent the weewx-generated clientraw.txt from overriding with the default values when the AJAX update happens. Change ajaxWDwx.js from // current condition icon and description
set_ajax_obs("ajaxconditionicon",
ajax_wxIcon(clientraw[48])
);
set_ajax_obs("ajaxconditionicon2",
ajax_wxIconJPG(clientraw[48])
);
var currentcond = clientraw[49];
// currentcond = currentcond.replace(/_/g,' ');
// currentcond = currentcond.replace(/^\/Dry\//g,'');
currentcond = currentcond.replace(/\\/g,', ');
// currentcond = currentcond.replace(/\//g,', ');
currentcond = ajaxFixupCondition(currentcond);
set_ajax_obs("ajaxcurrentcond",currentcond);
set_ajax_obs("gizmocurrentcond",currentcond);
to // current condition icon and description
// set_ajax_obs("ajaxconditionicon",
// ajax_wxIcon(clientraw[48])
// );
// set_ajax_obs("ajaxconditionicon2",
// ajax_wxIconJPG(clientraw[48])
// );
var currentcond = clientraw[49];
// currentcond = currentcond.replace(/_/g,' ');
// currentcond = currentcond.replace(/^\/Dry\//g,'');
currentcond = currentcond.replace(/\\/g,', ');
// currentcond = currentcond.replace(/\//g,', ');
currentcond = ajaxFixupCondition(currentcond);
// set_ajax_obs("ajaxcurrentcond",currentcond);
// set_ajax_obs("gizmocurrentcond",currentcond);
Best regards,
Ken