<?php 
    #######################################################
	#	CREATED FOR Meteobridge Aurora MKII TEMPLATE 		     
	# 		Soil Temperature
	# 	Release:April 30th 2025
	# 	                 
	#   Brian Underdown    
	######################################################
include('livedata.php');



//ICON COLOR


if ($weather["soiltemp"]  <=5 ){$soiltempcolor= " hsl(201, 79%, 47%)";}
else if ($weather["soiltemp"]  <=10 ){$soiltempcolor= "hsl(74, 60%, 46%)";}
else if ($weather["soiltemp"]  <=18){$soiltempcolor= "hsl(35, 77%, 58%)";}
else if ($weather["soiltemp"]  <=20 ){$soiltempcolor= "hsl(34, 98%, 49%)";}
else if ($weather["soiltemp"]  <=27 ){$soiltempcolor= "hsl(19, 66%, 55%)";}
else if ($weather["soiltemp"]  <=35 ){$soiltempcolor= "hsl(12, 80%, 52%)";}
else if ($weather["soiltemp"]  <=50 ){$soiltempcolor= "hsl(2, 56%, 55%)";}


;

//Soil Leaf Icon
$soilleaficon="<?xml version='1.0' encoding='utf-8'?>
<svg fill='green' width='60px' height='60px' viewBox='0 0 32 32' id='Layer_1' data-name='Layer 1' 
xmlns='http://www.w3.org/2000/svg'>
  <defs>
    <style>
      .cls-1 {
        fill: none;
      }
    </style>
  </defs>
  
  <path d='M11,16V11h1a4.0045,4.0045,0,0,0,4-4V4H13a3.9779,3.9779,0,0,0-2.7468,1.1067A6.0034,6.0034,0,0,0,5,2H2V5a6.0066,
  6.0066,0,0,0,6,6H9v5H2v2H16V16ZM13,6h1V7a2.002,2.002,0,0,1-2,2H11V8A2.002,2.002,0,0,1,13,6ZM8,9A4.0045,4.0045,0,0,1,4,
  5V4H5A4.0045,4.0045,0,0,1,9,8V9Z' transform='translate(0 0)'/>
  <rect x='2' y='21' width='14' height='2'/>
  <rect x='2' y='26' width='14' height='2'/>;
  </svg>";



//soil temperature icon svg
$soiltemperatureicon="<svg enable-background='new 0 0 128 128' viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg' width=40pt>
<path d='M76,80.34V16.29C76,9.77,70.82,4,64.3,4h-1.55C56.24,4,51,9.77,51,16.29v64.04 c-7,4.2-11.24,11.68-11.24,20.2c0,13.14,10.64,23.8,23.79,23.8s23.74-10.65,23.74-23.8
C87.28,92.01,83,84.54,76,80.34z' fill='none' stroke='#717F8C' stroke-width='2'/>

