Utilisation des actions depuis un scénario

Bonjour à tous,

Je commence à jouer avec le plugin SomfyUnified dans le but de définir une période d’absence pour mon chauffe-eau Thermor depuis un Scenario.

Depuis le Dashboard, la commande setAbsenceEndDate s’attend à recevoir un « Titre » et un « Message ». Tout fonctionne très bien quand je passe un JSON dans le « Message », avec un contenu du genre.

{"month":4,"hour":23,"weekday":5,"year":2025,"day":11,"minute":33,"second":0}

Le « Titre » semble ne pas avoir d’utilité et dans cette situation, le log me donne

[2025-04-11 23:31:58] INFO  : |Py| OverKiz Client |-------------------------------------------------------------------------------------
[2025-04-11 23:31:58] INFO  : |Py| Message: Message from PHP
[2025-04-11 23:31:58] INFO  : |Py| Log level: debug
[2025-04-11 23:31:58] DEBUG  : |Py| Daemon state: ok
[2025-04-11 23:31:58] DEBUG  : |Py| API action: execute_commands
[2025-04-11 23:31:58] DEBUG  : |Py| API type: cloud
[2025-04-11 23:31:58] DEBUG  : |Py| Server: thermor_cozytouch
[2025-04-11 23:31:58] DEBUG  : |Py| User Name: ####
[2025-04-11 23:31:58] DEBUG  : |Py| User Password: ####
[2025-04-11 23:31:58] DEBUG  : |Py| API payload: {'capabilityId': None, 'capabilityValue': None, 'absenceValues': None, 'commands': [{'name': 'setAbsenceEndDate', 'parameters': [{'month': 4, 'hour': 23, 'weekday': 5, 'year': 2025, 'day': 11, 'minute': 33, 'second': 0}]}], 'deviceId': None, 'deviceURL': 'modbuslink://####-####-####/1#1', 'gateway_id': None, 'label': 'setAbsenceEndDate', 'oid': None, 'register_event_listener': None, 'timestamp': None, 'token_label': None, 'token_scope': None, 'token_uuid': None}
[2025-04-11 23:31:58] DEBUG  : |Py| Local API gateway URL:
[2025-04-11 23:31:58] DEBUG  : |Py| Local API verify SSL: False
[2025-04-11 23:31:58] DEBUG  : |Py| Local API token:
[2025-04-11 23:31:58] DEBUG  : |Py| Fetch Loop Period (sec): 1
[2025-04-11 23:31:58] DEBUG  : |Py| importDataAsJson: True
[2025-04-11 23:31:58] DEBUG  : |Py| Callback url: url
[2025-04-11 23:31:58] DEBUG  : |Py| Cycle (sec): None
[2025-04-11 23:31:58] DEBUG  : |Py| Jeedom API key: #####################################
[2025-04-11 23:31:58] DEBUG  : |Py|
[2025-04-11 23:31:58] INFO  : |Py| main(): pid 26038 - api_action --> execute_commands
[2025-04-11 23:31:59] INFO  : |Py| main(): result= 26c445ce-0a1b-4481-1702-5146a0ae0a26
[2025-04-11 23:31:59] INFO  : |Py| main(): pid 26038 - Handling cleanup. Exiting ...
[2025-04-11 23:31:59] INFO  : |Py|------------------------------------------------------------------------------------------------------

En revanche, je n’ai pas réussi à exécuter cette commande depuis un scénario.
Si je rentre dans la zone « Message » la même chaîne que je saisissais dans le Dashboard

{"month":4,"hour":23,"weekday":5,"year":2025,"day":11,"minute":33,"second":0}

alors l’interface me le transforme en la chaîne de caractères « Array » dès l’enregistrement

Fort logiquement, le log montre que l’API n’aime pas ça…

