Hello,
Can anyone tell me if this sample script can be "transplanted" to LM?
If yes, can you give some guidance if not the full code?
I'm using ZipaTile as room thermostat (and lights, Sonos, etc. UI ), but sometimes it fails to send temperature data. The idea is to check periodically the group update time from resident script, and if it is to long issue a reboot command.
Thanks, Z
Can anyone tell me if this sample script can be "transplanted" to LM?
Code:
<?php
$username = 'xxx@xxx.xxx';
$password = 'xxx;
$serial = 'xxx';
$nonce;
$jsessionid;
$token;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://my.zipato.com/zipato-web/v2/user/init";,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err)
{
echo "cURL Error #:" . $err;
}
else
{
$json = json_decode($response, true);
$nonce = $json['nonce'];
$jsessionid = $json['jsessionid'];
$password = sha1($password);
$token = $nonce . $password;
$token = sha1($token);
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://my.zipato.com/zipato-web/v2/user/login?token=$token&username=$username";,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"cookie: JSESSIONID = $jsessionid;"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err)
{
echo "cURL Error #:" . $err;
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://my.zipato.com/zipato-web/v2/box/reboot/$serial";,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"cookie: JSESSIONID = $jsessionid;"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err)
{
echo "cURL Error #:" . $err;
}
else
{
echo 'success';
}
?>
If yes, can you give some guidance if not the full code?
I'm using ZipaTile as room thermostat (and lights, Sonos, etc. UI ), but sometimes it fails to send temperature data. The idea is to check periodically the group update time from resident script, and if it is to long issue a reboot command.
Thanks, Z