109 lines
1.8 KiB
PHP
109 lines
1.8 KiB
PHP
|
<?php
|
||
|
class Message
|
||
|
{
|
||
|
public $id;
|
||
|
public $state = false;
|
||
|
public $msg;
|
||
|
}
|
||
|
|
||
|
class topic {
|
||
|
public $mid;
|
||
|
public $status;
|
||
|
public $info;
|
||
|
public $devices;
|
||
|
public $groups;
|
||
|
public $extensions;
|
||
|
public $config;
|
||
|
}
|
||
|
|
||
|
class device
|
||
|
{
|
||
|
public $method; //auto or manual
|
||
|
public $topic;
|
||
|
public $device;
|
||
|
public $ieeeAddress;
|
||
|
public $groupID;
|
||
|
public $friendlyName;
|
||
|
public $powerSource;
|
||
|
public $description;
|
||
|
public $functions;
|
||
|
public $payload;
|
||
|
public $availibility;
|
||
|
|
||
|
public function set($event)
|
||
|
{
|
||
|
publish($this, $this->payload, "set", $event);
|
||
|
}
|
||
|
|
||
|
public function get()
|
||
|
{
|
||
|
publish($this, $this->payload, "get", $event);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class ranges
|
||
|
{
|
||
|
public $start; //datetime
|
||
|
public $end; //datetime
|
||
|
}
|
||
|
|
||
|
class event
|
||
|
{
|
||
|
public $ieeeAddress;
|
||
|
public $topic;
|
||
|
public $param;
|
||
|
public $value;
|
||
|
public $device;
|
||
|
public $published;
|
||
|
public $dateTimeEvent; // datetime : next occurence for recurrent event
|
||
|
public $startDatetime;
|
||
|
public $stopDatetime;
|
||
|
public $recurrenceInterval; // interval : for recurrent event
|
||
|
public $exceptionInterval; // array of object ranges
|
||
|
}
|
||
|
|
||
|
class interval
|
||
|
{
|
||
|
public $startDate;
|
||
|
public $endDate;
|
||
|
}
|
||
|
|
||
|
class notificationMethod
|
||
|
{
|
||
|
public $url;
|
||
|
public $msg;
|
||
|
public $active;
|
||
|
public $level;
|
||
|
|
||
|
function __construct($url)
|
||
|
{
|
||
|
$this->url = $url;
|
||
|
}
|
||
|
|
||
|
public function send($text=null)
|
||
|
{
|
||
|
if (empty($text)) $text= $this->msg;
|
||
|
if (!empty($msg))
|
||
|
{
|
||
|
$opts = array(
|
||
|
'http'=>array(
|
||
|
'method'=>"GET",
|
||
|
'header'=>"Accept-language: fr\r\n"
|
||
|
)
|
||
|
);
|
||
|
$context = stream_context_create($opts);
|
||
|
|
||
|
/* Envoi une requête HTTP vers $url
|
||
|
avec les en-têtes additionnels ci-dessus */
|
||
|
$fp = fopen($url . "/" . $msg, 'r', false, $context);
|
||
|
$response = stream_get_contents($fp, -1, 0);
|
||
|
fclose($fp);
|
||
|
}else
|
||
|
{
|
||
|
// TODO log_error("notificationMethod : $msg is null");
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
?>
|