Skip to content

Commit

Permalink
Virtual remote update
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Nov 17, 2024
1 parent 00f8ec8 commit ce2b054
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/config/Abeille.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/fr_FR/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
41 changes: 39 additions & 2 deletions plugin_info/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand All @@ -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) {
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit ce2b054

Please sign in to comment.