Hi, I have this new heating controller with wireless T-169 Thermometers.
The controller has a new Api, which I use with following php-script (with exec-binding).
You have to change the uponor IP and create the items (in PaperUI) from $devices_to_check .
C1_T5_room_temperature and C1_T5_rh correspond to temp and humidity from channel 5.
#!/usr/bin/php
<?php
// Settings
$oh_url = "192.168.211.56";
$oh_port = "8080";
$uponor_ip = "192.168.211.96";
$devices_to_check = array( array('mac' => 'C1_T3_room_temperature', 'item' => 'Elternschlafzimmertemp'), array('mac' => 'C1_T4_room_temperature', 'item' => 'Kindertemp'), array('mac' => 'C1_T5_room_temperature', 'item' => 'Badtemp'),array('mac' => 'C1_T3_rh', 'item' => 'Elternschlafzimmer') , array('mac' => 'C1_T4_rh', 'item' => 'Kinderzimmer'), array('mac' => 'C1_T5_rh', 'item' => 'BadFeuchtigkeit'));
//Elternschlafzimmeraus, Kinderzimmeraus
if(!function_exists('curl_version')) { echo "Please install cURL for PHP\n"; echo "Ubuntu: sudo apt install php-curl\n"; exit; }
// Get active connections from Linksys router
$connections = getLinksysConnections($uponor_ip);
// Loop throught devices to check
foreach($devices_to_check as $device_to_check) {
// Get state of device to check
$state = getOHItemState($oh_url, $oh_port, $device_to_check['item']);
// Check if device is online
$online = isOnline($connections, $device_to_check['mac']);
// Update status of device to check
if($state == 'NULL' ) { setOHItemState($oh_url, $oh_port, $device_to_check['item'], $online); }
setOHItemState($oh_url, $oh_port, $device_to_check['item'], doubleval($online));
echo $device_to_check['item']," = ",$online," , ";}
// isOnline
function isOnline($connections, $mac_to_check) {
foreach($connections as $connection) {
$connection_mac = $connection['waspVarName'];
//var_dump( $connection_mac);
if ($mac_to_check==$connection_mac) {
if ($connection['waspVarValue']>630) {$Temp=(($connection['waspVarValue']/10)-32)*5/9;}
else $Temp=$connection['waspVarValue'];
//echo $connection['waspVarName']," = ";
}
}
return $Temp; }
// getOHItemState
function getOHItemState($oh_url, $oh_port, $item) { $state = 'OFF'; $headers = array(); $headers[] = 'Content-Type: text/plain'; $headers[] = 'Accept: application/json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, "http://$oh_url:$oh_port/rest/items/$item"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch);
if (!curl_errno($ch)) { $json = json_decode($response, true); if(isset($json['state'])) { $state = $json['state']; } } curl_close($ch); return $state; }
// setOHItemState
function setOHItemState($oh_url, $oh_port, $item, $state = 'OFF') { $return = false; $headers = array(); $headers[] = 'Content-Type: text/plain'; $headers[] = 'Accept: application/json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, "http://$oh_url:$oh_port/rest/items/$item"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $state); curl_exec($ch); if (!curl_errno($ch)) { $return = true; } curl_close($ch); return $return; }
// getLinksysConnections curl -X POST -H 'x-jnap-action: ' 'http://<myip>/JNAP/' --data '{}' | \ jq -r '.output.vars[] | [.waspVarName, .waspVarValue] | @csv ' | \ sort | grep "[0-9]_name"
function getLinksysConnections($linksys_ip)
{ define('ACTION', 'http://phyn.com/jnap/uponorsky/GetAttributes');
//$connections = "";
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://'.$linksys_ip.'/JNAP/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "{}"); $headers = array();
$headers[] = 'X-Jnap-Action: '.ACTION;
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$json = curl_exec($ch);
if (!curl_errno($ch)) {
$connections = json_decode($json, true);
}
curl_close($ch);
return $connections['output']['vars']; }
?>