if (array_key_exists('airpressure', $items[$i])) { $bcst['airpressure'] = $items[$i]['airpressure']; } if (array_key_exists('windspeed', $items[$i])) { $bcst['windspeed'] = $items[$i]['windspeed']; } if (array_key_exists('winddirection', $items[$i])) { $bcst['winddirection'] = $items[$i]['winddirection']; } if (array_key_exists('rainfall', $items[$i])) { $bcst['rainfall'] = $items[$i]['rainfall']; } if (false === ($answer = json_encode($bcst))) { $log->lwrite("main:: error weather broadcast encode: <" . $bcst['tcnt'] . "," . $bcst['action'] . ">", 1); } $sock->s_bcast($answer); //continue; break; case "energy": $log->lwrite("main:: Recognized ENERGY Message", 3); // Update the energy structure in the rrd database // $wthr->upd($item); // Write the received values to the rrd database file, and update all fields. $sensor->rrdupdate($items[$i]); // We can forward to the GUI for example // XXX At the moment we do NOT have a meaningful use for forwarding // XXX Later we can use GUI action for updating the dials $bcst = array('tcnt' => "0", 'action' => "energy", 'type' => "json", 'address' => $items[$i]['address'], 'channel' => $items[$i]['channel'], 'brand' => $items[$i]['brand'], 'kw_hi_use' => $items[$i]['kw_hi_use'], 'kw_lo_use' => $items[$i]['kw_lo_use'], 'kw_hi_ret' => $items[$i]['kw_hi_ret'], 'kw_lo_ret' => $items[$i]['kw_lo_ret'], 'kw_act_use' => $items[$i]['kw_act_use'], 'kw_act_ret' => $items[$i]['kw_act_ret'], 'kw_ph1_use' => $items[$i]['kw_ph1_use'], 'kw_ph2_use' => $items[$i]['kw_ph2_use'], 'kw_ph3_use' => $items[$i]['kw_ph3_use'], 'kw_ph1_ret' => $items[$i]['kw_ph1_ret'], 'kw_ph2_ret' => $items[$i]['kw_ph2_ret'], 'kw_ph3_ret' => $items[$i]['kw_ph3_ret'], 'gas_use' => $items[$i]['gas_use']); if (false === ($answer = json_encode($bcst))) { $log->lwrite("main:: error energy broadcast encode: <" . $bcst['tcnt'] . "," . $bcst['action'] . ">", 1); }