From 8bd1d409354f395c4cc907439530455ab432ed0d Mon Sep 17 00:00:00 2001 From: Vincent Date: Thu, 26 Dec 2019 17:21:11 +0100 Subject: [PATCH] . --- .idea/workspace.xml | 44 ++++++++++++++++++++----------- js/home.js | 2 +- scripts/cron/cron.php | 6 +++++ scripts/domoticz_device_event.php | 4 ++- scripts/ecomode.php | 8 +++++- scripts/lib/lib.php | 1 + scripts/lib/router.php | 19 +++++++++++++ scripts/lib/scenes.php | 5 ++++ scripts/pop.php | 4 +++ scripts/router_devices_list.php | 5 ++++ 10 files changed, 79 insertions(+), 19 deletions(-) create mode 100644 scripts/lib/router.php create mode 100644 scripts/router_devices_list.php diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5a8f37a..b7edf87 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,8 +2,16 @@ + + - + + + + + + + @@ -1177,19 +1187,21 @@ - - + + + - - + + + - + - + diff --git a/js/home.js b/js/home.js index b0b45b2..ca64b63 100644 --- a/js/home.js +++ b/js/home.js @@ -38,7 +38,7 @@ $(function () { }, 10000); } - if (raspberry) { + if (true || raspberry) { setInterval(function () { checkEcoMode(false); }, 60000); diff --git a/scripts/cron/cron.php b/scripts/cron/cron.php index 54e812b..edefe84 100644 --- a/scripts/cron/cron.php +++ b/scripts/cron/cron.php @@ -13,6 +13,7 @@ function cronOneLoop($cronmin) cronVelib($cronmin); cronWeather($cronmin); cronBackyard($cronmin); + cronGuest($cronmin); } if ($cronmin % 10 == 0) { cronSqueezeFavorites($cronmin); @@ -39,6 +40,11 @@ function cronOneLoop($cronmin) cronHeartbeat($cronmin); } +function cronGuest($cronmin) +{ + setState('guest', hasGuest() ? '1' : '0'); +} + function cronInsteon($cronmin) { insteonCommand('knock'); diff --git a/scripts/domoticz_device_event.php b/scripts/domoticz_device_event.php index f27c821..589a8aa 100644 --- a/scripts/domoticz_device_event.php +++ b/scripts/domoticz_device_event.php @@ -24,7 +24,9 @@ if ($_GET['device'] == 480) { off('salon'); break; case 'Move': - _remoteCmd('pause', 'salon'); + if (getCurrentHarmonyActivity() != 'musique-radio') { + _remoteCmd('pause', 'salon'); + } break; case 'Clock_Wise': if (getCurrentHarmonyActivity() !== 'poweroff') { diff --git a/scripts/ecomode.php b/scripts/ecomode.php index dceac6e..82aedc9 100644 --- a/scripts/ecomode.php +++ b/scripts/ecomode.php @@ -8,4 +8,10 @@ if (isset($_GET['action'])) { heartbeat(); } ob_end_clean(); -die(getState('ecomode')); + +$res = getState('ecomode'); +if (!$res && in_array(config('DEVICE'), ['bureau', 'bureausun'])) { + $res = getDomoticzDeviceStatus(391) === 'Closed'; +} + +die($res); diff --git a/scripts/lib/lib.php b/scripts/lib/lib.php index 6dbd4a1..e994e1d 100644 --- a/scripts/lib/lib.php +++ b/scripts/lib/lib.php @@ -41,6 +41,7 @@ require_once ROOT . '/scripts/lib/heartbeats.php'; require_once ROOT . '/scripts/lib/ssh.php'; require_once ROOT . '/scripts/lib/cachemedia.php'; require_once ROOT . '/scripts/lib/ifttt.php'; +require_once ROOT . '/scripts/lib/router.php'; profile('Loaded libraries', __FILE__, __LINE__); diff --git a/scripts/lib/router.php b/scripts/lib/router.php new file mode 100644 index 0000000..3f98228 --- /dev/null +++ b/scripts/lib/router.php @@ -0,0 +1,19 @@ + time()], ['admin', 'BDQw479qbJST4u']); + // echo $res->getBody(); + if (preg_match('/dhcpd_lease = ([^;]+);/m', $res->getBody(), $dhcp)) { + if (preg_match_all('/192\.168\.13\.[0-9]{1,3}/', $dhcp[1], $matches)) { + return $matches[0]; + } + } + return []; +} + +function hasGuest() +{ + $guests = ['192.168.13.150', '192.168.13.151', '192.168.13.152', '192.168.13.153']; + return count(array_intersect(routerDevicesList(), $guests)) > 0; +} \ No newline at end of file diff --git a/scripts/lib/scenes.php b/scripts/lib/scenes.php index e22ac09..b69a133 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -286,26 +286,31 @@ $scenes = [ ], 'salon/on' => [ ['type' => 'hue', 'group' => $salon, 'scene' => 'Gte8sl76rzAD1wO'], + ['type' => 'domoticz', 'device' => '1203', 'command' => true, 'priority' => true], // sapin ['type' => 'insteon', 'command' => '0?113=I=0=0'], ['type' => 'scene', 'scene' => 'salon/cheminee', 'delay' => 1], ], 'salon/off' => [ ['type' => 'hue', 'group' => $salon, 'scene' => array('on' => false, 'brightness' => 0)], + ['type' => 'domoticz', 'device' => '1203', 'command' => false, 'priority' => true], // sapin ['type' => 'insteon', 'command' => '0?133=I=0=0'], ['type' => 'function', 'function' => 'chemineeOff', 'args' => ['salon']], ], 'salon/cinema' => [ ['type' => 'ecomode', 'mode' => '0'], + ['type' => 'domoticz', 'device' => '1203', 'command' => true, 'priority' => true], // sapin ['type' => 'hue', 'group' => $salon, 'scene' => 'AsU9eOyGsjEyz35'], ['type' => 'insteon', 'command' => '0?1111=I=0=0'], ], 'salon/tamise' => [ + ['type' => 'domoticz', 'device' => '1203', 'command' => true, 'priority' => true], // sapin ['type' => 'ecomode', 'mode' => '0'], ['type' => 'hue', 'group' => $salon, 'scene' => 'RbjnIcLtcDuHbfU'], ['type' => 'insteon', 'command' => '0?1130=I=0=0'], ['type' => 'function', 'function' => 'chemineeOn', 'args' => ['salon', 'fire', 0.8]], ], 'salon/lecturenocture' => [ + ['type' => 'domoticz', 'device' => '1203', 'command' => true, 'priority' => true], // sapin ['type' => 'hue', 'group' => $salon, 'scene' => 'HZiYyM6hMUMkmiY'], ['type' => 'insteon', 'command' => '0?1113=I=0=0'], ['type' => 'function', 'function' => 'chemineeOn', 'args' => ['salon', 'fire', 0.25]], diff --git a/scripts/pop.php b/scripts/pop.php index 738dce5..faa7dff 100644 --- a/scripts/pop.php +++ b/scripts/pop.php @@ -4,6 +4,10 @@ define('TIMELIMIT', 1); $_GET['im'] = '5'; include "import.php"; +if (getState('guest', '0') === '1' && $_GET['action'] == 'long') { + $_GET['action'] = 'tap'; +} + if ($_GET['button'] == 'wc') { if ($_GET['action'] == 'tap') { wcToggle(); diff --git a/scripts/router_devices_list.php b/scripts/router_devices_list.php new file mode 100644 index 0000000..e3dd613 --- /dev/null +++ b/scripts/router_devices_list.php @@ -0,0 +1,5 @@ +