<?php include_once 'includes/homematic.php'; switch ($_POST["method"]) { case "updateValve": if (is_numeric($_POST["peerId"])) { $home = new HomeMaticInstance(); if ($valve = $home->getValveByPeerId($_POST["peerId"])) { switch ($_POST["mode"]) { case "auto": if ($valve->getControlMode() != "auto") { $valve->setControlMode("auto"); } break; case "manual": if ($valve->getControlMode() != "manual") { $valve->setControlMode("manual"); } if ($valve->getTargetTemp() != floatval($_POST["targetTemp"])) { $valve->setTargetTemp(floatval($_POST["targetTemp"])); } break; } Header("Location: index.php#peer" . $_POST["peerId"]); exit; } else { echo "Error: Valve not found!\n"; } } else { echo "Error: invalid Peer ID\n"; }
<?php include_once 'includes/homematic.php'; include_once 'includes/rain.tpl.class.php'; $home = new HomeMaticInstance(); $tempset["regular"] = new tempsetInstance(); $tempset["regular"]->addTemp("07:00", 19, $tempset["regular"]->presetWorkday); $tempset["regular"]->addTemp("09:00", 17, $tempset["regular"]->presetWorkday); $tempset["regular"]->addTemp("18:00", 19, $tempset["regular"]->presetWorkday); $tempset["regular"]->addTemp("23:00", 17, $tempset["regular"]->presetWorkday); $tempset["regular"]->addTemp("08:00", 20, $tempset["regular"]->presetWeekend); $tempset["regular"]->addTemp("11:00", 17, $tempset["regular"]->presetWorkday); $tempset["nothome"] = new tempsetInstance(); $tempset["nothome"]->addTemp("01:00", 17); raintpl::$tpl_dir = "tpl/"; raintpl::$cache_dir = "/tmp/"; raintpl::$base_url = "/"; raintpl::$path_replace = true; $tpl = new raintpl(); $tpl->assign("deviceList", $home->getAllDevices(true)); $tpl->draw('index');
<?php $BASE_PATH = realpath(dirname(__FILE__)); include_once $BASE_PATH . '/../includes/homematic.php'; include_once $BASE_PATH . '/../includes/class.graphing.php'; $hm = new HomeMaticInstance(); $hg = new HomeMaticGraphing($hm); $periods = array("hourly", "daily", "weekly", "monthly", "yearly"); foreach ($periods as $period) { $hg->drawTempGraph($period); $hg->drawValveGraph($period); $hg->drawHumidityGraph($period); foreach ($hm->getAllDevices() as $device) { if ($device["type"] == "valve") { $hg->drawCurrentVsActualTempGraph($period, $device["peerId"]); } } }
<?php function sendPushMessage($pushMessage, $apiUrl, $apiToken, $apiUser) { curl_setopt_array($ch = curl_init(), array(CURLOPT_URL => $apiUrl, CURLOPT_POSTFIELDS => array("token" => $apiToken, "user" => $apiUser, "message" => $pushMessage), CURLOPT_SAFE_UPLOAD => true, CURLOPT_RETURNTRANSFER => true)); curl_exec($ch); curl_close($ch); } # basic variables $BASE_PATH = realpath(dirname(__FILE__)); include $BASE_PATH . "/../config/pushover-config.php"; $lastAvgValueFile = "/tmp/average-temp.txt"; # homegear stuff include_once $BASE_PATH . "/../includes/homematic.php"; $home = new HomeMaticInstance(); $devices = $home->getAllDevices(true); # redis stuff include_once $BASE_PATH . "/../includes/redis/redis.php"; $redis = new redis_cli("127.0.0.1", 6379); ########################################################## # Compare current Avg Temp against last known Avg Temp # ########################################################## $temperatures = array(); foreach ($devices as $device) { if (!empty($device["tempSensor"])) { $temperatures[] = $device["tempSensor"]; } } if (count($temperatures) > 0) { $avgTemp = round(array_sum($temperatures) / count($temperatures), 2); } else {