<?php
#-----------------------------------------------------------------------
# display source of script if requested so
#-----------------------------------------------------------------------
if (isset($_REQUEST['sce']) && strtolower($_REQUEST['sce']) == 'view' ) {
   $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;
}
$pageName	= 'tags.php';
if (!isset($SITE)){echo "<h3>invalid call to script $pageName</h3>";exit;}
$pageVersion	= '2.6 2014-10-10 12:29:51 ';
$SITE['wsModules'][$pageName] = 'version: ' . $pageVersion;
$pageFile = basename(__FILE__);			// check to see this is the real script
if ($pageFile <> $pageName) {$SITE['wsModules'][$pageFile]	= 'this file loaded instead of '.$pageName;}
echo '<!-- module '.$pageFile.' ==== '.$SITE['wsModules'][$pageFile]." -->".PHP_EOL;
#-----------------------------------------------------------------------
# 3.00 2014-09-22 release version   3.01 added ET conversion
# --------------------------------------- version ----------------------
$ws['tags.php']	= $pageName.'-'.$pageVersion;
# --------------------------------------- conditions--------------------
$ws['actTime']	= '[YYYY][MM][DD][hh][mm][ss]'; // '20120523113945';
# ------------------------------------------ temperature ---------------
$to 	= $SITE['uomTemp'];
$from	= 'C';

$ws['tempMinTodayTime']	= '[t1temp-dmintime:--]';
$ws['tempMinYdayTime']	= '[t1temp-ydmintime:--]';
$ws['tempMinMonthTime']	= '[t1temp-mmintime:--]';
$ws['tempMinYearTime']	= '[t1temp-ymintime.1:--]';
$ws['tempMaxTodayTime']	= '[t1temp-dmaxtime:--]'; 
$ws['tempMaxYdayTime']	= '[t1temp-ydmaxtime:--]';
$ws['tempMaxMonthTime']	= '[t1temp-mmaxtime:--]';
$ws['tempMaxYearTime']	= '[t1temp-ymaxtime:--]';
$ws['dewpMinTodayTime']	= '[th0dew-dmintime:--]';
$ws['dewpMinYdayTime']	= '[th0dew-ydmintime:--]';
$ws['dewpMaxTodayTime']	= '[th0dew-dmaxtime:--]';
$ws['dewpMaxYdayTime']	= '[th0dew-ydmaxtime:--]';

$ws['chilMinTodayTime']	= '[wind0chill-dmintime:--]';
$ws['chilMinYdayTime']	= '[wind0chill-ydmintime:--]';
$ws['chilMinMonthTime'] = '[wind0chill-mmintime:--]';
$ws['chilMinYearTime']	= '[wind0chill-ymintime:--]'; 

$ws['tempAct']		= wsConvertTemperature('[t1temp-act.1:--]', 	$from);  // convert and clean of units
$ws['tempActInside']	= wsConvertTemperature('[thb0temp-act.1:--]', 	$from);
$ws['tempActExtra1']	= wsConvertTemperature('[t1temp-act.1:--]', 	$from);	
if ('[t1temp-val60.1:--]' <> '--') {
	$ws['tempDelta']= '[t1temp-act.1:--]' - '[t1temp-val60.1:--]';
} else {
	$ws['tempDelta'] = 0;
}
$ws['tempMinToday']	= wsConvertTemperature('[t1temp-dmin.1:--]', 	$from);
$ws['tempMinYday']	= wsConvertTemperature('[t1temp-ydmin.1:--]',	$from);
$ws['tempMinMonth']	= wsConvertTemperature('[t1temp-mmin.1:--]',	$from);
$ws['tempMinYear']	= wsConvertTemperature('[t1temp-ymin.1:--]',	$from);
$ws['tempMaxToday']	= wsConvertTemperature('[t1temp-dmax.1:--]',	$from);
$ws['tempMaxYday']	= wsConvertTemperature('[t1temp-ydmax.1:--]',	$from);
$ws['tempMaxMonth']	= wsConvertTemperature('[t1temp-mmax.1:--]',	$from);
$ws['tempMaxYear']	= wsConvertTemperature('[t1temp-ymax.1:--]',	$from);

