diff --git a/README.md b/README.md index 3e60039..d9754a4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# FB.Switch v1.0.8.1-STABLE +# FB.Switch [![GitHub release](https://img.shields.io/github/release/bombcheck/FB.Switch.svg)](https://github.com/bombcheck/FB.Switch/releases/latest) *Webapp zur Steuerung und Verwaltung von 433-MHz-Funksteckdosen, FritzDect 200-Steckdosen und MiLight-Lampen.* @@ -16,8 +16,8 @@ * Audio-Feedback beim Betätigen bestimmter Buttons und dem Abschluss bestimmter Operationen ## Voraussetzungen: -* Webserver mit Apache/PHP5 (z.B. einen Raspberry Pi) -* PHP-Curl-Modul wird benötigt +* Webserver mit Apache, PHP5 oder PHP7 (z.B. einen Raspberry Pi) +* PHP-Curl- und PHP-MB-String-Modul werden benötigt * Benötigt keine Datenbank! ## Kompatible Hardware: diff --git a/VERSION b/VERSION index 5fab914..0310197 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.8.1-STABLE \ No newline at end of file +1.0.8.2-STABLE \ No newline at end of file diff --git a/config.php b/config.php index f8ce35c..5b6ea80 100644 --- a/config.php +++ b/config.php @@ -7,7 +7,7 @@ $plugin = false; $SysAlertMsg="FB.NET System Status KRITISCH"; $NoTimerAlertMsg="Timer ist deaktiviert"; -$FileVer="2.42"; +$FileVer="2.43"; //config.xml dateisystem rechte überprüfen if(!file_exists($CONFIG_FILENAME)) { @@ -183,18 +183,15 @@ } -function config_save($CONFIG_FILENAME, $xml) { - if(!isset($CONFIG_FILENAME)){ - global $CONFIG_FILENAME; - } - if(!isset($xml)){ - global $xml; - } +function config_save($CONFIGFILE = null, $xmldata = null) { + if($CONFIGFILE === null) { global $CONFIG_FILENAME; $CONFIGFILE = $CONFIG_FILENAME; } + if($xmldata === null) { global $xml; $xmldata = $xml; } + $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; - $dom->loadXML($xml->asXML()); - $dom->save($CONFIG_FILENAME); + $dom->loadXML($xmldata->asXML()); + $dom->save($CONFIGFILE); } function check_config_global() { diff --git a/get_fbdect_temp.php b/get_fbdect_temp.php index 2419969..b4b2821 100644 --- a/get_fbdect_temp.php +++ b/get_fbdect_temp.php @@ -40,7 +40,7 @@ if ($NewOutdoorDateDiff > 1800) { $NewOutdoorTemp = -1000; } else $NewOutdoorTemp = $NewOutdoorTemp[0]; - if ($NewOutdoorTemp == false || $NewOutdoorTemp == "") $NewOutdoorTemp = -1000; + if ($NewOutdoorTemp === false || $NewOutdoorTemp == "") $NewOutdoorTemp = -1000; } } @@ -49,16 +49,16 @@ $XMLdata = Fritzbox_GetHAactorsInfoXML(); foreach($xml->devices->device as $device) { if ($device->vendor == "fbdect200") { - if (Fritzbox_GetHAactorDataFromXML($XMLdata,trim($device->address->masterdip),'present') == 1) { - if($NewOutdoorTemp != false && trim($device->id) == $OutdoorTempSource) { - $ResStr .= trim($device->id).":".trim($NewOutdoorTemp)."|"; + if($NewOutdoorTemp !== false && trim($device->id) == $OutdoorTempSource) { + $ResStr .= trim($device->id).":".trim($NewOutdoorTemp)."|"; + } else { + if (Fritzbox_GetHAactorDataFromXML($XMLdata,trim($device->address->masterdip),'present') == 1) { + $ResStr .= trim($device->id).":".Fritzbox_GetHAactorDataFromXML($XMLdata,trim($device->address->masterdip),'temperature')."|"; } else { - $ResStr .= trim($device->id).":".Fritzbox_GetHAactorDataFromXML($XMLdata,trim($device->address->masterdip),'temperature')."|"; - } - } else { - $ResStr .= trim($device->id).":-1000|"; - } - } + $ResStr .= trim($device->id).":-1000|"; + } + } + } } } echo substr($ResStr, 0, strlen($ResStr)-1); diff --git a/index.php b/index.php index da8a3fd..5313984 100644 --- a/index.php +++ b/index.php @@ -19,7 +19,7 @@ } // Über Linkfunktion -> GET if (isset($_GET['action'])) { - $r_action = (string)$_GET['action']; + $r_action = (string)$_GET['action']; $r_type = (string)$_GET['type']; $r_id = (string)$_GET['id']; if (isset($_GET['async'])) { @@ -28,16 +28,28 @@ exit(); } - if($r_action == "toggle" and $r_type == "device"){ - $xpath='//device/id[.="'.$r_id.'"]/parent::*'; + if($r_action == "toggle" and $r_type == "device"){ + $xpath='//device/id[.="'.$r_id.'"]/parent::*'; $res = $xml->xpath($xpath); $parent = $res[0]; - if($parent[0]->status == "OFF"){ - $r_action = "on"; - }elseif($parent[0]->status == "ON"){ - $r_action = "off"; - } - } + if($parent[0]->status == "OFF"){ + $r_action = "on"; + }elseif($parent[0]->status == "ON"){ + $r_action = "off"; + } + } + + if($r_action == "status" and $r_type == "device"){ + $xpath='//device/id[.="'.$r_id.'"]/parent::*'; + $res = $xml->xpath($xpath); + $parent = $res[0]; + if($parent[0]->status == "OFF"){ + echo "0"; + }elseif($parent[0]->status == "ON"){ + echo "1"; + } + exit(); + } } if (isset($_POST['todo'])) { if ($_POST['todo'] == "sendmilight") { @@ -51,10 +63,10 @@ if (isset($_GET['timerrun'])) { require("send_msg.php"); require("timer.php"); - include("countdowntimer.php"); + include("countdowntimer.php"); if ($xml->global->timerGlobalRun != "false" && $xml->global->AlertState != "red") timer_check(); - ping_check(); - if ($xml->global->AlertState != "red") countdowntimer_check(); + ping_check(); + if ($xml->global->AlertState != "red") countdowntimer_check(); fbdect_check(); exit(); } diff --git a/js/fbswitch_1.js b/js/fbswitch_1.js index e513792..a64cf7a 100644 --- a/js/fbswitch_1.js +++ b/js/fbswitch_1.js @@ -211,6 +211,7 @@ var DevicesTemp = response.split('|'); var IndoorTemp = ""; var OutdoorTemp = ""; + var ShowTemp = false; if (DevicesTemp.length > 0) { for (tIndex = 0; tIndex < DevicesTemp.length; ++tIndex) { @@ -220,12 +221,14 @@ IndoorTemp = parseInt(tempvar[1]) / 10; if (IndoorTemp == -100) IndoorTemp = '---'; else IndoorTemp = IndoorTemp.toFixed(1) + ' °C'; + ShowTemp = true; } if (tempvar[0] == ) { OutdoorTemp = parseInt(tempvar[1]) / 10; if (OutdoorTemp == -100) OutdoorTemp = '---'; else OutdoorTemp = OutdoorTemp.toFixed(1) + ' °C'; + ShowTemp = true; } } if (IndoorTemp == "") IndoorTemp = '---'; @@ -256,7 +259,8 @@ // var OutdoorTemp = '---'; // } - if (IndoorTemp != '---' || OutdoorTemp != '---') { + //if (IndoorTemp != '---' || OutdoorTemp != '---') { + if (ShowTemp == true) { $('#tempmsg_favs').fadeIn('fast'); $('#tempmsg_devs').fadeIn('fast'); $('#tempmsg_groups').fadeIn('fast'); diff --git a/milight_ajax.php b/milight_ajax.php index 4a611bc..b37f040 100644 --- a/milight_ajax.php +++ b/milight_ajax.php @@ -5,7 +5,7 @@ $milight = new Milight($_GET['mlip'], (integer)$_GET['mlport']); $milight->setDelay(0); -$milight->setRepeats(3); +$milight->setRepeats(1); $milight->setRgbwActiveGroup((integer)$_GET['mlgroup']); if (isset($_GET['off'])) {