<linearGradient id='a' x1='67.014' x2='63.285' y1='38.588' y2='104.92' gradientUnits='userSpaceOnUse'>
<stop stop-color='$soiltempcolor' offset='.5974'/>
<stop stop-color='var(--darkblue)' offset='1'/></linearGradient>
<path d='m69.92 85.89v-62.07c0-3.53-2.86-6.39-6.39-6.39s-6.39 2.86-6.39 6.39v62.08
c-5.82 2.54-9.83 8.44-9.58 15.25 0.3 8.19 6.99 14.96 15.18 15.36 9.19 0.44 16.78-6.87 16.78-15.96-0.01-6.57-3.95-12.19-9.6-14.66z' fill='url(#a)'/>

<path stroke='#717F8C' stroke-width='2' d='m62.87 39.76h-11.92v-6.39h11.92c1.66 0 3 1.34 3 3v0.39c0 1.66-1.34 3-3 3z' fill='none'/>
<path stroke='#717F8C' stroke-width='2' d='m62.87 58.32h-11.92v-6.39h11.92c1.66 0 3 1.34 3 3v0.39c0 1.65-1.34 3-3 3z' fill='none'/>
<path stroke='#717F8C' stroke-width='2' d='m62.87 76.88h-11.92v-6.39h11.92c1.66 0 3 1.34 3 3v0.39c0 1.65-1.34 3-3 3z' fill='none'/>
</svg>";
  

?>




<style>
.module {display: grid; 
position: absolute;
font-size:14px;
font-family:verb;
color: var(--body-text-dark);
}

.indoorenvirocaution{position:absolute;
font-size:10px;
font-family:verb;
color: var(--body-text-dark);
display: inline;
margin-left:-110px;
margin-top:-40px;
background:var(--hilomodule);
width: max-content;
max-width:150px; 
padding:4px;
border-radius: 5px;opacity:.8


}


.indoorenvirovalue{
    position: absolute;
    font-size:38px;
    font-family:verb;
    background:var(--hilomodule);
    width:max-content;
    height:max-content;
 margin-left:-100px;
border-radius: 5px;
 margin-top:-80px;
 display: block;
 padding-right:3px;
 padding-left:5px;
 padding-bottom:5px;
 color:var(--body-text-dark);opacity:.8

}


.indoorenvirodescription{
position: absolute;
font-size:10px;
font-family:verb;
background:var(--hilomodule);
width:180px;
margin-left:-110px;
border-radius: 5px;
margin-top:-10px;
display: block;
padding:3px;
color:var(--body-text-dark);opacity:.9

}


.indoorenvirodescription span{
    color:<?php echo $feelindoorcolor;?>;}

.indoorenvirovalue span2{
font-size:10px;
display: block;


}

.leaficon{position: absolute;
margin-left:40px;
margin-top:-80px}

.soiltempicon{position: absolute;
margin-left:70px;
margin-top:-75px}


.charticonindoor { position: absolute;
font-size:11px;
font-family:verb;
background:none;
width:auto;
margin-left:90px;
border-radius: 5px;
margin-top:20px;
display: block;
padding-right:3px;
color:var(--body-text-dark);
z-index:10;}

.sensorINDcaption{position: absolute;
 margin-left:30px;
 margin-top:-92px;
 font-size:9px;
 color:var(--body-text-dark);
 opacity: 0.64;
 width:max-content;
 font-family:verb;
 }


</style>

<div class=module>
<div class=sensorINDcaption>Soil Temperature </div>
<div class="indoorenvirovalue"><?php 
//forecast indoor temperature
echo " ".(anytoC($weather["soiltemp"],1))."&deg;";
?>


<span2>
<?php //trend
if($weather["soiltemp_trend"]  >0){echo " Rising ".$risingtabletsmall;}
else if($weather["soiltemp_trend"] <0){echo "Falling ".$fallingtabletsmall;}
//steady
else echo "Steady ".$steadytabletsmall;?>


</span2>
</div>


<div class=leaficon>
<?php //icon leaf
echo $soilleaficon;
?>
</div>

<div class=soiltempicon>
<?php //icon temperature soil
echo $soiltemperatureicon;
?>
</div>



<div class="indoorenvirodescription"> 

<?php echo "Last 24 hours Avg: ";
if ($weather["soiltemp_davg"]    >= 30) {
    echo '<blue>' . (anytoC($weather["soiltemp_davg"],1))    . '</blue>';
} else if ($weather["soiltemp_dmax"]    >= 10) {
    echo '<yellow>' . ((anytoC($weather["soiltemp_davg"],1)))   . '</yellow>';;
} elseif ($weather["soiltemp_davg"]    >= 5) {
    echo '<green>' . ((anytoC($weather["soiltemp_davg"],1)))    . '</green>';
} elseif ($weather["soiltemp_dmax"]    >= -50) {
    echo '<blue>' . ((anytoC($weather["soiltemp_davg"],1))) . '</blue>';
}
echo "<smallunittablet3>&deg;</smallunittablet3>"  ."
<br> ";





echo date('D jS'); echo " Hi: "; 
//soil max day temp
if ($weather["soiltemp_dmax"]    >= 30) {
    echo '<blue>' . ((anytoC($weather["soiltemp_dmax"],1)))   . '</blue>';
} else if ($weather["soiltemp_dmax"]    >= 10) {
    echo '<yellow>' . ((anytoC($weather["soiltemp_dmax"],1)))    . '</yellow>';;
} elseif ($weather["soiltemp_dmax"]    >= 5) {
    echo '<green>' . ((anytoC($weather["soiltemp_dmax"],1)))   . '</green>';
} elseif ($weather["soiltemp_dmax"]    >= -50) {
    echo '<blue>' . ((anytoC($weather["soiltemp_dmax"],1))). '</blue>';
}
echo "<smallunittablet3>&deg;</smallunittablet3>" ;
echo " @". $weather["soiltemp_dmaxtime"] ."
<br> ";




echo date('D jS'); echo " Lo: "; 
//soil low day temp
if ($weather["soiltemp_dmin"]  >= 30) {
    echo '<blue>' .((anytoC($weather["soiltemp_dmin"],1)))  . '</blue>';
} else if ($weather["soiltemp_dmin"]  >= 10) {
    echo '<yellow>' .((anytoC($weather["soiltemp_dmin"],1)))  . '</yellow>';;
} elseif ($weather["soiltemp_dmin"]  >= 5) {
    echo '<green>' .((anytoC($weather["soiltemp_dmin"],1)))  . '</green>';
} elseif ($weather["soiltemp_dmin"]  >= -50) {
    echo '<blue>' .((anytoC($weather["soiltemp_dmin"],1)))  . '</blue>';
}

echo "<smallunittablet3>&deg;</smallunittablet3>" ;
echo " @". $weather["soiltemp_dmintime"] ."
<br> ";
?>
</div>

<div class=charticonindoor> 
<a href="soil-almanac2.php" data-lity data-chartdata="Chart Data">
<?php echo $weather34chartzoomtabletfull;?></a>
</div></div>