$ws['dewpAct']  	= wsConvertTemperature('[th0dew-act.1:0]',$from);
if ('[th0dew-val60.1:--]' <> '--') {
	$ws['dewpDelta']= '[th0dew-act.1:0]' - '[th0dew-val60.1:0]';
} else {
	$ws['dewpDelta'] = 0;
}
$ws['dewpMinToday']  	= wsConvertTemperature('[th0dew-dmin.1:0]',$from);
$ws['dewpMinYday']  	= wsConvertTemperature('[th0dew-ydmin.1:0]',$from);
$ws['dewpMaxToday']  	= wsConvertTemperature('[th0dew-dmax.1:0]',$from);
$ws['dewpMaxYday']  	= wsConvertTemperature('[th0dew-ydmax.1:0]',$from);
	
$ws['chilAct']		= wsConvertTemperature('[wind0chill-act.1:0]',$from);
$ws['chilDelta']	= '[wind0chill-act.1:0]' - '[wind0chill-val60.1:0]';
$ws['chilMinToday']	= wsConvertTemperature('[wind0chill-dmin.1:0]',$from);
$ws['chilMinYday']	= wsConvertTemperature('[wind0chill-ydmin.1:0]',$from);
$ws['chilMinMonth']	= wsConvertTemperature('[wind0chill-mmin.1:0]',$from);
$ws['chilMinYear']	= wsConvertTemperature('[wind0chill-ymin.1:0]',$from);

$ws['heatAct']		= $ws['tempAct'];
# ------------------------------------------ pressure / baro -----------
$to 	= $SITE['uomBaro'];
$from	= 'hPa';

$ws['baroMinTodayTime']	= '[thb0seapress-dmintime:--]';
$ws['baroMinYdayTime']	= '[thb0seapress-ydmintime:--]';
$ws['baroMinMonthTime']	= '[thb0seapress-mmintime:--]';
$ws['baroMinYearTime']	= '[thb0seapress-ymintime:--]';
$ws['baroMaxTodayTime']	= '[thb0seapress-dmaxtime:--]';
$ws['baroMaxYdayTime']	= '[thb0seapress-ydmaxtime:--]';
$ws['baroMaxMonthTime']	= '[thb0seapress-mmaxtime:--]';
$ws['baroMaxYearTime']	= '[thb0seapress-ymaxtime:--]';

$ws['baroAct'] 		= wsConvertBaro('[thb0seapress-act.1:0]',$from);
if ('[thb0seapress-val60.1:--]' <> '--') {
	$ws['baroDelta']= wsConvertBaro('[thb0seapress-act.1:0]' - '[thb0seapress-val60.1:0]',$from);
} else {
	$ws['baroDelta'] = 0;
}
$ws['baroMinToday']	= wsConvertBaro('[thb0seapress-dmin.1:0]',$from);
$ws['baroMinYday']	= wsConvertBaro('[thb0seapress-ydmin.1:0]',$from);
$ws['baroMinMonth']	= wsConvertBaro('[thb0seapress-mmin.1:0]',$from);
$ws['baroMinYear'] 	= wsConvertBaro('[thb0seapress-ymin.1:0]',$from);	
$ws['baroMaxToday']	= wsConvertBaro('[thb0seapress-dmax.1:0]',$from);
$ws['baroMaxYday']	= wsConvertBaro('[thb0seapress-ydmax.1:0]',$from);
$ws['baroMaxMonth']	= wsConvertBaro('[thb0seapress-mmax.1:0]',$from);
$ws['baroMaxYear'] 	= wsConvertBaro('[thb0seapress-ymax.1:0]',$from);

# ------------------------------------------ humidity  -----------------------------------
$ws['humiMinTodayTime ']= '[th0hum-dmintime:--]';
$ws['humiMinYdayTime ']	= '[th0hum-ydmintime:--]';   
$ws['humiMaxTodayTime'] = '[th0hum-dmaxtime.:--]';
$ws['humiMaxYdayTime'] 	= '[th0hum-ydmaxtime:--]';   

$ws['humiAct']		= '[th0hum-act.0:0]';
$ws['humiExtra']	= 'SENSORHUMEXTRA';
if ('[th0hum-val60.0:--]' <> '--') {
	$ws['humiDelta']= $ws['humiAct'] - '[th0hum-val60.0:0]';
} else {
	$ws['humiDelta'] = 0;
}
$ws['humiMinToday'] 	= '[th0hum-dmin.0:0]';
$ws['humiMinYday'] 	= '[th0hum-ydmin.0:0]';
$ws['humiMaxToday']	= '[th0hum-dmax.0:0]';
$ws['humiMaxYday']	= '[th0hum-ydmax.0:0]';

