2022-01-17 00:18:50 +01:00
|
|
|
<?php
|
|
|
|
//TODO to test and debug
|
|
|
|
$topics["linky2mqtt"] = new topic;
|
|
|
|
|
|
|
|
$topics["linky2mqtt"]->callback = function($topic, $message)
|
|
|
|
{
|
|
|
|
global $topics, $logFh, $devices, $included;
|
|
|
|
$topicName = $topic[0];
|
|
|
|
$friendlyName = $topic[1]; // get friendlyName
|
2022-01-28 23:05:58 +01:00
|
|
|
logger(INFO, sprintf(_("Incoming notification of device %s"), $topic[0], $topic[1]), __FILE__ . ":" . __LINE__);
|
2022-01-17 00:18:50 +01:00
|
|
|
$device = & $devices[$topic[0]];
|
|
|
|
$payloadArray = json_decode($message->payload);
|
|
|
|
if (!isset($device[$fn])) //must not exists, but ...
|
|
|
|
{
|
2022-01-28 23:05:58 +01:00
|
|
|
logger(LOG_WARNING, $logFh, _("init of ") . $fn, __FILE__ . ":" . __LINE__);
|
2022-01-17 00:18:50 +01:00
|
|
|
$device[$fn] = array();
|
|
|
|
$device[$fn]["device"] = new device;
|
|
|
|
$device[$fn]["device"]->type = "mesure";
|
|
|
|
$device[$fn]["device"]->ieeeAddress = $payloadArray["ADSC"];
|
2022-01-17 21:01:11 +01:00
|
|
|
$indexDevices[$device[$fn]["device"]->ieeeAddress] = & $device[$fn]["device"];
|
2022-01-17 00:18:50 +01:00
|
|
|
}
|
|
|
|
$device = & $device[$fn];
|
|
|
|
changeDevice($topicName, $friendlyName, $device["device"], $payloadArray);
|
2022-01-19 00:22:34 +01:00
|
|
|
//print_r($device["device"]);
|
2022-01-17 00:18:50 +01:00
|
|
|
}
|
|
|
|
?>
|