PHP-Code:
/*EINMAL DIE FUNKTION*/
function Write2Influx($id, $host, $db, $system, $category, $valuename)
{
$out ='http://'.$host.':8086/write?db='.$db.'';
$ch = curl_init($out);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST, 1 );
$vartype = IPS_GetVariableCompatibility($id)['VariableType'];
/*0: Boolean, 1: Integer, 2: Float, 3: String*/
//echo $vartype.' ';
switch ($vartype){
case 0:
$value = GetValueBoolean($id) ;
if ($value == true){
curl_setopt($ch, CURLOPT_POSTFIELDS, $system.','.$category.'='.$valuename.' value=1');
}
else{
curl_setopt($ch, CURLOPT_POSTFIELDS, $system.','.$category.'='.$valuename.' value=0');
}
//echo 'es war ein bool ';
break;
case 1:
$value = GetValueInteger($id) ;
curl_setopt($ch, CURLOPT_POSTFIELDS, $system.','.$category.'='.$valuename.' value=' .$value);
break;
case 2:
$value = GetValueFloat($id) ;
curl_setopt($ch, CURLOPT_POSTFIELDS, $system.','.$category.'='.$valuename.' value=' . number_format($value/1,1,'.','') );
//echo 'es war ein float ';
break;
}
$result=curl_exec ($ch);
$error=curl_error($ch) ;
echo $result ;
echo $error ;
//echo $system.','.$category.'='.$valuename.' value=' . number_format($floatvalue/1,1,'.','');
}
/*AB HIER ERST KOPIEREN*/
$host = '10.0.1.24';
Write2Influx(10695, $host, 'werte', 'ipsymcon', 'Temperatur', 'IST-Temperatur');
Write2Influx(50044, $host, 'werte', 'ipsymcon', 'Luftfeuchte', 'IST-Luftfeuchte');
Write2Influx(53070, $host, 'werte', 'ipsymcon', 'Temperatur', 'IST-Temperatur');
Write2Influx(19797, $host, 'werte', 'ipsymcon', 'Luftfeuchte', 'IST-Luftfeuchte');
Write2Influx(56294, $host, 'werte', 'ipsymcon', 'Temperatur', 'IST-Temperatur');
Write2Influx(47829, $host, 'werte', 'ipsymcon', 'Luftfeuchte', 'IST-Luftfeuchte');
Write2Influx(12143, $host, 'werte', 'ipsymcon', 'Temperatur', 'IST-Temperatur');
Write2Influx(22893, $host, 'werte', 'ipsymcon', 'Luftfeuchte', 'IST-Luftfeuchte');
Write2Influx(12247, $host, 'werte', 'ipsymcon', 'Temperatur', 'SOLL-Temperatur');
Write2Influx(52811, $host, 'werte', 'ipsymcon', 'Status', 'Status');
Write2Influx(34666, $host, 'werte', 'ipsymcon', 'Temperatur', 'IST-Temperatur');
Write2Influx(40842, $host, 'werte', 'ipsymcon', 'Luftfeuchte', 'IST-Luftfeuchte');
Write2Influx(37620, $host, 'werte', 'ipsymcon', 'Temperatur', 'SOLL-Temperatur');
Write2Influx(50860, $host, 'werte', 'ipsymcon', 'Status', 'Status');
Write2Influx(16676, $host, 'werte', 'ipsymcon', 'Temperatur', 'IST-Temperatur');
Write2Influx(57978, $host, 'werte', 'ipsymcon', 'Luftfeuchte', 'IST-Luftfeuchte');
Write2Influx(31603, $host, 'werte', 'ipsymcon', 'Temperatur', 'SOLL-Temperatur');
Write2Influx(55703, $host, 'werte', 'ipsymcon', 'Status', 'Status');
Write2Influx(31931, $host, 'werte', 'ipsymcon', 'Temperatur', 'IST-Temperatur');
Write2Influx(29130, $host, 'werte', 'ipsymcon', 'Luftfeuchte', 'IST-Luftfeuchte');
Write2Influx(10849, $host, 'werte', 'ipsymcon', 'Temperatur', 'SOLL-Temperatur');
Write2Influx(47549, $host, 'werte', 'ipsymcon', 'Status', 'Status');
Write2Influx(44422, $host, 'werte', 'ipsymcon', 'Temperatur', 'IST-Temperatur');
Write2Influx(24858, $host, 'werte', 'ipsymcon', 'Luftfeuchte', 'IST-Luftfeuchte');
Write2Influx(13938, $host, 'werte', 'ipsymcon', 'Temperatur', 'SOLL-Temperatur');
Write2Influx(58295, $host, 'werte', 'ipsymcon', 'Status', 'Status');
Write2Influx(12918, $host, 'werte', 'ipsymcon', 'Temperatur', 'IST-Temperatur');
Write2Influx(11380, $host, 'werte', 'ipsymcon', 'Luftfeuchte', 'IST-Luftfeuchte');
Write2Influx(25033, $host, 'werte', 'ipsymcon', 'Temperatur', 'SOLL-Temperatur');
Write2Influx(18779, $host, 'werte', 'ipsymcon', 'Status', 'Status');
Write2Influx(26844, $host, 'werte', 'ipsymcon', 'Status', 'Status');