<?php

$isDay = $t >= strtotime(date('H:i', getSunrise(false))) && $t <= strtotime(date('H:i', getSunset(false)));
$dayString = $isDay ? 'DAY' : 'NIGHT';
$data = json_decode($_REQUEST['data'], true);
$hdl = H2EventManager::getApplicableEventsForDevice($data);
$dds = o(db)->getDSMatch('devices', array('d_bus' => $data['type'], 'd_id' => $data['device']));
$data['ds'] = $dds;
$this->callEventHandlers($hdl, $data);
profile_point('done');
/* WriteToFile('log/stats.'.gmdate('Y-m').'.log', 
   json_encode(array(
     'type' => 'dp', 'key' => $dds['d_key'], 'id' => $data['device'], 'bus' => $data['type'], 'param' => $data['param'], 'value' => $data['value'], 'tr' => 'rx')).
   chr(10)
   ); */
$sds = array('si_bus' => $data['type'], 'si_name' => $data['device'], 'si_param' => $data['param'], 'si_value' => $data['value'], 'si_time' => time(), 'si_devicekey' => $dds['d_key'], 'si_by' => 'BIDCOS', 'si_mode' => 'RX', 'si_ip' => first($_SERVER['HTTP_X_FORWARDED_FOR'], $_SERVER['REMOTE_ADDR']));
o(db)->commit('stateinfo', $sds);
<?php

$editable = array('d_bus' => 'Bus System', 'd_id' => 'Identifier', 'd_type' => 'Type', 'd_icon' => 'Icon', 'd_room' => 'Room', 'd_name' => 'Name', 'd_alias' => 'Alias');
$doSave = isset($_POST['controller']);
$ds = getDeviceDS($_REQUEST['key']);
$dev = HMRPC('getDeviceDescription', array($ds['d_id']));
$paramSet = H2EventManager::getEmittableEventsByDevice($ds);
$_REQUEST['actionEvents'] = array();
$related = array();
$idnr = $ds['d_id'];
$idroot = CutSegment(':', $idnr);
foreach (o(db)->get('SELECT d_key,d_id,d_alias,d_type FROM devices WHERE d_id LIKE "' . $idroot . '%" ORDER BY d_id') as $dds) {
    $related[] = '<a href="' . actionUrl('edit', 'devices', array('key' => $dds['d_key'])) . '" style="' . ($dds['d_key'] == $ds['d_key'] ? 'font-weight:bold;' : '') . '">' . htmlspecialchars(first($dds['d_alias'], $dds['d_type'])) . ' ' . $dds['d_id'] . '</a>';
}
if ($_POST['key']) {
    foreach ($editable as $fn => $fncap) {
        $ds[$fn] = $_POST[$fn];
    }
    o(db)->commit('devices', $ds);
    header('location: ' . actionUrl('show'));
    die;
}
$eventList = H2EventManager::getEventsByDevice($ds);
$eventTargetList = H2EventManager::getEventsByTarget($ds);
$groupList = H2GroupManager::getGroupsByDevice($ds);