Here is some code I have put together in order to receive basic info from an Viessmann boiler. The code represents an improvement from a former post here on the forum and thus it has been highlighted as version 0.2. Only HTML and PHP. it is used. In order to work you will have first to receive the following variables: $autorizationTOKEN $installationId $gatewaySerial $deviceId For this preliminary steps, documentation is available here: https://developer.viessmann.com/en/doc/getting-started and with more details, after you login, here: https://developer.viessmann.com/en/doc/authentication Also you can take a lock at this post: https://www.viessmann-community.com/t5/Getting-started-programming-with/To-help-get-started/td-p/181... As soon as the above requirements are fulfilled here is the code: <html>
<title>Viessmann</title>
<body>
<?php
//Get all boiler features
//$getURL='https://api.viessmann.com/iot/v1/equipment/installations/'.$installationId.'/gateways/'.$gatewaySerial.'/devices/'.$deviceId.'/features';
//Get all boiler features required by the present project
$getURL='https://api.viessmann.com/iot/v1/equipment/installations/'.$installationId.'/gateways/'.$gatewaySerial.'/devices/'.$deviceId.'/features?regex='
.'heating.burners.0'.'%7C'
.'heating.burners.0.statistics'.'%7C'
.'heating.boiler.sensors.temperature.commonSupply'.'%7C'
.'heating.dhw.temperature.main'.'%7C'
.'heating.dhw.sensors.temperature.hotWaterStorage'.'%7C'
.'heating.circuits.0.operating.programs.normal'.'%7C'
.'heating.circuits.0.sensors.temperature.room';
$headerRequest = array(
"Content-Type: application/x-www-form-urlencoded",
"Authorization: Bearer $autorizationTOKEN"
);
$cURLConnection = curl_init();
curl_setopt($cURLConnection, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 7.01; Windows NT 5.0)");
curl_setopt($cURLConnection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($cURLConnection, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($cURLConnection, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER,true);
curl_setopt($cURLConnection, CURLOPT_HTTPHEADER, $headerRequest);
curl_setopt($cURLConnection, CURLOPT_CONNECTTIMEOUT, 130);
curl_setopt($cURLConnection, CURLOPT_TIMEOUT, 130);
curl_setopt($cURLConnection, CURLOPT_URL,$getURL);
$apiResponse = curl_exec($cURLConnection);
$apiErr = curl_error($cURLConnection);
curl_close($cURLConnection);
$jsonResponse = json_decode($apiResponse, true);
usort($jsonResponse['data'], function($a,$b){
return $a["feature"]>$b["feature"];
});
//echo "<br><br><br>";
//print_r($jsonResponse);
//print_r($apiErr);
//echo "<br><br><br>";
$BurnerStatus = $jsonResponse['data']['1']['properties']['active']['value']; // heating.burners.0
echo "BurnerStatus: ".$BurnerStatus."<br>";
if ($BurnerStatus == "1") {
$BurnerStatus = "<span style='vertical-align:middle; '>On</span><img src='viessmann_burner_on.png' alt='burner_on' width='20%' style='vertical-align:middle; '>";
} else {
$BurnerStatus = "<span style='vertical-align:middle; '>Off</span><img src='viessmann_burner_off.png' alt='burner_off' width='20%' style='vertical-align:middle; '>";
}
$BurnerHours = $jsonResponse['data']['2']['properties']['hours']['value']; //heating.burners.0.statistics
echo "BurnerHours: ".$BurnerHours."<br>";
$MaxEnergyConsumption = $BurnerHours*160/1000;
echo "MaxEnergyConsumption (160W/h): ".$EnergyConsumption." kWh<br>";
$BurnerStarts = $jsonResponse['data']['2']['properties']['starts']['value']; //heating.burners.0.statistics
echo "BurnerStarts: ".$BurnerStarts."<br>";
$MeasureUnit = $jsonResponse['data']['0']['properties']['value']['unit']; //heating.boiler.sensors.temperature.commonSupply
if ($MeasureUnit == "celsius") {
$MU = " °C ";
} else {
$MU = " °F ";
}
$TemperatureCommon = $jsonResponse['data']['0']['properties']['value']['value']; //heating.boiler.sensors.temperature.commonSupply
echo "TemperatureCommon: ".$TemperatureCommon." ".$MU."<br>";
$HotWaterSet = $jsonResponse['data']['6']['properties']['value']['value']; //heating.dhw.temperature.main
$HotWater = $jsonResponse['data']['5']['properties']['value']['value']; //heating.dhw.sensors.temperature.hotWaterStorage
echo "HotWater: ".$HotWaterSet." / ".$HotWater." ".$MU."<br>";
$RadiatorsSet = $jsonResponse['data']['3']['properties']['temperature']['value']; //heating.circuits.0.operating.programs.normal
$TemperatureRoom = $jsonResponse['data']['4']['properties']['value']['value']; //heating.circuits.0.sensors.temperature.room
echo "Radiators: ".$RadiatorsSet ." / ".$TemperatureRoom." ".$MU."<br>";
?>
<div style="position:relative; ">
<img src="viessmann_map.png" alt="map" style="display:block; margin-left:auto; margin-right:auto; ">
<div style="position:absolute; top: 12%; left:52%; font-size:150%; ">
<?php echo "Boiler<br>".
"TemperatureCommon: ".number_format($TemperatureCommon,0).$MU."<br>".
"BurnerHours: ".$BurnerHours."<br>".
"BurnerStarts: ".$BurnerStarts."<br>".
"MaxEnergyConsumption (160W/h): ".$MaxEnergyConsumption." kWh";?>
</div>
<div style="position:absolute; top: 53%; left:27%; font-size:150%; text-align:right; ">
<?php echo "Water heating<br>".
"Set: ".number_format($HotWaterSet,0).$MU."<br>".
"Current: ".number_format($HotWater,0).$MU."<br>";?>
</div>
<div style="position:absolute; top: 53%; left:50%; font-size:150%; ">
<?php echo "Radiators<br>".
"Set: ".number_format($RadiatorsSet,0).$MU."<br>".
"TemperatureRoom: ".number_format($TemperatureRoom,0).$MU."<br>";?>
</div>
<div style="position:absolute; top: 37%; left:41%; font-size:120%; ">
<?php echo $BurnerStatus; ?>
</div>
</div>
</body>
</html> Since the boiler I have used does not provide any consumption statistics I have worked something around: $MaxEnergyConsumption = $BurnerHours*160/1000; where 160 is the maximum boiler energy consumption as provided by Viessmann in the product manual. If you are not sure you can uncomment the appropriate $getURL to see all the features and data points reported by your boiler. The result is available in the attached screenshot. Also the used PNGs have been attached.
... Mehr anzeigen