2022-01-08 11:51:50 +01:00
|
|
|
<?php
|
2022-01-08 23:45:38 +01:00
|
|
|
$topics["pws2mqtt"] = new topic;
|
2022-01-17 00:18:50 +01:00
|
|
|
/*$devices["pws2mqtt"]["WH2650A"]["device"] = new device;
|
|
|
|
$device = &$devices["pws2mqtt"]["WH2650A"]["device"];*/
|
2022-01-08 11:51:50 +01:00
|
|
|
|
2022-01-08 23:45:38 +01:00
|
|
|
$topics["pws2mqtt"]->callback = function($topic, $message)
|
2022-01-08 11:51:50 +01:00
|
|
|
{
|
|
|
|
global $topics, $logFh, $devices, $included;
|
2022-01-17 00:18:50 +01:00
|
|
|
$fn = $topic[1]; // get friendlyname
|
|
|
|
logger(INFO, sprintf(_("Icoming notification of device %s => friendly name : %s"), $topic[0], $topic[1]));
|
2022-01-08 23:45:38 +01:00
|
|
|
$device = & $devices[$topic[0]];
|
2022-01-17 00:18:50 +01:00
|
|
|
$payloadArray = json_decode($message->payload);
|
|
|
|
//print_r($payloadArray);
|
|
|
|
//print_r($device) ;
|
|
|
|
if (!isset($device[$fn])) //must not exists, but ...
|
2022-01-08 23:45:38 +01:00
|
|
|
{
|
2022-01-17 00:18:50 +01:00
|
|
|
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, );
|
2022-01-08 23:45:38 +01:00
|
|
|
}
|
2022-01-17 00:18:50 +01:00
|
|
|
//print_r($device);
|
|
|
|
$device = & $device[$fn];
|
2022-01-08 23:45:38 +01:00
|
|
|
changeDevice($topic[0], $topic[1], $device["device"], $payloadArray);
|
2022-01-17 00:18:50 +01:00
|
|
|
//print_r($device["device"]);
|
2022-01-08 11:51:50 +01:00
|
|
|
}
|
|
|
|
?>
|