]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Wed, 20 Nov 2019 09:41:51 +0000 (10:41 +0100)
committerVincent <vincent@enhydra.fr>
Wed, 20 Nov 2019 09:41:51 +0000 (10:41 +0100)
.idea/workspace.xml
js/home.js
scripts/cron/cron.php
scripts/domoticz_status.php [new file with mode: 0644]
scripts/lib/domoticz.php
scripts/lib/weatherstation.php

index 8d9c6430d297874d52395bd5b91b3baacecb3c6c..3357e507448750a17f375febf9107bc37a2b6ee2 100644 (file)
@@ -2,10 +2,12 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
+      <change afterPath="$PROJECT_DIR$/scripts/domoticz_status.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/js/home.js" beforeDir="false" afterPath="$PROJECT_DIR$/js/home.js" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/scripts/cron/cron.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/cron/cron.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/domoticz_device_event.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/domoticz_device_event.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/lib/mediarasp.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/mediarasp.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/domoticz.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/domoticz.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/weatherstation.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/weatherstation.php" afterDir="false" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
       <workItem from="1573629043706" duration="29000" />
       <workItem from="1573629088225" duration="3531000" />
       <workItem from="1574065436563" duration="754000" />
-      <workItem from="1574066213679" duration="3460000" />
-    </task>
-    <task id="LOCAL-00195" summary=".">
-      <created>1562739863351</created>
-      <option name="number" value="00195" />
-      <option name="presentableId" value="LOCAL-00195" />
-      <option name="project" value="LOCAL" />
-      <updated>1562739863351</updated>
+      <workItem from="1574066213679" duration="7326000" />
     </task>
     <task id="LOCAL-00196" summary=".">
       <created>1562740088238</created>
       <option name="project" value="LOCAL" />
       <updated>1574066196695</updated>
     </task>
-    <option name="localTasksCounter" value="244" />
+    <task id="LOCAL-00244" summary=".">
+      <created>1574210671610</created>
+      <option name="number" value="00244" />
+      <option name="presentableId" value="LOCAL-00244" />
+      <option name="project" value="LOCAL" />
+      <updated>1574210671610</updated>
+    </task>
+    <option name="localTasksCounter" value="245" />
     <servers />
   </component>
   <component name="TodoView">
index f1896cd5cfdcda74bbac3de9d6b9a86018dfcd1f..b0b45b2fd07a6308419d3fab487950746cb69c6c 100644 (file)
@@ -682,7 +682,7 @@ function updateWeather() {
         w.find('.icon-day').html('<img src="https://vortex.accuweather.com/adc2010/images/slate/icons/' + data.dayIcon + '.svg" width="100" height="100" />');
         w.find('.icon-night').html('<img src="https://vortex.accuweather.com/adc2010/images/slate/icons/' + data.nightIcon + '.svg" width="100" height="100" />');
         w.find('.temp-max').text(data.max + '°C');
-        w.find('.temp').text(data.temp + '°C');
+        w.find('.temp').text(data.outdoor_temp + '°C');
         w.attr('data-init', 1);
         resize();
     });
index 692d60afc8b5c7d3dd52c1e75c653a7b3153fdda..cd5d682bbaaf55fbb6c690a4b950a0a32bb256fd 100644 (file)
@@ -11,10 +11,10 @@ function cronOneLoop($cronmin)
     if ($cronmin % 5 == 0) {
         cronTraffic($cronmin, false);
         cronVelib($cronmin);
+        cronWeather($cronmin);
         cronBackyard($cronmin);
     }
     if ($cronmin % 10 == 0) {
-        cronWeather($cronmin);
         cronSqueezeFavorites($cronmin);
     }
 
@@ -135,9 +135,18 @@ function cronSqueezeFavorites($cronmin)
     }
 }
 
-function cronWeather($cronmin)
+function toNumber($val, $round = false)
 {
+    $val = preg_replace('/[^0-9-.]/', '', $val);
+    $val = floatval($val);
+    if ($round) {
+        $val = round($val);
+    }
+    return $val;
+}
 
