30 lines
1.0 KiB
PHP
30 lines
1.0 KiB
PHP
<?php
|
|
$topics["pws2mqtt"] = new topic;
|
|
/*$devices["pws2mqtt"]["WH2650A"]["device"] = new device;
|
|
$device = &$devices["pws2mqtt"]["WH2650A"]["device"];*/
|
|
|
|
$topics["pws2mqtt"]->callback = function($topic, $message)
|
|
{
|
|
global $topics, $logFh, $devices, $included;
|
|
$fn = $topic[1]; // get friendlyname
|
|
logger(INFO, sprintf(_("Icoming notification of device %s => friendly name : %s"), $topic[0], $topic[1]));
|
|
$device = & $devices[$topic[0]];
|
|
$payloadArray = json_decode($message->payload);
|
|
//print_r($payloadArray);
|
|
//print_r($device) ;
|
|
if (!isset($device[$fn])) //must not exists, but ...
|
|
{
|
|
logger(LOG_WARNING, $logFh, "init of " . $fn .EOL);
|
|
$device[$fn] = array();
|
|
$device[$fn]["device"] = new device;
|
|
$device[$fn]["device"]->type = $payloadArray->type;
|
|
$device[$fn]["device"]->ieeeAddress = $payloadArray->ieeeAddress;
|
|
//addDevice($device[$fn], $fn, );
|
|
}
|
|
//print_r($device);
|
|
$device = & $device[$fn];
|
|
changeDevice($topic[0], $topic[1], $device["device"], $payloadArray);
|
|
//print_r($device["device"]);
|
|
}
|
|
?>
|