Skip to content
Merged

4.5.1 #3161

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions core/class/cmd.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1042,10 +1042,10 @@ public function formatValue($_value, $_quote = false) {
return intval($binary xor boolval($this->getConfiguration('invertBinary', false)));
case 'numeric':
if ($this->getConfiguration('historizeRound') !== '' && is_numeric($this->getConfiguration('historizeRound')) && $this->getConfiguration('historizeRound') >= 0) {
if (!is_numeric($_value)) {
log::add('cmd', 'error', __('La formule de calcul doit retourner une valeur numérique uniquement : ', __FILE__) . $this->getHumanName() . ' => ' . $_value);
$_value = (float) (str_replace(',', '.', $_value));
}
if (!is_numeric($_value)) {
log::add('cmd', 'error', __('La formule de calcul doit retourner une valeur numérique uniquement : ', __FILE__) . $this->getHumanName() . ' => ' . $_value);
$_value = (float) (str_replace(',', '.', $_value));
}
$_value = round($_value, $this->getConfiguration('historizeRound'));
}
if ($_value > $this->getConfiguration('maxValue', $_value)) {
Expand Down Expand Up @@ -3071,7 +3071,7 @@ public function getDisplay($_key = '', $_default = '') {
}

public function setDisplay($_key, $_value) {
if ($this->getDisplay($_key) !== $_value) {
if ($this->getDisplay($_key, null) !== $_value) {
$this->_needRefreshWidget = true;
$this->_changed = true;
}
Expand Down
79 changes: 41 additions & 38 deletions core/class/scenarioExpression.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,17 @@ public static function getDatesFromPeriod($_period = '1 hour') {
if ($_period == 'day') $_period = '1 day';

if (ctype_digit($_period[0]) && !stristr($_period, "ago")) {
$_startTime = date('Y-m-d H:i:s',(int) strtotime('-' . $_period));
$_startTime = date('Y-m-d H:i:s', (int) strtotime('-' . $_period));
} else {
$_startTime = date('Y-m-d H:i:s',(int) strtotime($_period));
$_startTime = date('Y-m-d H:i:s', (int) strtotime($_period));
}
$_endTime = date('Y-m-d H:i:s');

if ($_period == 'today') {
$_startTime = date('Y-m-d') . ' 00:00:00';
} elseif ($_period == 'yesterday') {
$_startTime = date('Y-m-d',(int) strtotime('-1 day')) . ' 00:00:00';
$_endTime = date('Y-m-d',(int) strtotime('-1 day')) . ' 23:59:59';
$_startTime = date('Y-m-d', (int) strtotime('-1 day')) . ' 00:00:00';
$_endTime = date('Y-m-d', (int) strtotime('-1 day')) . ' 23:59:59';
}
return array($_startTime, $_endTime);
}
Expand Down Expand Up @@ -303,8 +303,8 @@ public static function averageBetween($_cmd_id, $_startDate, $_endDate, $_round
if (!is_object($cmd) || $cmd->getIsHistorized() == 0) {
return '';
}
$_startTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_endDate)));
$_startTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_endDate)));
$historyStatistique = $cmd->getStatistique($_startTime, $_endTime);
if (!isset($historyStatistique['avg'])) {
return '';
Expand All @@ -328,8 +328,8 @@ public static function averageTemporalBetween($_cmd_id, $_startDate, $_endDate,
if (!is_object($cmd) || $cmd->getIsHistorized() == 0) {
return '';
}
$_startTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_endDate)));
$_startTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_endDate)));
return round($cmd->getTemporalAvg($_startTime, $_endTime), $_round);
}

