From ce2b054bfa63681b513741c5007a6aa88319c429 Mon Sep 17 00:00:00 2001 From: Tcharp38 Date: Sun, 17 Nov 2024 23:24:38 +0100 Subject: [PATCH] Virtual remote update --- core/config/Abeille.config.php | 2 +- docs/fr_FR/Changelog.md | 2 +- plugin_info/install.php | 41 ++++++++++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/core/config/Abeille.config.php b/core/config/Abeille.config.php index de61ac22a..439376528 100644 --- a/core/config/Abeille.config.php +++ b/core/config/Abeille.config.php @@ -3,7 +3,7 @@ * Abeille's static config file */ - define('lastDbVersion', 20240821); + define('lastDbVersion', 20241117); $in = "/tmp/AbeilleDeamonInput"; $resourcePath = realpath(__DIR__.'/../../resources'); define('wifiLink', '/tmp/zigateWifi'); // For WIFI: Socat output diff --git a/docs/fr_FR/Changelog.md b/docs/fr_FR/Changelog.md index 6102d421e..d38a51341 100644 --- a/docs/fr_FR/Changelog.md +++ b/docs/fr_FR/Changelog.md @@ -2,7 +2,7 @@ - Amélioration: Modèle pour Tuya 2 keys remote (2731). - Amélioration: Support Tuya: Ajout function générique 'rcvValueEnum'. -- Correction: Regression telecommande virtuelle (2732). +- Correction: Regression telecommande virtuelle => Mise-à-jour automatique (2732). ## 241115-BETA-1 diff --git a/plugin_info/install.php b/plugin_info/install.php index 658a370dc..47a8346c2 100755 --- a/plugin_info/install.php +++ b/plugin_info/install.php @@ -1173,8 +1173,9 @@ function updateConfigDB() { * - Cmd DB: 'setLevel' update: 'Level' renamed to 'level' * - Cmd DB: 'setLevel' update: 'EP' renamed to 'ep' * - Eq DB: Some icons renamed for normalization + * - Some eq updates forced from changed model. */ - if (intval($dbVersion) < 20241108) { + if (intval($dbVersion) < 20241117) { // 'config' DB updates for ($gtwId = 1; $gtwId <= maxGateways; $gtwId++) { renameConfigKey("ab::zgEnabled{$gtwId}", "ab::gtwEnabled{$gtwId}"); @@ -1194,6 +1195,11 @@ function updateConfigDB() { renameConfigKey("ab::zgChan{$gtwId}", "ab::gtwChan{$gtwId}"); } + // Force some equipments update from model. + $toReload = array( + 'remotecontrol' => '2024-11-17 23:30:00', + ); + // 'eqLogic' + 'cmd' DB updates $eqLogics = eqLogic::byType('Abeille'); foreach ($eqLogics as $eqLogic) { @@ -1258,12 +1264,43 @@ function updateConfigDB() { if (addCmdFromModel($eqId, "inf_time-String", "Time-Time") == true) log::add('Abeille', 'debug', " {$eqHName}[Time-Time]: Added"); } + + // Model updated ? + $eqModel = $eqLogic->getConfiguration('ab::eqModel', []); + if (isset($eqModel['modelName']) && array_key_exists($eqModel['modelName'], $toReload)) { + $eqModelName = $eqModel['modelName']; + checkAndUpdate($eqLogic, $eqModelName, $toReload); + } } - // config::save('ab::dbVersion', '20240624', 'Abeille'); + // config::save('ab::dbVersion', '20241117', 'Abeille'); } } // End updateConfigDB() + // Check if equipment must be updated and force if required + function checkAndUpdate($eqLogic, $eqModelName, $toReload) { + + // Check last update from model + $modelTime = $toReload[$eqModelName]; + $updateTime = $eqLogic->getConfiguration('updatetime', ""); + log::add('Abeille', 'debug', ' '.$eqLogic->getHumanName().": modelTime=".$modelTime.", updateTime=".$updateTime); + if ($updateTime != '') { + if (strtotime($updateTime) > strtotime($modelTime)) + return; + } + + list($net, $addr) = explode("/", $eqLogic->getLogicalId()); + $dev = array( + 'net' => $net, + 'addr' => $addr, + 'jsonId' => $eqModelId, + 'jsonLocation' => 'Abeille', + 'ieee' => $eqLogic->getConfiguration('IEEE'), + ); + Abeille::createDevice("update", $dev); + log::add('Abeille', 'debug', ' '.$eqLogic->getHumanName().": Updating Jeedom equipment from model"); + } + // Returns: true or false function addCmdFromModel($eqId, $cmdModelName, $cmdName) { $fullPath = cmdsDir.$cmdModelName.'.json';