<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Floorplan2</title><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><meta name="HandheldFriendly" content="true"/><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><meta name="viewport" content="width=device-width,height=device-height,user-scalable=yes,minimal-ui"/><link rel="icon" type="image/png" href="images/domoticzphp48.png"/><link rel="shortcut icon" href="images/domoticzphp48.png"/><link rel="apple-touch-startup-image" href="images/domoticzphp450.png"/><link rel="apple-touch-icon" href="images/domoticzphp48.png"/><meta name="msapplication-TileColor" content="#ffffff"><meta name="msapplication-TileImage" content="images/domoticzphp48.png"><meta name="msapplication-config" content="browserconfig.xml"><meta name="mobile-web-app-capable" content="yes"><link rel="manifest" href="manifest.json"><meta name="theme-color" content="#ffffff"><link href="floorplan.css" rel="stylesheet" type="text/css"/><style>body{background-image:none;}</style></head><body>
<?php 
require "secure/settings.php";
require "secure/functions2.php";
if ($authenticated) {
    if (isset($_POST['Schakel'])) {
        if (Schakel($_POST['Schakel'], $_POST['Actie'], $_POST['Naam']) == 'ERROR') {
            echo '<div id="message" class="balloon">' . $_POST['Naam'] . ' ' . $_POST['Actie'] . '<br/>ERROR</div>';
        }
        if (isset($_POST['halfuurwater'])) {
            cset('water', 1800);
        }
    } else {
        if (isset($_POST['Udevice'])) {
            if (Udevice($_POST['Udevice'], $_POST['Naam']) == 'ERROR') {
                echo '<div id="message" class="balloon">' . $_POST['Naam'] . ' ' . $_POST['Actie'] . '<br/>ERROR</div>';
            }
        } else {
            if (isset($_POST['imacpicam1'])) {
                shell_exec('/volume1/web/secure/picam1.sh');
            } else {
                if (isset($_POST['imacsleep'])) {
                    shell_exec('/volume1/web/secure/imacsleep.sh');
                }
            }
        }
    }
    $domoticz = json_decode(file_get_contents($domoticzurl . 'json.htm?type=devices&used=true&plan=5', true, $ctx), true);
    $domotime = microtime(true) - $start;
    //&plan=2
    if ($domoticz) {
             echo '<div id="message" class="balloon">' . $_POST['Naam'] . ' ' . $_POST['Actie'] . '<br/>ERROR</div>';
         }
     }
 } else {
     if (isset($_POST['Setpoint'])) {
         foreach ($_POST as $key => $value) {
             $value = round($value, 0);
             if (substr($key, 0, 5) == "Actie") {
                 if (Udevice($_POST['Setpoint'], 0, $value) == 'ERROR') {
                     echo '<div id="message" class="balloon">' . $_POST['Naam'] . ' ' . $value . '<br/>ERROR</div>';
                 }
             }
         }
     } else {
         if (isset($_POST['Udevice'])) {
             if (Udevice($_POST['Udevice']) == 'ERROR') {
                 echo '<div id="message" class="balloon">' . $_POST['Naam'] . ' ' . $_POST['Actie'] . '<br/>ERROR</div>';
             }
         } else {
             if (isset($_POST['dimlevelEettafel'])) {
                 if (Dim(163, $_POST['dimlevelEettafel']) == 'ERROR') {
                     echo '<div id="message" class="balloon">Dimmer eettafel level ' . $_POST['dimlevelEettafel'] . '<br/>ERROR</div>';
                 }
             } else {
                 if (isset($_POST['dimlevelZithoek'])) {
                     if (Dim(159, $_POST['dimlevelZithoek']) == 'ERROR') {
                         echo '<div id="message" class="balloon">Dimmer eettafel level ' . $_POST['dimlevelEettafel'] . '<br/>ERROR</div>';
                     }
                 } else {
                     if (isset($_POST['Scene'])) {
                         if (Scene($_POST['Scene']) == 'ERROR') {
     $totalrain = $totalrain + substr($rain, 0, 3);
     $averagerain = round($totalrain / $aantal, 0);
     if ($aantal == 12) {
         break;
     }
 }
 if ($averagerain >= 0) {
     $mc->set('averagerain', $averagerain);
 }
 $openweathermap = file_get_contents('http://api.openweathermap.org/data/2.5/weather?id=2787891&APPID=ac3485b0bf1a02a81d2525db6515021d&units=metric');
 $openweathermap = json_decode($openweathermap, true);
 if (isset($openweathermap['weather']['0']['icon'])) {
     $mc->set('weatherimg', $openweathermap['weather']['0']['icon']);
     $newtemp = round(($openweathermap['main']['temp'] + $Tbuiten) / 2, 1);
     if ($newtemp != $Tbuiten) {
         Udevice(22, 0, $newtemp, 'Buiten = ' . $openweathermap['main']['temp']);
     }
 }
 //KODI
 if ($Skodi == 'On' && $STkodi < $driemin) {
     $status = pingDomain('192.168.0.7', 1597);
     if (is_int($status)) {
         sleep(5);
         $status2 = pingDomain('192.168.0.7', 1597);
         if (is_int($status2)) {
             Schakel($SIkodi, 'Off', 'kodi');
         }
     }
 }
 //diskstation
 if ($Sdiskstation == 'On' && $STdiskstation < $driemin) {
                }
            } else {
                if ($action == "sleep") {
                    if (${'Dlevel' . $place} > 1 && $mc->get('dimmer' . $place) != 1) {
                        $mc->set('dimmer' . $place, 1);
                        Dim(${'DI' . $place}, ${'Dlevel' . $place} - 1, $place);
                    }
                } else {
                    if ($action == "dimmer") {
                        if (${'Dlevel' . $place} != $detail) {
                            Dim(${'DI' . $place}, $detail, 'GCal ' . $place . ' ');
                        }
                    } else {
                        if ($action == "schakel") {
                            if (${'S' . $place} != $detail) {
                                Schakel(${'SI' . $place}, $detail, 'GCal ' . $place . ' ');
                            }
                        } else {
                            if ($action == "setpoint") {
                                $mc->set('setpoint' . ${'RI' . $place}, 2);
                                if (${'R' . $place} != $detail) {
                                    Udevice(${'RI' . $place}, 0, $detail, 'GCal ' . $place . ' ');
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
{
    if ($time < 1) {
        return;
    }
    $hours = floor($time / 60);
    $minutes = $time % 60;
    return sprintf($format, $hours, $minutes);
}
if ($authenticated === true || basename($_SERVER['PHP_SELF']) == 'pass2php.time.php') {
    if (isset($_POST['Schakel'])) {
        if (Schakel($_POST['Schakel'], $_POST['Actie'], $_POST['Naam']) == 'ERROR') {
            echo '<div id="message" class="balloon">' . $_POST['Naam'] . ' ' . $_POST['Actie'] . '<br/>ERROR</div>';
        }
    }
    if (isset($_POST['Setpoint'])) {
        if (Udevice($_POST['Setpoint'], 0, number_format($_POST['Actie'], 1), $_POST['Naam']) == 'ERROR') {
            echo '<div id="message" class="balloon">' . $_POST['Naam'] . ' ' . $value . '<br/>ERROR</div>';
        } else {
            cset('setpoint' . $_POST['Naam'], 2);
        }
    }
    $domoticz = json_decode(file_get_contents($domoticzurl . 'json.htm?type=devices&used=true&plan=4'), true);
    foreach ($domoticz['result'] as $dom) {
        isset($dom['Type']) ? $Type = $dom['Type'] : ($Type = 'None');
        isset($dom['SwitchType']) ? $SwitchType = $dom['SwitchType'] : ($SwitchType = 'None');
        isset($dom['SubType']) ? $SubType = $dom['SubType'] : ($SubType = 'None');
        $name = $dom['Name'];
        if ($Type == 'Temp') {
            ${'T' . $name} = $dom['Temp'];
            ${'TI' . $name} = $dom['idx'];
            ${'TT' . $name} = strtotime($dom['LastUpdate']);
                         echo '<div id="message" class="balloon">Dimmer ' . $_POST['Naam'] . ' level ' . $_POST['dimlevel'] . '<br/>ERROR</div>';
                     }
                     $mc->set('dimmer' . $_POST['Naam'], 2);
                 } else {
                     if (Dim($_POST['dimmer'], $_POST['dimlevel'], $_POST['Naam']) == 'ERROR') {
                         echo '<div id="message" class="balloon">Dimmer ' . $_POST['Naam'] . ' level ' . $_POST['dimlevel'] . '<br/>ERROR</div>';
                     }
                     $mc->set('dimtime' . $_POST['Naam'], $time);
                     $mc->set('dimmer' . $_POST['Naam'], 0);
                 }
             }
         }
     }
 } else {
     if (isset($_POST['Scene'])) {
         if (Udevice($_POST['Scene'], 1, 'On', $_POST['Naam']) == 'ERROR') {
             echo '<div id="message" class="balloon">Scene ' . $_POST['Naam'] . ' activeren' . '<br/>ERROR</div>';
         }
         if ($_POST['Scene'] == 5) {
             $mc->set('dimtimeEettafel', $time);
         }
     } else {
         if (isset($_POST['restart'])) {
             telegram('Restart Domoticz executed by ' . $user);
             telegram(shell_exec('/var/www/secure/restart_domoticz'));
         } else {
             if (isset($_POST['reboot'])) {
                 telegram('Reboot Domoticz Rpi executed by ' . $user);
                 shell_exec('sudo /var/www/secure/reboot');
             } else {
                 if (isset($_POST['healnetwork'])) {