Got this problem too with openhab2 build #1020. My “fix” is a php script based on @Kev_Marlow suggestion:
<?php
function curlPost($url) {
// Set a one-minute timeout for this script
set_time_limit(60);
$options = array(
CURLOPT_RETURNTRANSFER => TRUE, // return web page
CURLOPT_HEADER => FALSE, // don't return headers
CURLOPT_POST => TRUE,
CURLOPT_HTTPHEADER => array("Accept: application/json"),
);
$session = curl_init($url);
curl_setopt_array($session, $options);
// Tell curl that this is the body of the POST
curl_setopt($session, CURLOPT_POSTFIELDS, $data);
// $output contains the output string
$output = curl_exec($session);
}
function curlPut($url, $data) {
// Set a one-minute timeout for this script
set_time_limit(60);
$options = array(
CURLOPT_RETURNTRANSFER => TRUE, // return web page
CURLOPT_HEADER => FALSE, // don't return headers
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => array("Content-Type: application/json", "Accept: application/json"),
);
$session = curl_init($url);
curl_setopt_array($session, $options);
// Tell curl that this is the body of the POST
curl_setopt($session, CURLOPT_POSTFIELDS, $data);
// $output contains the output string
$output = curl_exec($session);
}
function curlGet($url) {
// Set a one-minute timeout for this script
set_time_limit(60);
$options = array(
CURLOPT_RETURNTRANSFER => TRUE, // return web page
CURLOPT_HEADER => FALSE, // don't return headers
CURLOPT_HTTPGET => TRUE,
CURLOPT_HTTPHEADER => array("Accept: application/json"),
);
$session = curl_init($url);
curl_setopt_array($session, $options);
// $output contains the output string
$output = curl_exec($session);
return $output;
}
$output = curlGet("http://openhab:8080/rest/rules");
if (preg_match_all('/"uid"\:\"(.*?)\"/', $output, $matches)) {
foreach ($matches[1] as $rule) {
curlPut("http://openhab:8080/rest/rules/" . $rule . "/config", "{}");
}
}