Expand Down Expand Up @@ -458,8 +458,8 @@ public static function maxBetween($_cmd_id, $_startDate, $_endDate, $_round = 1)
if (!is_object($cmd) || $cmd->getIsHistorized() == 0) {
return '';
}
$_startTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_endDate)));
$_startTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_endDate)));
$historyStatistique = $cmd->getStatistique($_startTime, $_endTime);
if (!isset($historyStatistique['max'])) {
return '';
Expand Down Expand Up @@ -489,8 +489,8 @@ public static function minBetween($_cmd_id, $_startDate, $_endDate, $_round = 1)
if (!is_object($cmd) || $cmd->getIsHistorized() == 0) {
return '';
}
$_startTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_endDate)));
$_startTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_endDate)));
$historyStatistique = $cmd->getStatistique($_startTime, $_endTime);
if (!isset($historyStatistique['min'])) {
return '';
Expand Down Expand Up @@ -642,8 +642,8 @@ public static function stateChangesBetween($_cmd_id, $_value, $_startDate, $_end
$_endDate = func_get_arg(2);
$_value = null;
}
$_startTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_endDate)));
$_startTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_endDate)));

return history::stateChanges($cmd_id, $_value, $_startTime, $_endTime);
}
Expand Down Expand Up @@ -724,8 +724,8 @@ public static function durationBetween($_cmd_id, $_value, $_startDate, $_endDate
$_endDate = date('Y-m-d H:i:s');
}

$_startTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_endDate)));
$_startTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_endDate)));
$_value = str_replace(',', '.', $_value);
$_decimal = strlen(substr(strrchr($_value, "."), 1));