# ------------------------------------------ rain  ---------------------
$to 	= $SITE['uomRain'];
$from	= 'mm'; 

$ws['rainRateAct'] 	= wsConvertRainfall('[rain0total-act.1:0]',$from);
$ws['rainRateToday'] 	= wsConvertRainfall('[rain0rate-dmax.1:0]',$from);		
$ws['rainHour']		= wsConvertRainfall('[rain0total-sum60.1:0]',$from);
$ws['rainToday']	= wsConvertRainfall('[rain0total-dmax.1:0]',$from);
$ws['rainYday']		= wsConvertRainfall('[rain0total-ydaysum.1:0]',$from);
$ws['rainMonth']	= wsConvertRainfall('[rain0total-monthsum.1:0]',$from);
$ws['rainYear']		= wsConvertRainfall('[rain0total-yearsum.1:0]',$from);
#$ws['rainDaysWithNo']	= 'dayswithnorain';
#$ws['rainWeek'] 	= wsConvertRainfall('raincurrentweek',$from);
# ------------------------ ev test -------------------------------------
$ws['solEvoAct']	= wsConvertRainfall('[sol0evo-act.1:--]',$from); 
$ws['etToday']		= wsConvertRainfall('[sol0evo-dmax:1:--]',$from);
$ws['etYday']		= wsConvertRainfall('[sol0evo-ydmax:1:--]',$from);
$ws['etMonth']		= wsConvertRainfall('[sol0evo-mmax:1:--]',$from);
$ws['etYear']		= wsConvertRainfall('[sol0evo-ymax:1:--]',$from);
# ------------------------------------------ wind  ---------------------
$to 	= $SITE['uomWind'];
$from	= 'kmh'; 	
# meteobridge default = m/s  But most users want kmh so let meteobridge do the conversion 
#
$ws['windActDsc']	= wsConvertWinddir ('[wind0dir-act.0:--]'); // degrees to label
$ws['windBeafort']	= wsBeaufortNumber ('[wind0wind-act=kmh.1:0]',$from);
$ws['gustMaxTodayTime']	= '[wind0wind-dmaxtime:--]';
$ws['gustMaxYdayTime']	= '[wind0wind-ydmaxtime:--]';
$ws['gustMaxMonthTime']	= '[wind0wind-mmaxtime:--]';
$ws['gustMaxYearTime']	= '[wind0wind-ymaxtime:--]';

$ws['windAct']		= wsConvertWindspeed('[wind0wind-act=kmh.1:0]',$from);
$ws['gustAct']		= 0;
$ws['gustMaxHour']	= wsConvertWindspeed('[wind0wind-hmax=kmh.1:0]',$from);	
$ws['gustMaxToday']	= wsConvertWindspeed('[wind0wind-dmax=kmh.1:0]',$from);
$ws['gustMaxYday']	= wsConvertWindspeed('[wind0wind-ydmax=kmh.1:0]',$from); 
$ws['gustMaxMonth']	= wsConvertWindspeed('[wind0wind-mmax=kmh.1:0]',$from);
$ws['gustMaxYear']	= wsConvertWindspeed('[wind0wind-ymax=kmh.1:0]',$from);	

if ($ws['gustAct'] <= $ws['windAct'])	{$ws['gustAct'] = $ws['windAct'];}
# ------------------------------------------  UV   ---------------------
$ws['uvMaxTodayTime'] 	= '[uv0index-dmaxtime:--]';
$ws['uvMaxYdayTime'] 	= '[uv0index-ydmaxtime:--]';
$ws['uvMaxMonthTime'] 	= '[uv0index-mmaxtime:--]';
$ws['uvMaxYearTime'] 	= '[uv0index-ymaxtime:--]';

$ws['uvAct']		= '[uv0index-act.1:0]';
$ws['uvMaxToday']	= '[uv0index-dmax.1:0]';
$ws['uvMaxYday']	= '[uv0index-ydmax.1:0]';
$ws['uvMaxMonth']	= '[uv0index-mmax.1:0]';
$ws['uvMaxYear']	= '[uv0index-ymax.1:0]';
# ------------------------------------------ Solar  --------------------
$ws['solarMaxTodayTime']= '[sol0rad-dmaxtime:--]';
$ws['solarMaxYdayTime'] = '[sol0rad-ydmaxtime:--]';
$ws['solarMaxMonthTime']= '[sol0rad-mmaxtime:--]';
$ws['solarMaxYearTime'] = '[sol0rad-ymaxtime:--]';

