availability = array("value" => null, "functions" => array()); } public function set($method=0) //, $event = null) { $this->method = $method; publish($this->topic . "/" . $this->friendlyName, $this->payload, "set"); //, $event); } public function get() { publish($this->topic . "/" . $this->friendlyNames, $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 watch { public $topic; public $property; public $PropertyValue; public $device; public $function; private $conditions = array( "<", ">", "==", ">=", "<=" ); public $condition; public function __construct($topic, $fn, $property, $condition, $value) { logger(DEBUG, _("New Notify object"), __FILE__ . ":" . __LINE__); if (($this->device = getDevice($topic, $fn)) === false) { $this->topic = $topic; if (array_key_exist($property, $this->device)) { $this->property = $property; if (!is_numeric($value)) { logger(ERROR, _("Value is not numeric"), __FILE__ . ":" . __LINE__ ); return false; } if (array_search($condition, $conditions)) { $this->function = '$value ' . $condition . " " . $value; logger(DEBUG, _("Test function is ") . $this->function); }else { logger(ERROR, _("Condition is not one of the permitted"), __FILE__ . ":" . __LINE__ ); return false; } $this->device[$ieeeAddress]->$property["functions"][] = array($this,"notifyCallback"); }else { logger(ERROR, _("Property do not exists"), __FILE__ . ":" . __LINE__ ); return false; } }else { logger(ERROR, _("Device do not exists"), __FILE__ . ":" . __LINE__ ); return false; } return $this; } public function notifyCallback(&$device, $property, $value) { if (eval($this->function)) { $msg = sprintf(_("Device '%s' have property '%s' value %s %s %s"), $device->friendlyName, $property, $value, $this->condition, $this->PropertyValue ); notify($msg); } } } class interval { public $startDate; public $endDate; } ?>