1
0

making compatibility with mqtt's friendly names

This commit is contained in:
2021-12-31 14:34:20 +01:00
parent 5162731a16
commit 57390d099b
5 changed files with 151 additions and 61 deletions

View File

@@ -3,15 +3,16 @@
function checkEvents()
{
global $events, $indexDevices, $devices;
echo "===========> checking events" . EOL;
//echo "===========> checking events" . EOL;
foreach ($events as $key => $event)
{
if ($event->dateTimeEvent <= now())
if (!empty($event->dateTimeEvent) and $event->dateTimeEvent <= now())
{
echo "---->sending command" . EOL;
//echo "---->sending command" . EOL;
publish($devices[$event->topic][$indexDevices[$event->ieeeAddress]], array($event->param => $event->value), "set", $key);
//$event->published = now();
unset($key);
//echo "#################################\nUnsetting event $key \n###########################" . EOL;
unset($events[$key]);
}
}
//print_r($events);
@@ -69,15 +70,15 @@ function searchEvent($device, $param , $value)
global $events;
echo "searching event" . EOL;
//$keys = array_keys($events, $device->ieeeAddress);
echo "ieee_address =>" . $device->ieeeAddress . EOL;
print_r($events);
//echo "ieee_address =>" . $device->ieeeAddress . EOL;
//print_r($events);
foreach($events as $key => $event)
{
//echo "Event : $event => $value" . EOL;
echo "===>";print_r($event); echo EOL;
//echo "===>";print_r($event); echo EOL;
if($event->topic == $device->topic and $event->param == $param and $event->value == $value and $event->ieeeAddress == $device->ieeeAddress)
{
echo "==============================\nfound " . $key . "\n=================================" . EOL;
//echo "==============================\nfound " . $key . "\n=================================" . EOL;
return $key;
}
}
@@ -87,7 +88,7 @@ function deleteEvent($eventKey)
{
global $events;
unset ($events[$eventKey]);
echo "delete event " . $eventKey . EOL;
//echo "delete event " . $eventKey . EOL;
}