// if any action set, act on it if (isset($_GET['action'])) { try { $theState = ''; $theCurr = ''; $theReq = ''; if (isset($_GET["state"])) { $theState = $_GET["state"]; } if (isset($_GET["curr"])) { $theCurr = $_GET["curr"]; } if (isset($_GET["req"])) { $theReq = $_GET["req"]; } heyu_action($config, $_GET["action"], $_GET["code"], $theState, $theCurr, $theReq); } catch (Exception $e) { // noop } if (isset($_GET['page'])) { header("Location: " . $_SERVER['PHP_SELF'] . "?page=" . $_GET['page']); } else { header("Location: " . $_SERVER['PHP_SELF']); } exit; } // load page acordingly switch ($page) { case "domus_home_page": //if theme is iPhone, we want to show a menu instead of the location_tb if ($config['theme'] == 'iPhone' || $config['theme'] == 'mobileWebKit') {
/** * Build Module Table * * Description: * * @param $alias */ function buildModuleTable($anAliasable) { $lang = $_SESSION['frontObj']->getLanguageFile(); $config = $_SESSION['frontObj']->getConfig(); $modTypes = $_SESSION['frontObj']->getModuleTypes(); $alias = $anAliasable; $scene = $anAliasable; $multi_alias = $alias->isMultiAlias(); // check if A1,2 or just A1 $hvac_alias = $alias->isHVACAlias(); // check if HVAC module // check if is a multi alias, if true, use modules.tpl, if not use template acording to $type if ($multi_alias) { $tpl = "modules.tpl"; } else { $tpl = $modTypes->getModuleType($anAliasable->getAliasMap()->getType())->getModuleImage() . ".tpl"; } // create new template $mod = new Template(TPL_FILE_LOCATION . $tpl); $mod->set('config', $config); $mod->set('label', label_parse($anAliasable->getLabel(), false)); $mod->set('lang', $lang); if ($anAliasable->isAlias()) { $mod->set('code', $alias->getHouseDevice()); } if (!isset($_GET['page'])) { $_GET['page'] = 'domus_home_page'; } else { $mod->set('page', $_GET['page']); } // if alias is a multi alias, scene or HVAC, module state & dimlevel are not checked if ($anAliasable->statusAbility()) { try { if (on_state($config, $alias->getHouseDevice())) { $state = 'on'; $action = $config['cmd_off']; } else { $state = 'off'; $action = $config['cmd_on']; } } catch (Exception $e) { gen_error("buildLocationTable - on_state ", $e->getMessage()); exit; } $mod->set('action', $action); $mod->set('state', $state); if (strtolower(trim($modTypes->getModuleType($alias->getAliasMap()->getType())->getModuleType())) == DIMMABLE_D) { $mod->set('level', $this->level_calc(dim_level($config, $alias->getHouseDevice()))); } } elseif ($hvac_alias) { $result_arr = heyu_action($config, "hvac_control", $alias->getHouseDevice(), null, null, "mode"); // error_log("error of heyu_action in hvac ".$result_arr[0]. " count of result array [".count($result_arr)."]"); if ($result_arr[0] != "Error in HVAC result") { $mode = $result_arr[0]; } else { $mode = "OFF"; } if ($mode == "OFF") { $state = "off"; } else { $state = "on"; } $result_arr = heyu_action($config, "hvac_control", $alias->getHouseDevice(), null, null, "temp"); if ($result_arr[0] != "Error in HVAC result") { $temp = $result_arr[0]; } else { $temp = "?"; } $result_arr = heyu_action($config, "hvac_control", $alias->getHouseDevice(), null, null, "setpoint"); if ($result_arr[0] != "Error in HVAC result") { $setpoint = $result_arr[0]; } else { $setpoint = "?"; } $result_arr = heyu_action($config, "hvac_control", $alias->getHouseDevice(), null, null, "fan_mode"); if ($result_arr[0] != "Error in HVAC result") { $fan_mode = $result_arr[0]; } else { $fan_mode = "?"; } $result_arr = heyu_action($config, "hvac_control", $alias->getHouseDevice(), null, null, "setback_mode"); if ($result_arr[0] != "Error in HVAC result") { $setback_mode = $result_arr[0]; } else { $setback_mode = "?"; } $mod->set('state', $state); $mod->set('mode', $mode); $mod->set('temp', $temp); $mod->set('setpoint', $setpoint); $mod->set('fan_mode', $fan_mode); $mod->set('setback_mode', $setback_mode); } // return as html return $mod->fetch(TPL_FILE_LOCATION . $tpl); }
/** * run a scene * @url POST /runscene/$label */ public function runScene($label) { ## error_log("Enter turnOn for - ".$label); require_once '.' . DIRECTORY_SEPARATOR . 'apiinclude.php'; require_once '.' . DIRECTORY_SEPARATOR . 'include_globals.php'; $config = $_SESSION['frontObj']->getConfig(); if (!heyu_running()) { return array("status" => "heyu not running"); } if ($label) { $aScene = $heyuconf->getSceneForLabel($this->myLogin->getUser(), $label, false); if ($aScene) { try { heyu_action($config, "run", $aScene->getLabel()); } catch (Exception $e) { // noop } return array("status" => "done"); } else { error_log("runScene no scene found " . $label); } } return array("status" => "not done"); }