Beispiel #1
0
$alarm = new Alarm();
$arrMvt = loadSensors();
$arrMvt2 = initTimestamp($arrMvt);
$scenarios = loadScenarios($arrMvt);
while (true) {
    $settings = new Settings();
    $zwave = new Zwave();
    foreach ($arrMvt as $i => $sensor) {
        if ($sensor['type'] == 'Door/Window') {
            switch ($sensor['protocol']) {
                case 'zwave':
                    if ($zwave->getValue($sensor['sensor']) == 'on' && $zwave->GetTimestamp($sensor['sensor']) != $arrMvt2[$i]) {
                        $arrMvt2[$i] = $zwave->GetTimestamp($sensor['sensor']);
                        execScenario($i, $scenarios);
                        if ($mode->getMode() == Mode::NIGHT || $mode->getMode() == Mode::AWAY) {
                            $alarm->execAlarm();
                        }
                    }
                    break;
            }
        } else {
            if ($sensor['type'] == 'Motion') {
                switch ($sensor['protocol']) {
                    case 'zwave':
                        if ($zwave->GetTimestamp($sensor['sensor']) != $arrMvt2[$i]) {
                            $arrMvt2[$i] = $zwave->GetTimestamp($sensor['sensor']);
                            execScenario($i, $scenarios);
                            if ($mode->getMode() == Mode::AWAY) {
                                $alarm->execAlarm();
                            }
                        }