[2025-04-11 23:36:20] INFO  : |Py| OverKiz Client |-------------------------------------------------------------------------------------
[2025-04-11 23:36:20] INFO  : |Py| Message: Message from PHP
[2025-04-11 23:36:20] INFO  : |Py| Log level: debug
[2025-04-11 23:36:20] DEBUG  : |Py| Daemon state: ok
[2025-04-11 23:36:20] DEBUG  : |Py| API action: execute_commands
[2025-04-11 23:36:20] DEBUG  : |Py| API type: cloud
[2025-04-11 23:36:20] DEBUG  : |Py| Server: thermor_cozytouch
[2025-04-11 23:36:20] DEBUG  : |Py| User Name: #########
[2025-04-11 23:36:20] DEBUG  : |Py| User Password: ####
[2025-04-11 23:36:20] DEBUG  : |Py| API payload: {'capabilityId': None, 'capabilityValue': None, 'absenceValues': None, 'commands': [{'name': 'setAbsenceEndDate', 'parameters': ['Array']}], 'deviceId': None, 'deviceURL': 'modbuslink://####-####-####/1#1', 'gateway_id': None, 'label': 'setAbsenceEndDate', 'oid': None, 'register_event_listener': None, 'timestamp': None, 'token_label': None, 'token_scope': None, 'token_uuid': None}
[2025-04-11 23:36:20] DEBUG  : |Py| Local API gateway URL:
[2025-04-11 23:36:20] DEBUG  : |Py| Local API verify SSL: False
[2025-04-11 23:36:20] DEBUG  : |Py| Local API token:
[2025-04-11 23:36:20] DEBUG  : |Py| Fetch Loop Period (sec): 1
[2025-04-11 23:36:20] DEBUG  : |Py| importDataAsJson: True
[2025-04-11 23:36:20] DEBUG  : |Py| Callback url: url
[2025-04-11 23:36:20] DEBUG  : |Py| Cycle (sec): None
[2025-04-11 23:36:20] DEBUG  : |Py| Jeedom API key: #######################
[2025-04-11 23:36:20] DEBUG  : |Py|
[2025-04-11 23:36:20] INFO  : |Py| main(): pid 27297 - api_action --> execute_commands
[2025-04-11 23:36:20] ERROR  : |Ov| OverkizApi.process_command() execute_commands, exception type= <class 'pyoverkiz.exceptions.OverkizException'>, exception4= {'errorCode': 'INCOMPATIBLE_VALUE', 'error': 'setAbsenceEndDate() : Invalid value for command parameter p1 : expected object value but got Array (String)'}
[2025-04-11 23:36:20] INFO  : |Py| main(): result= False
[2025-04-11 23:36:20] DEBUG  : |Py| main(): api_action_result is Falsy.
[2025-04-11 23:36:20] INFO  : |Py| main(): pid 27297 - Handling cleanup. Exiting ...
[2025-04-11 23:36:20] INFO  : |Py|------------------------------------------------------------------------------------------------------

Pour définir cette date de fin depuis le scénario j’ai tenté plusieurs syntaxes (avec ou sans guillemets, des virgules, des points-virgules, des accolades, etc…).
Mais sans succès.
Quelqu’un saurait-il m’aiguiller ?

Par avance merci


Informations Jeedom

Core : 4.4.19 (master)
DNS Jeedom : non

Plugin : SomfyUnified
Version : 2025-03-24 18:25:36 (stable)
Statut Démon : Démarré - (2025-04-11 23:04:01)

Bonsoir,

Le problème à partir d’un scénario est que le Core Jeedom transforme la valeur saisie en Array.
Pour contourner cette limitation, il faut passer par un bloc code pour définir le champ Date qui sera transmis selon le bon format.
Voici un exemple de bloc code:

// DEFINE & FORMAT A DATE/TIME TO BE SENT AS A MESSAGE
$tags = $scenario->getTags();
// Define the object DateTime
$dateObject = new stdClass();
$dateObject->year 		= 2025;
$dateObject->month 		= 4;
$dateObject->day 		= 8;
$dateObject->hour 		= 28;
$dateObject->minute 	= 00;
$dateObject->second 	= 0;
$dateObject->weekday 	= 2;
// Convert the PHP Object to JSON
$jsonString = json_encode($dateObject);
//
$tags['#AbsenceStartDate#'] = $jsonString;
$scenario->setTags($tags);

puis exécuter la commande correspondante en utilisant le tag:

Le Titre n’est pas utilisé.

1 « J'aime »

Ah effectivement, je n’aurais jamais trouvé tout seul :sweat_smile:
Ca marche nickel, merci pour la réponse rapide !

Ce sujet a été automatiquement fermé après 24 heures suivant le dernier commentaire. Aucune réponse n’est permise dorénavant.