]> _ Git - tortuga-home.git/commitdiff
.
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Sun, 3 Sep 2023 14:52:37 +0000 (16:52 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Sun, 3 Sep 2023 14:52:37 +0000 (16:52 +0200)
.idea/workspace.xml
config/entree.php
js/home.js
scripts/lib/lib.php
scripts/lib/weatherstation.php
scripts/lib/windows.php [new file with mode: 0644]
scripts/lock.php [new file with mode: 0644]
style/style.css
style/style.less

index 84e8fabe9693a7a9a4f2cc4b0379a1deba8b8e94..6141cba7c168a844512cb126b02e96ed057b3a7c 100644 (file)
@@ -5,8 +5,15 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
+      <change afterPath="$PROJECT_DIR$/scripts/lib/windows.php" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/scripts/lock.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/homeassistant_device_event.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/homeassistant_device_event.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/config/entree.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/entree.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/js/home.js" beforeDir="false" afterPath="$PROJECT_DIR$/js/home.js" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/lib.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/lib.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/weatherstation.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/weatherstation.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/style/style.css" beforeDir="false" afterPath="$PROJECT_DIR$/style/style.css" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/style/style.less" beforeDir="false" afterPath="$PROJECT_DIR$/style/style.less" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1693209704251" duration="1417000" />
       <workItem from="1693322814662" duration="2000" />
       <workItem from="1693464071297" duration="2018000" />
-      <workItem from="1693471119520" duration="70000" />
+      <workItem from="1693471119520" duration="1065000" />
+      <workItem from="1693742530467" duration="7018000" />
     </task>
     <task id="LOCAL-00502" summary=".">
       <created>1641726946298</created>
       <option name="project" value="LOCAL" />
       <updated>1687259667913</updated>
     </task>
-    <option name="localTasksCounter" value="592" />
+    <option name="localTasksCounter" value="593" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index 155dda461a893fcf5da3e05f39e4b6dcbd892c92..9cf71342df007d34af500deea00f4770d99b11e6 100644 (file)
@@ -5,23 +5,23 @@ config('SQUEEZEBOX_PLAYER', 'Cuisine');
 config('SLEEPSCREEN', 15);
 config('SCREENSAVER_BRIGHTNESS', 100);
 config('SLEEPTYPE', 'screensaver');
-config('SCREENSAVER','weatherstation');
+config('SCREENSAVER', 'weatherstation');
 config('VOLUME_DEVICE', 'SqueezeboxPlayer');
-config('VOLUME_STEP',5);
-config('HIDEMASK_TIMEOUT',250);
-config('THEME','#000000');
+config('VOLUME_STEP', 5);
+config('HIDEMASK_TIMEOUT', 250);
+config('THEME', '#000000');
 
 if (DISPLAYINTERFACE) {
-       if (!isset($shortcuts)) {
-               $shortcuts = [];
-       }
+    if (!isset($shortcuts)) {
+        $shortcuts = [];
+    }
 
-       $c = home();
-       $shortcuts['lights'] = $c['all'];
-       $favoriteslights = $c['favorites'];
-       array_splice($favoriteslights, 3, 0, [['type' => 'velib'], ['type' => 'traffic']]);
+    $c = home();
+    $shortcuts['lights'] = $c['all'];
+    $favoriteslights = $c['favorites'];
+    array_splice($favoriteslights, 3, 0, [['type' => 'lock'], ['type' => 'velib'], ['type' => 'traffic']]);
 
-    $nav=['home','lights','music','coffee','switch','settings','alert','off'];
+    $nav = ['home', 'lights', 'music', 'coffee', 'switch', 'settings', 'alert', 'off'];
 
-       include "default.php";
+    include "default.php";
 }
index 799e047cef48268271fe5fba111feef6bec93e2c..8607a6aa9cabdce17b89ccbea24186f84be81ecc 100644 (file)
@@ -399,6 +399,7 @@ $(function () {
     initWeather();
     initTraffic();
     initVelib();
+    initLocks();
 
     setTimeout(function () {
         console.log('init');
@@ -706,6 +707,38 @@ function initTraffic() {
     updateTraffic(false);
 }
 
+function initLocks() {
+    $(document).on('click', ".lock", function () {
+        displayLoader($(this));
+        updateLocks();
+    });
+    setInterval(function () {
+        updateLocks();
+    }, 1000 * 15);
+    updateLocks();
+}
+
+function updateLocks() {
+    var t = $(".lock");
+    if (t.length == 0) {
+        return;
+    }
+    let url = 'scripts/lock.php';
+    $.get(url + '?' + new Date().getTime(), function (data) {
+        if (data.secured) {
+            $(t).addClass('secured');
+        } else {
+            $(t).removeClass('secured');
+        }
+        t.find('.icon').text(data.icon);
+        t.attr('data-init', '1');
+        resize();
+        hideLoader();
+    }).fail(function () {
+        hideLoader();
+    });
+}
+
 function updateTraffic(force) {
     var t = $(".traffic");
     if (t.length == 0) {
index 016d69052d3f1174803084501c91543ffeb84cb8..fd94442f6313e3d509d94fef900e5ff9051dea1e 100644 (file)
@@ -55,6 +55,7 @@ require_once ROOT . '/scripts/lib/wol.php';
 require_once ROOT . '/scripts/lib/switchbot.php';
 require_once ROOT . '/scripts/lib/ical.php';
 require_once ROOT . '/scripts/lib/klarstein.php';
+require_once ROOT . '/scripts/lib/windows.php';
 
 
 profile('Loaded libraries', __FILE__, __LINE__);
@@ -308,7 +309,12 @@ function shortcut($s, $hash)
 <ul class="issy"><li class="car"></li><li class="subway"></li><li class="bike"></li></ul>
 <div class="total_jams"><span class="jams"></span> de bouchons</div>';
 
-    } elseif ($s['type'] == 'velib') {
+    } else if($s['type']==='lock'){
+        $attrs['class'] = $s['type'] . ' info';
+        $attrs['data-init'] = "0";
+        $attrs['data-init-function'] = "updateLocks";
+        $s['label']='<div class="icon"></div>';
+    }elseif ($s['type'] == 'velib') {
         $attrs['class'] = $s['type'] . ' info';
         $attrs['data-init'] = "0";
         $attrs['data-init-function'] = "updateVelib";
index 11255a579d397a32e5687a855280530e4c2978c6..4488b71a7c14019cca6e7f6e9cc035a6d99c2ddf 100644 (file)
 <?php
 
-function getWeather() {
-       $place = 623;
-       $apikey = 'fM7z3yrWwnUuXuAPPYIM5EqTl2iBAGB6';
-
-       $cache = ROOT . '/cache/accuweather.json';
-       $limit = max(time() - 3600, 0);
-
-       if (!file_exists($cache) || filemtime($cache) < $limit) {
-               copy('http://dataservice.accuweather.com/currentconditions/v1/' . $place . '?apikey=' . $apikey . '&language=fr-FR&details=true', $cache);
-       }
-
-       $res = [];
-       $weather = json_decode(file_get_contents($cache), true);
-       $weather = $weather[0];
-       $res['temp'] = round(($weather['Temperature']['Metric']['Value']/* + getState('airtemperature')*/));
-       $res['outdoor_temp'] = toNumber(haGetState(['sensor.indoor_outdoor_meter_ddf7_temperature', 'sensor.w340001x_tempc']), 1);
-       $res['outdoor_humidity'] = toNumber(haGetState(['sensor.indoor_outdoor_meter_ddf7_humidity', 'sensor.w340001x_hum']), true);
-       $res['outdoor_pressure'] = toNumber(haGetState('sensor.0x00158d000464c885_pressure'), true);
-       $res['backyard_temp'] = toNumber(haGetState('sensor.0x00158d000464c885_temperature'), 1);
-       $res['backyard_humidity'] = toNumber(haGetState('sensor.0x00158d000464c885_humidity'), true);
-       $res['backyard_pressure'] = toNumber(haGetState('sensor.0x00158d000464c885_pressure'), true);
-       $res['bathroom_temp'] = toNumber(haGetState('sensor.0x00158d0004658cc2_temperature'), 1);
-       $res['bathroom_humidity'] = toNumber(haGetState('sensor.0x00158d0004658cc2_humidity'), true);
-       $res['bedroom_temp'] = toNumber(haGetState('sensor.0x54ef4410003596e5_temperature'), 1);
-       $res['bedroom_humidity'] = toNumber(haGetState('sensor.0x54ef4410003596e5_humidity'), true);
-       $res['bedroom_airquality'] = toNumber(haGetState('sensor.0x54ef4410003596e5_voc'), true);
-       $res['livingroom_temp'] = toNumber(haGetState('sensor.temperature_salon_temperature'), 1);
-       $res['livingroom_humidity'] = toNumber(haGetState('sensor.temperature_salon_humidity'), true);
-       $res['kitchen_temp'] = toNumber(haGetState('sensor.0x00158d000418441f_temperature'), 1);
-       $res['kitchen_humidity'] = toNumber(haGetState('sensor.0x00158d000418441f_humidity'), true);
-       $res['wc_temp'] = toNumber(haGetState('sensor.0x00158d00046574da_temperature'), 1);
-       $res['wc_humidity'] = toNumber(haGetState('sensor.0x00158d00046574da_humidity'), true);
-       $res['office_temp'] = toNumber(haGetState(['sensor.meter_c7c3_temperature', 'sensor.thx1_w230150x_tempc']), 1);
-       $res['office_humidity'] = toNumber(haGetState(['sensor.meter_c7c3_humidite', 'sensor.thx1_w230150x_hum']), true);
-       //      $res['cellar_humidity'] = toNumber(getDomoticzDeviceStatus(4818), true);
-       //      $res['cellar_temp'] = toNumber(getDomoticzDeviceStatus(4817), 1);
-       $res['cellar_humidity'] = 0;
-       $res['cellar_temp'] = 0;
-       $res['pressure'] = round($weather['Pressure']['Metric']['Value']);
-       $res['pressureTendency'] = $weather['PressureTendency']['Code'];
-       $res['precipitations24'] = round($weather['PrecipitationSummary']['Past24Hours']['Metric']['Value']);
-       $res['cloudCover'] = $weather['CloudCover'];
-       $res['ceiling'] = $weather['Ceiling']['Imperial']['Value'];
-       $res['icon'] = $weather['WeatherIcon'];
-       if ($res['icon'] < 10) {
-               $res['icon'] = '0' . $res['icon'];
-       }
-
-       $cache = ROOT . '/cache/accuforecasts.json';
-       if (!file_exists($cache) || filemtime($cache) < $limit) {
-               copy('http://dataservice.accuweather.com/forecasts/v1/daily/5day/' . $place . '?apikey=' . $apikey . '&language=fr-FR&metric=true&details=true', $cache);
-       }
-       $forecasts = json_decode(file_get_contents($cache), true);
-       $f = $forecasts['DailyForecasts'][0];
-       $res['dayIcon'] = $f['Day']['Icon'];
-
-       if ($res['dayIcon'] < 10) {
-               $res['dayIcon'] = '0' . $res['dayIcon'];
-       }
-       $res['nightIcon'] = $f['Night']['Icon'];
-       if ($res['nightIcon'] < 10) {
-               $res['nightIcon'] = '0' . $res['nightIcon'];
-       }
-       $res['min'] = round($f['Temperature']['Minimum']['Value']);
-       $res['max'] = round($f['Temperature']['Maximum']['Value']);
-
-       $res['sunrise'] = $f['Sun']['EpochRise'];
-       $res['sunset'] = $f['Sun']['EpochSet'];
-       $res['moon'] = $f['Moon']['Phase'];
-       $res['moonage'] = $f['Moon']['Age'];
-       $res['moonrise'] = $f['Moon']['EpochRise'];
-       $res['moonset'] = $f['Moon']['EpochSet'];
-
-       $res['forecasts'] = [];
-       $days = ['D', 'L', 'M', 'M', 'J', 'V', 'S'];
-       for ($i = 1; $i <= 4; $i++) {
-               $j = $i - 1;
-               $res['forecasts'][$j] = [];
-               $f = $forecasts['DailyForecasts'][$i];
-               $res['forecasts'][$j]['dayIcon'] = $f['Day']['Icon'];
-
-               if ($res['forecasts'][$j]['dayIcon'] < 10) {
-                       $res['forecasts'][$j]['dayIcon'] = '0' . $res['forecasts'][$j]['dayIcon'];
-               }
-               $res['forecasts'][$j]['nightIcon'] = $f['Night']['Icon'];
-               if ($res['forecasts'][$j]['nightIcon'] < 10) {
-                       $res['forecasts'][$j]['nightIcon'] = '0' . $res['forecasts'][$j]['nightIcon'];
-               }
-               $res['forecasts'][$j]['min'] = round($f['Temperature']['Minimum']['Value']);
-               $res['forecasts'][$j]['max'] = round($f['Temperature']['Maximum']['Value']);
-               $res['forecasts'][$j]['day'] = $days[date('w', $f['EpochDate'])];
-       }
-
-       file_put_contents(ROOT . '/cache/weather.json', json_encode($res));
-       return $res;
+function getWeather()
+{
+    $place = 623;
+    $apikey = 'fM7z3yrWwnUuXuAPPYIM5EqTl2iBAGB6';
+
+    $cache = ROOT . '/cache/accuweather.json';
+    $limit = max(time() - 3600, 0);
+
+    if (!file_exists($cache) || filemtime($cache) < $limit) {
+        copy('http://dataservice.accuweather.com/currentconditions/v1/' . $place . '?apikey=' . $apikey . '&language=fr-FR&details=true', $cache);
+    }
+
+    $res = [];
+    $weather = json_decode(file_get_contents($cache), true);
+    $weather = $weather[0];
+    $res['temp'] = round(($weather['Temperature']['Metric']['Value']/* + getState('airtemperature')*/));
+    $res['outdoor_temp'] = toNumber(haGetState(['sensor.indoor_outdoor_meter_ddf7_temperature', 'sensor.w340001x_tempc']), 1);
+    $res['outdoor_humidity'] = toNumber(haGetState(['sensor.indoor_outdoor_meter_ddf7_humidity', 'sensor.w340001x_hum']), true);
+    $res['outdoor_pressure'] = toNumber(haGetState('sensor.0x00158d000464c885_pressure'), true);
+    $res['backyard_temp'] = toNumber(haGetState('sensor.indoor_outdoor_meter_1719'), 1);
+    $res['backyard_humidity'] = toNumber(haGetState('sensor.indoor_outdoor_meter_1719_humidite'), true);
+    $res['backyard_pressure'] = toNumber(haGetState('sensor.0x00158d0004658cc2_pressure'), true);
+    $res['bathroom_temp'] = toNumber(haGetState('sensor.0x00158d0004658cc2_temperature'), 1);
+    $res['bathroom_humidity'] = toNumber(haGetState('sensor.0x00158d0004658cc2_humidity'), true);
+    $res['bedroom_temp'] = toNumber(haGetState('sensor.0x54ef4410003596e5_temperature'), 1);
+    $res['bedroom_humidity'] = toNumber(haGetState('sensor.0x54ef4410003596e5_humidity'), true);
+    $res['bedroom_airquality'] = toNumber(haGetState('sensor.0x54ef4410003596e5_voc'), true);
+    $res['livingroom_temp'] = toNumber(haGetState('sensor.temperature_salon_temperature'), 1);
+    $res['livingroom_humidity'] = toNumber(haGetState('sensor.temperature_salon_humidity'), true);
+    $res['kitchen_temp'] = toNumber(haGetState('sensor.0x00158d000418441f_temperature'), 1);
+    $res['kitchen_humidity'] = toNumber(haGetState('sensor.0x00158d000418441f_humidity'), true);
+    $res['wc_temp'] = toNumber(haGetState('sensor.0x00158d00046574da_temperature'), 1);
+    $res['wc_humidity'] = toNumber(haGetState('sensor.0x00158d00046574da_humidity'), true);
+    $res['office_temp'] = toNumber(haGetState(['sensor.meter_c7c3_temperature', 'sensor.thx1_w230150x_tempc']), 1);
+    $res['office_humidity'] = toNumber(haGetState(['sensor.meter_c7c3_humidite', 'sensor.thx1_w230150x_hum']), true);
+    // $res['cellar_humidity'] = toNumber(getDomoticzDeviceStatus(4818), true);
+    // $res['cellar_temp'] = toNumber(getDomoticzDeviceStatus(4817), 1);
+    $res['cellar_humidity'] = 0;
+    $res['cellar_temp'] = 0;
+    $res['pressure'] = round($weather['Pressure']['Metric']['Value']);
+    $res['pressureTendency'] = $weather['PressureTendency']['Code'];
+    $res['precipitations24'] = round($weather['PrecipitationSummary']['Past24Hours']['Metric']['Value']);
+    $res['cloudCover'] = $weather['CloudCover'];
+    $res['ceiling'] = $weather['Ceiling']['Imperial']['Value'];
+    $res['icon'] = $weather['WeatherIcon'];
+    if ($res['icon'] < 10) {
+        $res['icon'] = '0' . $res['icon'];
+    }
+
+    $cache = ROOT . '/cache/accuforecasts.json';
+    if (!file_exists($cache) || filemtime($cache) < $limit) {
+        copy('http://dataservice.accuweather.com/forecasts/v1/daily/5day/' . $place . '?apikey=' . $apikey . '&language=fr-FR&metric=true&details=true', $cache);
+    }
+    $forecasts = json_decode(file_get_contents($cache), true);
+    $f = $forecasts['DailyForecasts'][0];
+    $res['dayIcon'] = $f['Day']['Icon'];
+
+    if ($res['dayIcon'] < 10) {
+        $res['dayIcon'] = '0' . $res['dayIcon'];
+    }
+    $res['nightIcon'] = $f['Night']['Icon'];
+    if ($res['nightIcon'] < 10) {
+        $res['nightIcon'] = '0' . $res['nightIcon'];
+    }
+    $res['min'] = round($f['Temperature']['Minimum']['Value']);
+    $res['max'] = round($f['Temperature']['Maximum']['Value']);
+
+    $res['sunrise'] = $f['Sun']['EpochRise'];
+    $res['sunset'] = $f['Sun']['EpochSet'];
+    $res['moon'] = $f['Moon']['Phase'];
+    $res['moonage'] = $f['Moon']['Age'];
+    $res['moonrise'] = $f['Moon']['EpochRise'];
+    $res['moonset'] = $f['Moon']['EpochSet'];
+
+    $res['forecasts'] = [];
+    $days = ['D', 'L', 'M', 'M', 'J', 'V', 'S'];
+    for ($i = 1; $i <= 4; $i++) {
+        $j = $i - 1;
+        $res['forecasts'][$j] = [];
+        $f = $forecasts['DailyForecasts'][$i];
+        $res['forecasts'][$j]['dayIcon'] = $f['Day']['Icon'];
+
+        if ($res['forecasts'][$j]['dayIcon'] < 10) {
+            $res['forecasts'][$j]['dayIcon'] = '0' . $res['forecasts'][$j]['dayIcon'];
+        }
+        $res['forecasts'][$j]['nightIcon'] = $f['Night']['Icon'];
+        if ($res['forecasts'][$j]['nightIcon'] < 10) {
+            $res['forecasts'][$j]['nightIcon'] = '0' . $res['forecasts'][$j]['nightIcon'];
+        }
+        $res['forecasts'][$j]['min'] = round($f['Temperature']['Minimum']['Value']);
+        $res['forecasts'][$j]['max'] = round($f['Temperature']['Maximum']['Value']);
+        $res['forecasts'][$j]['day'] = $days[date('w', $f['EpochDate'])];
+    }
+
+    file_put_contents(ROOT . '/cache/weather.json', json_encode($res));
+    return $res;
 }
 
-function weatherStationScreenSaver() {
-       $weather = json_decode(file_get_contents(ROOT . '/cache/weather.json'), true);
-
-       $pressureTendency = $weather['pressureTendency'] == 'F' ? 'down' : 'up';
-       $pressure = $weather['outdoor_pressure'] == '--' ? $weather['backyard_pressure'] : $weather['outdoor_pressure'];
-
-       $res = '<div id="weatherstation" class="screensaver">';
-       $res .= '<div class="contents">';
-       $res .= '<div class="time"></div>';
-       $res .= '<div class="current">';
-       $res .= '<div class="icon">' . accuweatherIcon($weather['icon']) . '</div>';
-       $res .= '<div class="icons">';
-       $res .= '<div class="night">' . accuweatherIcon($weather['nightIcon']) . '</div>';
-       $res .= '<div class="day">' . accuweatherIcon($weather['dayIcon']) . '</div>';
-       $res .= '</div>';
-       $res .= '<div class="temps">';
-       $res .= '<div class="temp-min">' . $weather['min'] . '°C</div>';
-       $res .= '<div class="temp"> ' . $weather['outdoor_temp'] . '°C <span style="font-size:20%;"> ' . $weather['temp'] . '°C</span></div>';
-       $res .= '<div class="temp-max">' . $weather['max'] . '°C</div>';
-       $res .= '</div>';
-       $res .= '<div class="pp">';
-       $res .= '<i class="fas fa-cloud-rain"></i> ' . $weather['precipitations24'] . ' mm | <i class="fas fa-tachometer-alt"></i> ' . $pressure . ' hPa <i class="fa fa-arrow-circle-' . $pressureTendency . '"></i> | <i class="fa fa-tint"></i> ' . $weather['outdoor_humidity'] . '%';
-       $res .= '</div>';
-       $res .= '<table class="house">';
-       $res .= '<tr><td class="hicon backyard"><i class="fa fa-flower-tulip"></i></td><td class="backyard">' . $weather['backyard_temp'] . ' °C</td><td class="hicon hum backyard"><i class="fa fa-tint"></i></td><td class="hum backyard">' . $weather['backyard_humidity'] . '%</td>';
-       $res .= '<td class="sep"></td><td class="hicon kitchen"><i class="fa fa-knife-kitchen"></i></td><td class="kitchen">' . $weather['kitchen_temp'] . ' °C</td><td class="hicon hum kitchen"><i class="fa fa-tint"></i></td><td class="hum kitchen">' . $weather['kitchen_humidity'] . '%</td></tr>';
-       $res .= '<tr><td class="hicon livingroom"><i class="fa fa-cocktail"></i></td><td class="livingroom">' . $weather['livingroom_temp'] . ' °C</td><td class="hicon hum livingroom"><i class="fa fa-tint"></i></td><td class="hum livingroom">' . $weather['livingroom_humidity'] . '%</td>';
-       $res .= '<td class="sep"></td><td class="hicon office"><i class="fa fa-plane"></i></td><td class="office">' . $weather['office_temp'] . ' °C</td><td class="hicon hum office"><i class="fa fa-tint"></i></td><td class="hum office">' . $weather['office_humidity'] . '%</td></tr>';
-       $res .= '<tr><td class="hicon wc"><i class="fa fa-toilet"></i></td><td class="wc">' . $weather['wc_temp'] . ' °C</td><td class="hicon hum wc"><i class="fa fa-tint"></i></td><td class="hum wc">' . $weather['wc_humidity'] . '%</td>';
-       $res .= '<td class="sep"></td><td class="hicon bedroom"><i class="fa fa-bed"></i></td><td class="bedroom">' . $weather['bedroom_temp'] . ' °C</td><td class="hicon hum bedroom"><i class="fa fa-tint"></i></td><td class="hum bedroom">' . $weather['bedroom_humidity'] . '%</td>';
-       $res .= '<tr><td class="hicon bathroom"><i class="fa fa-bath"></i></td><td class="bathroom">' . $weather['bathroom_temp'] . ' °C</td><td class="hicon hum bathroom"><i class="fa fa-tint"></i></td><td class="hum bathroom">' . $weather['bathroom_humidity'] . '%</td>';
-       $res .= '<td class="sep"></td><td class="hicon cellar"><i class="fa fa-bat"></i></td><td class="cellar">' . $weather['cellar_temp'] . ' °C</td><td class="hicon hum cellar"><i class="fa fa-tint"></i></td><td class="hum cellar">' . $weather['cellar_humidity'] . '%</td></tr>';
-       $res .= '</table>';
-       $res .= '</div>';
-       $res .= '<div class="forecasts">';
-       foreach ($weather['forecasts'] as $forecast) {
-               $res .= '<div class="forecast">';
-               $res .= '<div class="weekday">' . $forecast['day'] . '</div>';
-               $res .= '<div class="night">' . accuweatherIcon($forecast['nightIcon']) . '</div>';
-               $res .= '<div class="day">' . accuweatherIcon($forecast['dayIcon']) . '</div>';
-               $res .= '<div class="temp-min">' . $forecast['min'] . '°C</div>';
-               $res .= '<div class="temp-max">' . $forecast['max'] . '°C</div>';
-               $res .= '</div>';
-       }
-       $res .= '</div>';
-
-       $res .= '<div class="curves">';
-       $res .= _curve($weather, 'sun');
-       $res .= _curve($weather, 'moon');
-       $res .= '</div>';
-       $res .= '</div>';
-
-       return $res;
+function weatherStationScreenSaver()
+{
+    $weather = json_decode(file_get_contents(ROOT . '/cache/weather.json'), true);
+
+    $pressureTendency = $weather['pressureTendency'] == 'F' ? 'down' : 'up';
+    $pressure = $weather['outdoor_pressure'] == '--' ? $weather['backyard_pressure'] : $weather['outdoor_pressure'];
+
+    $res = '<div id="weatherstation" class="screensaver">';
+    $res .= '<div class="contents">';
+    $res .= '<div class="time"></div>';
+    $res .= '<div class="current">';
+    $res .= '<div class="icon">' . accuweatherIcon($weather['icon']) . '</div>';
+    $res .= '<div class="icons">';
+    $res .= '<div class="night">' . accuweatherIcon($weather['nightIcon']) . '</div>';
+    $res .= '<div class="day">' . accuweatherIcon($weather['dayIcon']) . '</div>';
+    $res .= '</div>';
+    $res .= '<div class="temps">';
+    $res .= '<div class="temp-min">' . $weather['min'] . '°C</div>';
+    $res .= '<div class="temp"> ' . $weather['outdoor_temp'] . '°C <span style="font-size:20%;"> ' . $weather['temp'] . '°C</span></div>';
+    $res .= '<div class="temp-max">' . $weather['max'] . '°C</div>';
+    $res .= '</div>';
+    $res .= '<div class="pp">';
+    $res .= '<i class="fas fa-cloud-rain"></i> ' . $weather['precipitations24'] . ' mm | <i class="fas fa-tachometer-alt"></i> ' . $pressure . ' hPa <i class="fa fa-arrow-circle-' . $pressureTendency . '"></i> | <i class="fa fa-tint"></i> ' . $weather['outdoor_humidity'] . '%';
+    $res .= '</div>';
+    $res .= '<table class="house">';
+    $res .= '<tr><td class="hicon backyard"><i class="fa fa-flower-tulip"></i></td><td class="backyard">' . $weather['backyard_temp'] . ' °C</td><td class="hicon hum backyard"><i class="fa fa-tint"></i></td><td class="hum backyard">' . $weather['backyard_humidity'] . '%</td>';
+    $res .= '<td class="sep"></td><td class="hicon kitchen"><i class="fa fa-knife-kitchen"></i></td><td class="kitchen">' . $weather['kitchen_temp'] . ' °C</td><td class="hicon hum kitchen"><i class="fa fa-tint"></i></td><td class="hum kitchen">' . $weather['kitchen_humidity'] . '%</td></tr>';
+    $res .= '<tr><td class="hicon livingroom"><i class="fa fa-cocktail"></i></td><td class="livingroom">' . $weather['livingroom_temp'] . ' °C</td><td class="hicon hum livingroom"><i class="fa fa-tint"></i></td><td class="hum livingroom">' . $weather['livingroom_humidity'] . '%</td>';
+    $res .= '<td class="sep"></td><td class="hicon office"><i class="fa fa-plane"></i></td><td class="office">' . $weather['office_temp'] . ' °C</td><td class="hicon hum office"><i class="fa fa-tint"></i></td><td class="hum office">' . $weather['office_humidity'] . '%</td></tr>';
+    $res .= '<tr><td class="hicon wc"><i class="fa fa-toilet"></i></td><td class="wc">' . $weather['wc_temp'] . ' °C</td><td class="hicon hum wc"><i class="fa fa-tint"></i></td><td class="hum wc">' . $weather['wc_humidity'] . '%</td>';
+    $res .= '<td class="sep"></td><td class="hicon bedroom"><i class="fa fa-bed"></i></td><td class="bedroom">' . $weather['bedroom_temp'] . ' °C</td><td class="hicon hum bedroom"><i class="fa fa-tint"></i></td><td class="hum bedroom">' . $weather['bedroom_humidity'] . '%</td>';
+    $res .= '<tr><td class="hicon bathroom"><i class="fa fa-bath"></i></td><td class="bathroom">' . $weather['bathroom_temp'] . ' °C</td><td class="hicon hum bathroom"><i class="fa fa-tint"></i></td><td class="hum bathroom">' . $weather['bathroom_humidity'] . '%</td>';
+    $res .= '<td class="sep"></td><td class="hicon cellar"><i class="fa fa-bat"></i></td><td class="cellar">' . $weather['cellar_temp'] . ' °C</td><td class="hicon hum cellar"><i class="fa fa-tint"></i></td><td class="hum cellar">' . $weather['cellar_humidity'] . '%</td></tr>';
+    $res .= '</table>';
+    $res .= '</div>';
+    $res .= '<div class="forecasts">';
+    foreach ($weather['forecasts'] as $forecast) {
+        $res .= '<div class="forecast">';
+        $res .= '<div class="weekday">' . $forecast['day'] . '</div>';
+        $res .= '<div class="night">' . accuweatherIcon($forecast['nightIcon']) . '</div>';
+        $res .= '<div class="day">' . accuweatherIcon($forecast['dayIcon']) . '</div>';
+        $res .= '<div class="temp-min">' . $forecast['min'] . '°C</div>';
+        $res .= '<div class="temp-max">' . $forecast['max'] . '°C</div>';
+        $res .= '</div>';
+    }
+    $res .= '</div>';
+
+    $res .= '<div class="curves">';
+    $res .= _curve($weather, 'sun');
+    $res .= _curve($weather, 'moon');
+    $res .= '</div>';
+    $res .= '</div>';
+
+    return $res;
 }
 
-function _curve($weather, $curve) {
-       $time = time();
-
-       if ($curve == 'sun') {
-               $set = $weather['sunset'];
-               $rise = $weather['sunrise'];
-               $icon = '/images/weather/sun.svg';
-               $radius = 75;
-               $pointXOffset = 44;
-               $pointYOffset = 33;
-       } else {
-               $set = $weather['moonset'];
-               $rise = $weather['moonrise'];
-               $icon = '/images/weather/moon/' . (round(($weather['moonage'] / 28) * 12) % 12) . '.svg';
-               $radius = 50;
-               $pointXOffset = 33;
-               $pointYOffset = 21;
-       }
-
-       $diameter = $radius * 2;
-
-       $duration = 360 * (($set - $rise) / (3600 * 24));
-       $riseAngle = (180 - $duration) / 2;
-       $setAngle = $riseAngle + $duration;
-
-       //die('d '.$sunduration.';r '.$sunriseAngle.';s '.$sunsetAngle);
-
-       $sunrisePos = getPosOnCircle($riseAngle, $radius, $pointXOffset, $pointYOffset);
-       $sunsetPos = getPosOnCircle($setAngle, $radius, $pointXOffset, $pointYOffset);
-       $sunangle = $riseAngle + (($time - $rise) / (3600 * 24)) * 360;
-
-       $res = '<div class="curve curve-' . $curve . '">';
-       $res .= '<div class="astre" style="transform: rotate(' . $sunangle . 'deg)"><img src="' . $icon . '" width="20" height="20" style="transform: rotate(' . (-$sunangle) . 'deg)" /></div>';
-       if ($curve === 'sun') {
-               $res .= '<div class="orbit earth" style="background-image:url(\'/images/earth.png?j=' . filemtime(ROOT . '/images/earth.png') . '\'"></div>';
-       } else {
-               $res .= '<div class="orbit"></div>';
-       }
-       $res .= '<div class="horizon" style="top:' . ($sunrisePos['y'] + 3) . 'px;"></div>';
-       $res .= '<div class="point rise" style="top:' . $sunrisePos['y'] . 'px;left:' . $sunrisePos['x'] . 'px;"><span>' . date('H:i', $rise) . '</span></div>';
-       $res .= '<div class="point set" style="top:' . $sunsetPos['y'] . 'px;left:' . $sunsetPos['x'] . 'px;"><span>' . date('H:i', $set) . '</span></div>';
-       $res .= '</div>';
-
-       return $res;
+function _curve($weather, $curve)
+{
+    $time = time();
+
+    if ($curve == 'sun') {
+        $set = $weather['sunset'];
+        $rise = $weather['sunrise'];
+        $icon = '/images/weather/sun.svg';
+        $radius = 75;
+        $pointXOffset = 44;
+        $pointYOffset = 33;
+    } else {
+        $set = $weather['moonset'];
+        $rise = $weather['moonrise'];
+        $icon = '/images/weather/moon/' . (round(($weather['moonage'] / 28) * 12) % 12) . '.svg';
+        $radius = 50;
+        $pointXOffset = 33;
+        $pointYOffset = 21;
+    }
+
+    $diameter = $radius * 2;
+
+    $duration = 360 * (($set - $rise) / (3600 * 24));
+    $riseAngle = (180 - $duration) / 2;
+    $setAngle = $riseAngle + $duration;
+
+    //die('d '.$sunduration.';r '.$sunriseAngle.';s '.$sunsetAngle);
+
+    $sunrisePos = getPosOnCircle($riseAngle, $radius, $pointXOffset, $pointYOffset);
+    $sunsetPos = getPosOnCircle($setAngle, $radius, $pointXOffset, $pointYOffset);
+    $sunangle = $riseAngle + (($time - $rise) / (3600 * 24)) * 360;
+
+    $res = '<div class="curve curve-' . $curve . '">';
+    $res .= '<div class="astre" style="transform: rotate(' . $sunangle . 'deg)"><img src="' . $icon . '" width="20" height="20" style="transform: rotate(' . (-$sunangle) . 'deg)" /></div>';
+    if ($curve === 'sun') {
+        $res .= '<div class="orbit earth" style="background-image:url(\'/images/earth.png?j=' . filemtime(ROOT . '/images/earth.png') . '\'"></div>';
+    } else {
+        $res .= '<div class="orbit"></div>';
+    }
+    $res .= '<div class="horizon" style="top:' . ($sunrisePos['y'] + 3) . 'px;"></div>';
+    $res .= '<div class="point rise" style="top:' . $sunrisePos['y'] . 'px;left:' . $sunrisePos['x'] . 'px;"><span>' . date('H:i', $rise) . '</span></div>';
+    $res .= '<div class="point set" style="top:' . $sunsetPos['y'] . 'px;left:' . $sunsetPos['x'] . 'px;"><span>' . date('H:i', $set) . '</span></div>';
+    $res .= '</div>';
+
+    return $res;
 }
 
-function getPosOnCircle($angle, $radius, $x, $y) {
-       $angle -= 180;
-       $cos = $radius / 2 + (cos(deg2rad($angle)) * $radius);
-       $sin = $radius / 2 + (sin(deg2rad($angle)) * $radius);
+function getPosOnCircle($angle, $radius, $x, $y)
+{
+    $angle -= 180;
+    $cos = $radius / 2 + (cos(deg2rad($angle)) * $radius);
+    $sin = $radius / 2 + (sin(deg2rad($angle)) * $radius);
 
-       return ['x' => $x + $cos, 'y' => $y + $sin];
+    return ['x' => $x + $cos, 'y' => $y + $sin];
 }
 
-function accuweatherIcon($icon) {
-       return '<img src="/images/weather/' . $icon . '.svg" />';
-       // return '<img src="https://www.accuweather.com/images/weathericons/' . $icon . '.svg" />';
+function accuweatherIcon($icon)
+{
+    return '<img src="/images/weather/' . $icon . '.svg" />';
+    // return '<img src="https://www.accuweather.com/images/weathericons/' . $icon . '.svg" />';
 }
 
-function isDay() {
-       return getPeriodOfDay()['day'];
+function isDay()
+{
+    return getPeriodOfDay()['day'];
 }
 
-function getPeriodOfDay() {
-       $time = new DateTime('now', new DateTimeZone('Europe/Paris'));
-       $timestamp = $time->getTimestamp();
-       $offset = $time->getOffset() / 3600;
+function getPeriodOfDay()
+{
+    $time = new DateTime('now', new DateTimeZone('Europe/Paris'));
+    $timestamp = $time->getTimestamp();
+    $offset = $time->getOffset() / 3600;
 
-       $hours = intval(date('H'));
+    $hours = intval(date('H'));
 
-       $sunrise = date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, LATITUDE, LONGITUDE, 90, $offset);
-       $sunset = date_sunset($timestamp, SUNFUNCS_RET_TIMESTAMP, LATITUDE, LONGITUDE, 90, $offset);
+    $sunrise = date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, LATITUDE, LONGITUDE, 90, $offset);
+    $sunset = date_sunset($timestamp, SUNFUNCS_RET_TIMESTAMP, LATITUDE, LONGITUDE, 90, $offset);
 
-       if ($timestamp > $sunset && $sunrise < $sunset) {
-               $sunrise += 3600 * 24;
-       }
+    if ($timestamp > $sunset && $sunrise < $sunset) {
+        $sunrise += 3600 * 24;
+    }
 
 
-       $start_twilight = $sunset - 3600;
-       $end_twilight = $sunset + 3600;
+    $start_twilight = $sunset - 3600;
+    $end_twilight = $sunset + 3600;
 
-       $start_dawn = $sunrise - 3600;
-       $end_dawn = $sunrise + 3600;
+    $start_dawn = $sunrise - 3600;
+    $end_dawn = $sunrise + 3600;
 
-       $day = !($timestamp < $sunrise || $timestamp >= $sunset);
+    $day = !($timestamp < $sunrise || $timestamp >= $sunset);
 
-       if ($timestamp >= $start_twilight && $timestamp < $end_twilight) {
-               $period = 'twilight';
-       } else if ($timestamp >= $start_dawn && $timestamp < $end_dawn) {
-               $period = 'dawn';
-       } else if ($day) {
+    if ($timestamp >= $start_twilight && $timestamp < $end_twilight) {
+        $period = 'twilight';
+    } else if ($timestamp >= $start_dawn && $timestamp < $end_dawn) {
+        $period = 'dawn';
+    } else if ($day) {
 
-       } else {
-               $period = 'night';
-       }
+    } else {
+        $period = 'night';
+    }
 
-       if ($day) {
-               $midday = ($sunset + $sunrise) / 2;
-       } else {
+    if ($day) {
+        $midday = ($sunset + $sunrise) / 2;
+    } else {
 
-       }
+    }
+
+    return ['day' => $day, 'period' => $period];
+}
 
-       return ['day' => $day, 'period' => $period];
-}
\ No newline at end of file
diff --git a/scripts/lib/windows.php b/scripts/lib/windows.php
new file mode 100644 (file)
index 0000000..576dd25
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+
+function isSummer()
+{
+    $summer = range(4, 10);
+    return in_array(date('n'), $summer);
+}
+
+function areWindowsOpened()
+{
+    foreach (sensors() as $name => $sensor) {
+        if ($sensor['type'] !== 'window') {
+            continue;
+        }
+        if (haGetState($sensor['device']) === 'on') {
+            return true;
+        }
+    }
+    return false;
+}
+
+function isSecured()
+{
+    foreach (sensors() as $name => $sensor) {
+        if (!$sensor['secure']) {
+            continue;
+        }
+        if (haGetState($sensor['device']) === 'on') {
+            return false;
+        }
+    }
+    return true;
+}
+
+function needOpenWindows()
+{
+    return areWindowsClosed() && optimalWindowsOpening();
+}
+
+function optimalWindowsOpening()
+{
+    $summer = isSummer();
+    $outdoor = toNumber(haGetState(['sensor.indoor_outdoor_meter_ddf7_temperature', 'sensor.w340001x_tempc']), 1);
+    $indoor = toNumber(haGetState(['sensor.meter_c7c3_temperature', 'sensor.thx1_w230150x_tempc']), 1);
+    $res = $indoor > $outdoor;
+    if ($summer) {
+        return $res;
+    }
+    return !$res;
+
+
+}
+
+function areWindowsClosed()
+{
+    return !areWindowsOpened();
+}
+
+function needCloseWindows()
+{
+    return areWindowsOpened() && !optimalWindowsOpening();
+}
+
+function sensors()
+{
+    return [
+        'Chambre Est' => ['device' => 'binary_sensor.0x00124b0029344d11_contact', 'type' => 'window', 'secure' => true],
+        'Chambre Ouest' => ['device' => 'binary_sensor.0x00124b002933740b_contact', 'type' => 'window', 'secure' => true],
+        'Bureau' => ['device' => 'binary_sensor.0x00124b002933744d_contact', 'type' => 'window', 'secure' => true],
+    ];
+}
\ No newline at end of file
diff --git a/scripts/lock.php b/scripts/lock.php
new file mode 100644 (file)
index 0000000..0ea8d99
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+require_once "import.php";
+
+$secured = isSecured();
+$res = [
+    'icon' => $secured ? '🔒' : '🔓',
+    'secured' => $secured,
+    'windows' => areWindowsOpened(),
+];
+
+header('content-type: application/json');
+
+die(json_encode($res));
\ No newline at end of file
index 8f0edbde2faad94cfa4f8947cd28b94fca1d84d8..7121cf4d65d6367b3047a9f5900112734e31b13c 100644 (file)
@@ -674,6 +674,20 @@ section accordion.closed {
   width: 100%;
   height: 100%;
 }
+section .col > .info.lock {
+  background-color: rgba(204, 0, 0, 0.5);
+}
+section .col > .info.lock.secured {
+  background-color: rgba(0, 0, 0, 0.5);
+}
+section .col > .info.lock .icon {
+  position: absolute;
+  top: 0;
+  left: 0;
+  width: 100%;
+  opacity: 0.3;
+  font-size: 4em;
+}
 .mm-spn {
   --mm-ocd-max-width: 440px;
 }
index f8f5f224100273c8faeb43e3aa26cec6c144c990..dcae52398fe0c7f2686ed8f5793c5f17d190acca 100644 (file)
@@ -308,8 +308,8 @@ section {
     }
   }
 
-  &.nintendoswitch{
-    background-color:#e60012;
+  &.nintendoswitch {
+    background-color: #e60012;
   }
 
   &.missing {
@@ -541,6 +541,24 @@ section {
 }
 
 
+section .col > .info.lock {
+  background-color: rgba(204, 0, 0, 0.5);
+
+  &.secured {
+    background-color: rgba(0, 0, 0, 0.5);
+  }
+
+  .icon {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100%;
+    opacity: 0.3;
+    font-size: 4em;
+
+  }
+}
+
 @import "menu";
 
 @import "remote";
\ No newline at end of file