1
0
moha/topics_callbacks/pws2mqtt.php

29 lines
832 B
PHP
Raw Normal View History

<?php
2022-01-08 23:45:38 +01:00
$topics["pws2mqtt"] = new topic;
2022-01-08 23:45:38 +01:00
$topics["pws2mqtt"]->callback = function($topic, $message)
{
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"]);
}
?>