+function cronWeather($cronmin)
+{
     $place = 2608449;
 
     $cache = ROOT . '/cache/accuweather.json';
@@ -150,6 +159,11 @@ function cronWeather($cronmin)
     $weather = json_decode(file_get_contents($cache), true);
     $weather = $weather[0];
     $res['temp'] = round(($weather['Temperature']['Metric']['Value']/* + getState('airtemperature')*/));
+    $res['outdoor_temp'] = toNumber(getDomoticzDeviceStatus(12, 'zigate'),true);
+    $res['outdoor_humidity'] = toNumber(getDomoticzDeviceStatus(13, 'zigate'),true);
+    $res['outdoor_pressure'] = toNumber(getDomoticzDeviceStatus(14, 'zigate'),true);
+    $res['backyard_temp'] = toNumber(getDomoticzDeviceStatus(5, 'zigate'),true);
+    $res['backyard_humidity'] = toNumber(getDomoticzDeviceStatus(6, 'zigate'),true);
     $res['pressure'] = round($weather['Pressure']['Metric']['Value']);
     $res['pressureTendency'] = $weather['PressureTendency']['Code'];
     $res['precipitations24'] = round($weather['PrecipitationSummary']['Past24Hours']['Metric']['Value']);
diff --git a/scripts/domoticz_status.php b/scripts/domoticz_status.php
new file mode 100644 (file)
index 0000000..97c6ff6
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+require_once "import.php";
+
+print_r(getDomoticzDeviceStatus($_GET['device'],$_GET['hardware']));
\ No newline at end of file
index a4a530369e177249f648ec53a75544ea829d79f3..ea1ff44de9d230f112392d5066bd536344d0f93f 100644 (file)
@@ -1,15 +1,22 @@
 <?php
-function runDomoticzCommand($params)
+function runDomoticzCommand($params, $hardware = 'rflink')
 {
     $default = ['type' => 'command', 'passcode' => ''];
     $params = array_merge($default, $params);
 
-    return httpRequest('http://192.168.13.60:8084/json.htm', 'GET', $params);
+    if ($params['hardware'] == 'rflink') {
+        $ip = '192.168.13.60';
+    } else if ($params['hardware'] == 'zigate') {
+        $ip = '192.168.13.68';
+    }
+    unset($params['hardware']);
+
+    return httpRequest('http://' . $ip . ':8084/json.htm', 'GET', $params);
 }
 
-function domoticzSwitch($device, $cmd, $type = 'light', $priority = false)
+function domoticzSwitch($device, $cmd, $type = 'light', $priority = false, $hardware = 'rflink')
 {
-    return domoticzCmd(['idx' => $device, 'switchcmd' => $cmd ? 'On' : 'Off', 'param' => 'switch' . $type, 'level' => '0'], $priority);
+    return domoticzCmd(['idx' => $device, 'switchcmd' => $cmd ? 'On' : 'Off', 'param' => 'switch' . $type, 'level' => '0', 'hardware' => $hardware], $priority);
 }
 
 function domoticzCmd($command, $priority = false)
@@ -21,11 +28,20 @@ function domoticzCmd($command, $priority = false)
     if (!is_array($queue)) {
         $queue = [];
     }
-    if($priority){
-        array_unshift($queue,$command);
-    }else{
-        array_push($queue,$command);
+    if ($priority) {
+        array_unshift($queue, $command);
+    } else {
+        array_push($queue, $command);
     }
     $redis->igbset($queue_name, $queue);
     $redis->publish('domoticz_event', 'handle_queue');
-}
\ No newline at end of file
+    return true;
+}
+
+function getDomoticzDeviceStatus($device, $hardware = 'rflink')
+{
+    $res = runDomoticzCommand(['type' => 'devices', 'rid' => $device, 'hardware' => $hardware]);
+    $res = json_decode($res->getBody(),true);
+
+    return $res['result'][0]['Data'];
+}
index 40525feb336b2fc47b1ce6fe185b480cfce0b885..e0175cf11b37ea7679c9a2a889409faee569a063 100644 (file)
@@ -15,10 +15,13 @@ function weatherStationScreenSaver()
     $res .= '</div>';
     $res .= '<div class="temps">';
     $res .= '<div class="temp-min">' . $weather['min'] . '°C</div>';
-    $res .= '<div class="temp"> ' . $weather['temp'] . '°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"><i class="fa fa-water"></i> ' . $weather['precipitations24'] . ' mm | ' . $weather['pressure'] . ' hPa <i class="fa fa-arrow-circle-' . $pressureTendency . '"></i></div>';
+    $res .= '<div class="pp">';
+    $res .= '<i class="fas fa-cloud-rain"></i> ' . $weather['precipitations24'] . ' mm | <i class="fas fa-tachometer-alt"></i> ' . $weather['outdoor_pressure'] . ' hPa <i class="fa fa-arrow-circle-' . $pressureTendency . '"></i> | <i class="fa fa-tint"></i> ' . $weather['outdoor_humidity'] . '%</br>';
+    $res .= '<i class="fas fa-leaf"></i> ' . $weather['backyard_temp'] . ' °C | <i class="fa fa-tint"></i> ' . $weather['backyard_humidity'] . '%';
+    $res .= '</div>';
     $res .= '</div>';
     $res .= '<div class="forecasts">';
     foreach ($weather['forecasts'] as $forecast) {