$ws['solarAct']		= '[sol0rad-act.0:0]';
#$ws['solActPerc']	= 'currentsolarpctplain';
$ws['solarMaxToday']	= '[sol0rad-dmax:0]';
$ws['solarMaxYday']	= '[sol0rad-ydmax:0]';
$ws['solarMaxMonth']	= '[sol0rad-mmax:0]';
$ws['solarMaxYear']	= '[sol0rad-ymax:0]';
# ------------------------------------------ forecasts -----------------
$ws['fcstRule'] 	= '[forecast-rule]';
$ws['fcstTxt'] 	  	= '[forecast-text]';
# ------------------------------------------ sun and moon --------------
$ws['sunrise']		= '[mbsystem-sunrise]';
$ws['sunset']		= '[mbsystem-sunset]';
$ws['moonrise']		= '[mbsystem-moonrise:<00:00]';
$ws['moonset']		= '[mbsystem-moonset:>00:00]';
$ws['lunarPhasePerc']	= '[mbsystem-lunarpercent]';
$ws['lunarAge']		= '[mbsystem-lunarage]';
# ------------------------------------------ some more -----------------
$ws['wsDashboardDec']	= '[mbsystem-graphA]';
$ws['wsDashboardImp']	= '[mbsystem-graphB]';
$ws['wsPhoneDec']	= '[mbsystem-graphC]';
$ws['wsPhoneImp']	= '[mbsystem-graphD]';
$ws['wsPhoneGr1Dec']	= '[mbsystem-graphE]';
$ws['wsPhoneGr1Imp']	= '[mbsystem-graphF]';
$ws['wsPhoneGr2Dec']	= '[mbsystem-graphG]';
$ws['wsPhoneGr2Imp']	= '[mbsystem-graphH]';
$ws['wsVersion']	= '[mbsystem-swversion] b [mbsystem-buildnum]';
$ws['wsHardware'] 	= '[mbsystem-platform]'; 
$ws['wsUptime']		= '0';

# -------------------------------------- trends ------------------------

if (!isset ($wsTrends)){$wsTrends = array() ;}
$wsTrends[0] ['min']	= 0;
$wsTrends[1] ['min']	= 5;
$wsTrends[2] ['min']	= 10;
$wsTrends[3] ['min']	= 15;
$wsTrends[4] ['min']	= 30;
$wsTrends[5] ['min']	= 60;

$to 	= $SITE['uomTemp'];
$from	= 'C'; 
$wsTrends[0] ['temp']	= $ws['tempAct'];
$wsTrends[0] ['dew']	= $ws['dewpAct'];
$wsTrends[1] ['temp']	= wsConvertTemperature('[t1temp-val5.1:0]',$from);
$wsTrends[1] ['dew']	= wsConvertTemperature('[th0dew-val5.1:0]',$from);
$wsTrends[2] ['temp']	= wsConvertTemperature('[t1temp-val10.1:0]',$from);
$wsTrends[2] ['dew']	= wsConvertTemperature('[th0dew-val10.1:0]',$from);
$wsTrends[3] ['temp']	= wsConvertTemperature('[t1temp-val15.1:0]',$from);
$wsTrends[3] ['dew']	= wsConvertTemperature('[th0dew-val15.1:0]',$from);
$wsTrends[4] ['temp']	= wsConvertTemperature('[t1temp-val30.1:0]',$from);
$wsTrends[4] ['dew']	= wsConvertTemperature('[th0dew-val30.1:0]',$from);
$wsTrends[5] ['temp']	= wsConvertTemperature('[t1temp-val60.1:0]',$from);
$wsTrends[5] ['dew']	= wsConvertTemperature('[th0dew-val60.1:0]',$from);

