示例#1
0
function sendHMCommand($device, $commandType, $value, $reason = 'unknown', $config = array(), $fireEvent = false)
{
    if (sizeof($device) > 0 && $device['d_state'] != $value) {
        $pv = reviewParams($device, $commandType, $value);
        if ($commandType == 'STATE') {
            $hpv = $pv == 0 ? 'false' : 'true';
        } else {
            $hpv = $pv;
        }
        // send HM commands directly, to save time
        $result = HMRPC('setValue', array($device['d_id'], $commandType, $hpv));
        queryCommandServer(array('cmd' => 'busmessage', 'fireevent' => $fireEvent ? 'Y' : 'N', 'data' => json_encode(array('key' => $device['d_key'], 'type' => $device['d_bus'], 'device' => $device['d_id'], 'param' => $commandType, 'value' => $pv, 'stxt' => $reason))));
        recordDeviceStatus($device, $commandType, $pv, $reason);
        $tmr = $config['timer_' . $commandType . '_' . $pv];
        if ($tmr) {
            cqrequest(array(array('url' => 'http://localhost:1080/?cmd=timer' . '&name=' . $device['d_key'] . '&countDown=' . $tmr['seconds'] . '&stxt=' . urlencode($reason) . '&param=' . urlencode($commandType) . '&key=' . $device['d_key'] . '&id=' . $device['d_id'] . '&trigger=' . ('timer_' . $commandType . '_' . $pv))));
        }
    }
    return $result;
}
<?php

$recentTicks = queryCommandServer(array('cmd' => 'info', 'about' => 'tickLog'));
if ($recentTicks['svc/ajax_tick'] < time() - 60 * 5) {
    ?>
<div class="banner">
      Warning: the timer system is not working.
    </div><?php 
    $nodeProc = explode(chr(10), shell_exec('ps aux | grep node'));
    $srvFound = false;
    foreach ($nodeProc as $p) {
        if (stripos($p, 'node srv.js') !== false) {
            $srvFound = true;
        }
    }
    if (!$srvFound) {
        ?>
<div class="banner">
        Warning: the Home Overlord service is not running.
      </div><?php 
    }
}
示例#3
0
<pre><?php 
print_r(queryCommandServer(array('cmd' => 'info', 'about' => 'tickLog')));
?>
</pre>