for ($i = 0; $i < count($items); $i++) { // For every item ... // Do we have the latest list of devices?? // run-a-command-to-get-the-latest-list-of-devices;; // What to do if the command is all off. We have to expand the command to include all // the devices currently in the room. Since all off might be a popular command in scene and timer // commands we need to ensure correct timing. Because if the daemon runs with old data // we might miss a switch off of a devices that were added later to the scene. // Make use of the feature that the condition in the loop is re-evaluated for every iteration. SO // "explode" the ALL-OFF command, and replace it with the individual device commands, en put them at // the back of the queue-list being executed switch ($items[$i]['action']) { case "weather": $log->lwrite("main:: Recognized WEATHER Message", 3); // Write the received values to the rrd database file, and update all fields. $sensor->rrdupdate($items[$i]); // Update the weather structure in the MySQL database $wthr->upd($items[$i]); // make broadcst $bcst = array('tcnt' => "0", 'action' => "weather", 'type' => "json", 'brand' => $items[$i]['brand'], 'address' => $items[$i]['address'], 'channel' => $items[$i]['channel']); if (array_key_exists('temperature', $items[$i])) { $bcst['temperature'] = $items[$i]['temperature']; } if (array_key_exists('humidity', $items[$i])) { $bcst['humidity'] = $items[$i]['humidity']; } if (array_key_exists('airpressure', $items[$i])) { $bcst['airpressure'] = $items[$i]['airpressure']; } if (array_key_exists('windspeed', $items[$i])) { $bcst['windspeed'] = $items[$i]['windspeed'];