2022-01-08 11:51:50 +01:00
|
|
|
<?php
|
2022-01-08 23:45:38 +01:00
|
|
|
$topics["pws2mqtt"] = new topic;
|
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-08 23:45:38 +01:00
|
|
|
$topic = explode ("/", $message->topic, 2); // get topic name
|
|
|
|
$fnTree = explode ("/" , $topic[1]); // get friendlyname
|
|
|
|
echo $topic[0] . " => " . $topic[1] . EOL;
|
|
|
|
$device = & $devices[$topic[0]];
|
|
|
|
foreach($fnTree as $fn)
|
|
|
|
{
|
|
|
|
//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;
|
|
|
|
//addDevice($device[$fn], $fn, );
|
|
|
|
}
|
|
|
|
$device = & $device[$fn];
|
|
|
|
print_r($device);
|
|
|
|
}
|
|
|
|
$payloadArray = json_decode($message->payload);
|
|
|
|
changeDevice($topic[0], $topic[1], $device["device"], $payloadArray);
|
|
|
|
print_r($device["device"]);
|
2022-01-08 11:51:50 +01:00
|
|
|
}
|
|
|
|
?>
|