<?php
if (!isset($SITE)){
	header ("Location: ../index.php")  ;	// back to index/startpage if someone tries an
	exit;  									//  page to load without menu system//
}
$pageName		= 'tags.php';
$pageVersion	= '2.30 2013-11-11 17:19:31 ';
$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;
# ----------------------------------------------------------------------------------------
# version 2.40 2013-11-11
# --------------------------------------- version ----------------------------------------
$ws['tags.php']	= $pageName.'-'.$pageVersion;
# --------------------------------------- conditions--------------------------------------
$ws['actTime']		= '[YYYY][MM][DD][hh][mm][ss]'; // '20120523113945';
# ------------------------------------------ temperature ---------------------------------
$to 	= $SITE['uomTemp'];
$from	= 'C'; 		//  = 'C', 'F',  (or  'C', 'F', or '&deg;C', '&deg;F' )

$ws['tempMinTodayTime']	= '[th0temp-dmintime:--]';
$ws['tempMinYdayTime']	= '[th0temp-ydmintime:--]';
$ws['tempMinMonthTime']	= '[th0temp-mmintime:--]';
$ws['tempMinYearTime']	= '[th0temp-ymintime:--]';
$ws['tempMaxTodayTime']	= '[th0temp-dmaxtime:--]'; 
$ws['tempMaxYdayTime']	= '[th0temp-ydmaxtime:--]';
$ws['tempMaxMonthTime']	= '[th0temp-mmaxtime:--]';
$ws['tempMaxYearTime']	= '[th0temp-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:--]'; // yday
$ws['chilMinMonthTime'] = '[wind0chill-mmintime:--]';
$ws['chilMinYearTime']	= '[wind0chill-ymintime:--]'; 

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

$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'; 		//  = 'mm', 'in'

$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);

# ------------------------------------------ wind  ---------------------------------------
$to 	= $SITE['uomWind'];
$from	= 'kmh'; 		// 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-avg10=kmh.1:0]',$from);
$ws['gustMaxTodayTime']	= '[wind0wind-dmaxtime:--]';
$ws['gustMaxYdayTime']	= '[wind0wind-ydmaxtime:--]';
$ws['gustMaxMonthTime']	= '[wind0wind-mmaxtime:--]';
$ws['gustMaxYearTime']	= '[wind0wind-ymaxtime:--]';

$ws['windAct']			= wsConvertWindspeed('[wind0wind-avg10=kmh.1:0]',$from);
$ws['gustAct']			= wsConvertWindspeed('[wind0wind-max10=kmh.1:0]',$from);
$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]';
# ----- ev test
$ws['solEvoAct']		= '[sol0evo-act.1:--]'; // sol0evo
$ws['etToday']			= '[sol0evo-dmax:1:--]';
$ws['etYday']			= '[sol0evo-ydmax:1:--]';
$ws['etMonth']			= '[sol0evo-mmax:1:--]';
$ws['etYear']			= '[sol0evo-ymax:1:--]';
# ------------------------------------------ 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['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('[th0temp-val5.1:0]',$from);
$wsTrends[1] ['dew']	= wsConvertTemperature('[th0dew-val5.1:0]',$from);
$wsTrends[2] ['temp']	= wsConvertTemperature('[th0temp-val10.1:0]',$from);
$wsTrends[2] ['dew']	= wsConvertTemperature('[th0dew-val10.1:0]',$from);
$wsTrends[3] ['temp']	= wsConvertTemperature('[th0temp-val15.1:0]',$from);
$wsTrends[3] ['dew']	= wsConvertTemperature('[th0dew-val15.1:0]',$from);
$wsTrends[4] ['temp']	= wsConvertTemperature('[th0temp-val30.1:0]',$from);
$wsTrends[4] ['dew']	= wsConvertTemperature('[th0dew-val30.1:0]',$from);
$wsTrends[5] ['temp']	= wsConvertTemperature('[th0temp-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]';

?>