Expand Down Expand Up @@ -769,8 +769,8 @@ public static function lastBetween($_cmd_id, $_startDate, $_endDate) {
if (!is_object($cmd) || $cmd->getIsHistorized() == 0) {
return '';
}
$_startTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_endDate)));
$_startTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_endDate)));
$historyStatistique = $cmd->getStatistique($_startTime, $_endTime);
if (!isset($historyStatistique['last']) || $historyStatistique['last'] === '') {
return '';
Expand Down Expand Up @@ -802,8 +802,8 @@ public static function statisticsBetween($_cmd_id, $_calc, $_startDate, $_endDat
return '';
}
$_calc = str_replace(' ', '', $_calc);
$_startTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s',(int) strtotime(self::setTags($_endDate)));
$_startTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_startDate)));
$_endTime = date('Y-m-d H:i:s', (int) strtotime(self::setTags($_endDate)));
$historyStatistique = $cmd->getStatistique(self::setTags($_startTime), self::setTags($_endTime));
return $historyStatistique[$_calc];
}
Expand Down Expand Up @@ -960,7 +960,7 @@ public static function trigger($_name = '', &$_scenario = null) {
if (trim($_name) == '') {
return $_scenario->getTag('trigger_name');
}
if (trim(jeedom::toHumanReadable($_name),'#') == $_scenario->getTag('trigger_name')) {
if (trim(jeedom::toHumanReadable($_name), '#') == $_scenario->getTag('trigger_name')) {
return 1;
}
return 0;
Expand Down Expand Up @@ -1038,8 +1038,8 @@ public static function time_diff($_date1, $_date2, $_format = 'd', $_rnd = 2) {
if ($_date2 < 100) $_date2 = '00' . $_date2;
if ($_date2 < 1000) $_date2 = '0' . $_date2;
}
$d1 = str_replace(array('"','\'',"'"), '', self::setTags($_date1));
$d2 = str_replace(array('"','\'',"'"), '', self::setTags($_date2));
$d1 = str_replace(array('"', '\'', "'"), '', self::setTags($_date1));
$d2 = str_replace(array('"', '\'', "'"), '', self::setTags($_date2));
$date1 = new DateTime($d1);
$date2 = new DateTime($d2);
$duree = $date2->getTimestamp() - $date1->getTimestamp();
Expand Down Expand Up @@ -1275,6 +1275,9 @@ public static function setTags(&$_expression, &$_scenario = null, $_quote = fals
}
if ($_quote) {
foreach ($replace1 as &$value) {
if ($value === null) {
continue;
}
if (strpos($value, ' ') !== false || preg_match("/[a-zA-Z]/", $value) || $value === '') {
$value = '"' . trim($value, '"') . '"';
}
Expand Down Expand Up @@ -1386,7 +1389,7 @@ public function execute(&$scenario = null) {
}
$this->checkBackground();
if ($this->getOptions('background', 0) == 1) {
$key = 'scenarioElement'.$this->getId().'::' . config::genKey(16).'::'.strtotime('now');
$key = 'scenarioElement' . $this->getId() . '::' . config::genKey(16) . '::' . strtotime('now');
cache::set($key, array('scenarioExpression' => $this, 'scenario' => $scenario), 60);
$cmd = __DIR__ . '/../php/jeeScenarioExpression.php';
$cmd .= ' key=' . $key;
Expand Down Expand Up @@ -1571,14 +1574,14 @@ public function execute(&$scenario = null) {
}
$this->setLog($scenario, $GLOBALS['JEEDOM_SCLOG_TEXT']['launchScenario']['txt'] . $actionScenario->getName() . ' ' . __('options :', __FILE__) . ' ' . json_encode($actionScenario->getTags()));
if ($scenario !== null) {
$actionScenario->addTag('trigger','scenario');
$actionScenario->addTag('trigger_message',$GLOBALS['JEEDOM_SCLOG_TEXT']['startByScenario']['txt'] . $scenario->getHumanName());
$actionScenario->addTag('trigger_name',trim($scenario->getHumanName(),'#'));
$actionScenario->addTag('trigger_id',$scenario->getId());
$actionScenario->addTag('trigger', 'scenario');
$actionScenario->addTag('trigger_message', $GLOBALS['JEEDOM_SCLOG_TEXT']['startByScenario']['txt'] . $scenario->getHumanName());
$actionScenario->addTag('trigger_name', trim($scenario->getHumanName(), '#'));
$actionScenario->addTag('trigger_id', $scenario->getId());
return $actionScenario->launch();
} else {
$actionScenario->addTag('trigger','other');
$actionScenario->addTag('trigger_message',$GLOBALS['JEEDOM_SCLOG_TEXT']['startCausedBy']['txt']);
$actionScenario->addTag('trigger', 'other');
$actionScenario->addTag('trigger_message', $GLOBALS['JEEDOM_SCLOG_TEXT']['startCausedBy']['txt']);
return $actionScenario->launch();
}
break;
Expand All @@ -1597,14 +1600,14 @@ public function execute(&$scenario = null) {
}
$this->setLog($scenario, $GLOBALS['JEEDOM_SCLOG_TEXT']['launchScenario']['txt'] . $actionScenario->getName() . ' ' . __('options :', __FILE__) . ' ' . json_encode($actionScenario->getTags()));
if ($scenario !== null) {
$actionScenario->addTag('trigger','scenario');
$actionScenario->addTag('trigger_message',$GLOBALS['JEEDOM_SCLOG_TEXT']['startByScenario']['txt'] . $scenario->getHumanName());
$actionScenario->addTag('trigger_name',trim($scenario->getHumanName(),'#'));
$actionScenario->addTag('trigger_id',$scenario->getId());
$actionScenario->addTag('trigger', 'scenario');
$actionScenario->addTag('trigger_message', $GLOBALS['JEEDOM_SCLOG_TEXT']['startByScenario']['txt'] . $scenario->getHumanName());
$actionScenario->addTag('trigger_name', trim($scenario->getHumanName(), '#'));
$actionScenario->addTag('trigger_id', $scenario->getId());
return $actionScenario->launch(true);
} else {
$actionScenario->addTag('trigger','other');
$actionScenario->addTag('trigger_message',$GLOBALS['JEEDOM_SCLOG_TEXT']['startCausedBy']['txt']);
$actionScenario->addTag('trigger', 'other');
$actionScenario->addTag('trigger_message', $GLOBALS['JEEDOM_SCLOG_TEXT']['startCausedBy']['txt']);
return $actionScenario->launch(true);
}
break;
Expand Down Expand Up @@ -1791,8 +1794,8 @@ public function execute(&$scenario = null) {
$tmp_file = jeedom::getTmpFolder('history_export') . '/' . $options['name'] . '.csv';
$cmd_parameters = array('files' => [$tmp_file], 'title' => $options['name'], 'message' => $options['name']);

$start = date('Y-m-d H:i:s',(int) strtotime($options['start']));
$end = date('Y-m-d H:i:s',(int) strtotime($options['end']));
$start = date('Y-m-d H:i:s', (int) strtotime($options['start']));
$end = date('Y-m-d H:i:s', (int) strtotime($options['end']));
$this->setLog($scenario, __('Export de l\'historique du', __FILE__) . ' ' . $start . ' ' . __('au', __FILE__) . ' ' . $end);

$histories = array();
Expand Down
4 changes: 2 additions & 2 deletions core/class/user.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static function connect(string $_login, string $_mdp) {
->setProfils($profile);
$user->save();
log::add("connection", "info", __('User created from the LDAP :', __FILE__) . ' ' . $_login);
jeedom::event('user_connect');
jeedom::event('user_connect', false, array('trigger_value' => $_login));
// TODO : if username == password => change ldap password
log::add('event', 'info', __('User connection accepted', __FILE__) . ' ' . $_login);
return $user;
Expand All @@ -145,7 +145,7 @@ public static function connect(string $_login, string $_mdp) {
if (is_object($user)) {
$user->setOptions('lastConnection', date('Y-m-d H:i:s'));
$user->save();
jeedom::event('user_connect');
jeedom::event('user_connect', false, array('trigger_value' => $_login));
log::add('event', 'info', __('Local account found for', __FILE__) . ' ' . $_login);
log::add('event', 'info', __('User connection accepted', __FILE__) . ' ' . $_login);
}
Expand Down
2 changes: 1 addition & 1 deletion core/config/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.5
4.5.1
8 changes: 7 additions & 1 deletion core/template/dashboard/cmd.action.color.picker.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
if ('#time#' == 'duration' || '#time#' == 'date') {
jeedom.cmd.displayDuration(_options.valueDate, cmd.querySelector('.timeCmd'), '#time#')
}
cmd.querySelector('.action_colorpicker_change').value = (_options.display_value != '') ? _options.display_value.substr(0, 7) : '#000000'
if (_options.display_value.length == 0) {
cmd.querySelector('.action_colorpicker_change').value = '#000000'
} else if (_options.display_value.startsWith('#')) {
cmd.querySelector('.action_colorpicker_change').value = _options.display_value.substr(0, 7)
} else {
cmd.querySelector('.action_colorpicker_change').value = '#' + _options.display_value.substr(0, 6)
}
}
})

Expand Down
11 changes: 9 additions & 2 deletions docs/fr_FR/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog Jeedom V4.5

# 4.5.1

- Le déclencheur de scénarios `#user_connect#` inclut dorénavant le tag `#trigger_value#` qui renseigne le nom de l'utilisateur venant de se connecter ([Détails](https://github.com/jeedom/core/pull/3109))
- Montée de version de nodejs 20 vers 22 ([Détails](https://github.com/jeedom/core/issues/3147))
- La sauvegarde se fera maintenant a une heure aléatoire entre 00:10 et 9:59
- Correction d'un warning sur les valeurs de tags null

# 4.5

- [Développeurs] Ajout de la fonction `$listener->removeEvent($_id)`
Expand All @@ -10,7 +17,7 @@
- Les graphiques se mettent à jour automatiquement lors de l'arrivée de nouvelles valeurs [LIEN](https://github.com/jeedom/core/issues/2749)
- Jeedom ajoute automatiquement la hauteur de l'image lors de la création des widgets pour éviter les soucis de chevauchement en mobile [LIEN](https://github.com/jeedom/core/issues/2539)
- Refonte de la partie backup cloud [LIEN](https://github.com/jeedom/core/issues/2765)
- **DEV** Mise en place d'un système de queue pour l'exécution d'actions [LIEN](https://github.com/jeedom/core/issues/2489)
- [Développeurs] Mise en place d'un système de queue pour l'exécution d'actions [LIEN](https://github.com/jeedom/core/issues/2489)
- Les tags des scénarios sont maintenant propres à l'instance du scénario (si vous avez deux lancements de scénarios très proches, les tags du dernier n'écrasent plus le premier) [LIEN](https://github.com/jeedom/core/issues/2763)
- Changement sur la partie trigger des scénarios : [LIEN](https://github.com/jeedom/core/issues/2414)
- ``triggerId()`` est maintenant deprecated et sera retiré dans les futures mises à jour du core. Si vous avez ``triggerId() == 587`` il faut le remplacer par ``#trigger_id# == 587``
Expand Down Expand Up @@ -95,4 +102,4 @@

>**IMPORTANT**
>
> La restauration d'un backup 4.4 peut dans certains cas finir par des erreurs dans l'interface web. Rien de grave cela peut facilement se corriger il suffit de faire : `cd /tmp;wget https://github.com/jeedom/core/archive/refs/tags/4.4.20.zip;unzip 4.4.19.zip;cd core-4.4.20;cp -rf * /var/www/html/;rm -rf /tmp/master.zip;rm -rf /tmp/core-4.4.20;`. Vous pouvez lancer cette commande depuis l'interface rescue de jeedom (ajouter `&rescue=1` dans l'url), ou directement en ssh.
> La restauration d'un backup 4.4 peut dans certains cas finir par des erreurs dans l'interface web. Rien de grave cela peut facilement se corriger il suffit de faire : `cd /tmp;wget https://github.com/jeedom/core/archive/refs/tags/4.4.20.zip;unzip 4.4.20.zip;cd core-4.4.20;cp -rf * /var/www/html/;rm -rf /tmp/master.zip;rm -rf /tmp/core-4.4.20;`. Vous pouvez lancer cette commande depuis l'interface rescue de jeedom (ajouter `&rescue=1` dans l'url), ou directement en ssh.
4 changes: 2 additions & 2 deletions docs/fr_FR/scenario.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Il existe des déclencheurs spécifiques (autre que ceux fournis par les command
- ``#end_update#`` : Événement envoyé à la fin d’une mise à jour.
- ``#begin_restore#`` : Événement envoyé au début d’une restauration.
- ``#end_restore#`` : Événement envoyé à la fin d’une restauration.
- ``#user_connect#`` : Connexion d'un utilisateur
- ``#user_connect#`` : Connexion d'un utilisateur, le tag `#trigger_value#` contient le nom de l'utilisateur.
- ``#variable(nom_variable)#`` : Changement de valeur de la variable nom_variable.
- ``#genericType(GENERIC, #[Object]#)#`` : Changement d'une commande info de Type Generic GENERIC, dans l'objet Object.
- ``#new_eqLogic#`` : Événement envoyé lors de la création d'un nouvelle équipement, vous avez dans les tags id (id de l'équipement crée), name (nom de l'équipement crée) et eqType (type/plugin de l'équipement crée)
Expand Down Expand Up @@ -439,7 +439,7 @@ Une boîte à outils de fonctions génériques peut également servir à effectu
- ``randText(texte1;texte2;texte…​..)`` : Permet de retourner un des textes aléatoirement (séparer les texte par un ; ). Il n’y a pas de limite dans le nombre de texte.
- ``randomColor(min,max)`` : Donne une couleur aléatoire comprise entre 2 bornes ( 0 => rouge, 50 => vert, 100 => bleu).
- ``trigger(commande)`` : Permet de connaître le déclencheur du scénario ou de savoir si c’est bien la commande passée en paramètre qui a déclenché le scénario. **=> Deprecated il vaut mieux utiliser le tag #trigger#**
- ``triggerValue()`` : Permet de connaître la valeur du déclencheur du scénario. **=> Deprecated il vaut mieux utiliser le tag #triggerValue#**
- ``triggerValue()`` : Permet de connaître la valeur du déclencheur du scénario. **=> Deprecated il vaut mieux utiliser le tag #trigger_value#**
- ``round(valeur,[decimal])`` : Donne un arrondi au-dessus, [decimal] nombre de décimales après la virgule.
- ``odd(valeur)`` : Permet de savoir si un nombre est impair ou non. Renvoie 1 si impair 0 sinon.
- ``median(commande1,commande2…​.commandeN)`` : Renvoie la médiane des valeurs.
Expand Down
Loading
Loading