Пример #1
0
 /**
  * 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);
 }
Пример #2
0
 /**
  * Gets the alias state and dim level
  * @url GET /aliasstate/$label
  */
 public function getAliasState($label = null)
 {
     ## error_log("Enter getAliasState");
     require_once '.' . DIRECTORY_SEPARATOR . 'apiinclude.php';
     require_once '.' . DIRECTORY_SEPARATOR . 'include_globals.php';
     $config = $_SESSION['frontObj']->getConfig();
     $moduleTypes = $_SESSION['frontObj']->getModuleTypes();
     if (!heyu_running()) {
         return array("state" => -1, "level" => -1);
     }
     if ($label) {
         $anAlias = $heyuconf->getAliasforLabel($this->myLogin->getUser(), $label, false);
         if ($anAlias->isHVACAlias()) {
             $theResult = heyu_action($config, "hvac_control", $anAlias->getHouseDevice(), null, null, "mode");
             if ($theResult[0] == "Error in HVAC result" || $theResult[0] == "OFF") {
                 $theState = false;
             } else {
                 $theState = true;
             }
         } elseif ($anAlias->isMultiAlias()) {
             $theState = false;
         } else {
             $theState = on_state($config, $anAlias->getHouseDevice());
         }
         if (strtolower(trim($moduleTypes->getModuleType($anAlias->getAliasMap()->getType())->getModuleType())) == DIMMABLE_D) {
             $theLevel = dim_level($config, $anAlias->getHouseDevice());
         } else {
             $theLevel = 0;
         }
         if ($theState) {
             return array("state" => 1, "level" => $theLevel);
         }
     }
     return array("state" => 0, "level" => 0);
 }