$to 	= $SITE['uomWind'];
$from	= 'kmh'; 	
$wsTrends[0] ['wind']	= $ws['windAct'];
$wsTrends[0] ['gust']	= $ws['windAct'];
$wsTrends[1] ['wind']	= wsConvertWindspeed('[wind0wind-val5=kmh.1:0]',  $from);
$wsTrends[1] ['gust']	= wsConvertWindspeed('[wind0wind-val5=kmh.1:0]',  $from);
$wsTrends[2] ['wind']	= wsConvertWindspeed('[wind0wind-val10=kmh.1:0]',$from);
$wsTrends[2] ['gust']	= wsConvertWindspeed('[wind0wind-val10=kmh.1:0]',$from);
$wsTrends[3] ['wind']	= wsConvertWindspeed('[wind0wind-val15=kmh.1:0]',$from);
$wsTrends[3] ['gust']	= wsConvertWindspeed('[wind0wind-val15=kmh.1:0]',$from);
$wsTrends[4] ['wind']	= wsConvertWindspeed('[wind0wind-val30=kmh.1:0]',$from);
$wsTrends[4] ['gust']	= wsConvertWindspeed('[wind0wind-val30=kmh.1:0]',$from);
$wsTrends[5] ['wind']	= wsConvertWindspeed('[wind0wind-val60=kmh.1:0]',$from);
$wsTrends[5] ['gust']	= wsConvertWindspeed('[wind0wind-val60=kmh.1:0]',$from);

$to 	= $SITE['uomBaro'];
$from	= 'hPa'; 
$wsTrends[0] ['baro']	= $ws['baroAct'];
$wsTrends[1] ['baro']	= wsConvertBaro('[thb0seapress-val5.1:0]',$from);
$wsTrends[2] ['baro']	= wsConvertBaro('[thb0seapress-val10.1:0]',$from);
$wsTrends[3] ['baro']	= wsConvertBaro('[thb0seapress-val15.1:0]',$from);
$wsTrends[4] ['baro']	= wsConvertBaro('[thb0seapress-val30.1:0]',$from);
$wsTrends[5] ['baro']	= wsConvertBaro('[thb0seapress-val60.1:0]',$from);

$to 	= $SITE['uomRain'];
$from	= 'mm';
$wsTrends[0] ['rain']	= wsConvertRainfall('[rain0rate-val1.1:0]',$from);
$wsTrends[1] ['rain']	= wsConvertRainfall('[rain0rate-val5.1:0]',$from);
$wsTrends[2] ['rain']	= wsConvertRainfall('[rain0rate-val10.1:0]',$from);
$wsTrends[3] ['rain']	= wsConvertRainfall('[rain0rate-val15.1:0]',$from);
$wsTrends[4] ['rain']	= wsConvertRainfall('[rain0rate-val30.1:0]',$from);
$wsTrends[5] ['rain']	= wsConvertRainfall('[rain0rate-val60.1:0]',$from);

$wsTrends[0] ['dir']	= $ws['windActDsc'];
$wsTrends[0] ['hum']	= $ws['humiAct'];
$wsTrends[0] ['sol']	= $ws['solarAct'];
$wsTrends[0] ['uv']	= $ws['uvAct'];
$wsTrends[1] ['dir']	= wsConvertWinddir ('[wind0dir-val5.0:--]');
$wsTrends[1] ['hum']	= '[th0hum-val5.0:0]';
$wsTrends[1] ['sol']	= '[sol0rad-val5.0:0]';
$wsTrends[1] ['uv']	= '[uv0index-val5.1:0]';
$wsTrends[2] ['dir']	= wsConvertWinddir ('[wind0dir-val10.0:--]');
$wsTrends[2] ['hum']	= '[th0hum-val10.0:0]';
$wsTrends[2] ['sol']	= '[sol0rad-val10.0:0]';
$wsTrends[2] ['uv']	= '[uv0index-val10.1:0]';
$wsTrends[3] ['dir']	= wsConvertWinddir ('[wind0dir-val15.0:--]');
$wsTrends[3] ['hum']	= '[th0hum-val15.0:0]';
$wsTrends[3] ['sol']	= '[sol0rad-val15.0:0]';
$wsTrends[3] ['uv']	= '[uv0index-val15.1:0]';
$wsTrends[4] ['dir']	= wsConvertWinddir ('[wind0dir-val30.0:--]');
$wsTrends[4] ['hum']	= '[th0hum-val30.0:0]';
$wsTrends[4] ['sol']	= '[sol0rad-val30.0:0]';
$wsTrends[4] ['uv']	= '[uv0index-val30.1:0]';
$wsTrends[5] ['dir']	= wsConvertWinddir ('[wind0dir-val60.0:--]');
$wsTrends[5] ['hum']	= '[th0hum-val60.0:0]';
$wsTrends[5] ['sol']	= '[sol0rad-val60.0:0]';
$wsTrends[5] ['uv']	= '[uv0index-val60.1:0]';
#
$ws['check_ok']         = '3.00';
// end of tags.txt/tags.php
?>
