Action incorrecte

Bonjour @Loic,

J’ai remarqué, selon moi, un petit bug dans le #plugin-harmonyhub
Les actions (commandes) envoyées au hub sont incorrectes dans quelques cas, en effet le plugin utilise le « name » du json récupéré au lieu d’utilisé « command » dans la clé « action »
La plupart du temps c’est la même valeur mais pas toujours et dans ce cas l’action ne fonctionne pas.

un exemple ci-dessous les actions sont identiques excepté pour le « select » pour lequel il faut envoyer « ok » et pas « select »:

    "function":[
        {
            "action":"{\"command\":\"DirectionDown\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
            "name":"DirectionDown",
            "label":"Direction Down"
        },
        {
            "action":"{\"command\":\"DirectionLeft\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
            "name":"DirectionLeft",
            "label":"Direction Left"
        },
        {
            "action":"{\"command\":\"DirectionRight\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
            "name":"DirectionRight",
            "label":"Direction Right"
        },
        {
            "action":"{\"command\":\"DirectionUp\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
            "name":"DirectionUp",
            "label":"Direction Up"
        },
        {
            "action":"{\"command\":\"OK\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
            "name":"Select",
            "label":"Select"
        }
    ],
    "name":"NavigationBasic"

Pareil avec les numéros de chaine (sur tous les appareils que j’ai) mais pour ce cas tu avais déjà fait le replace de « number » pour que cela fonctionne dans le code (plus nécessaire si on prend directement la valeur de « command »

"function":[

    {
        "action":"{\"command\":\"0\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
        "name":"Number0",
        "label":"0"
    },
    {
        "action":"{\"command\":\"1\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
        "name":"Number1",
        "label":"1"
    },
    {
        "action":"{\"command\":\"2\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
        "name":"Number2",
        "label":"2"
    },
    {
        "action":"{\"command\":\"3\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
        "name":"Number3",
        "label":"3"
    },
    {
        "action":"{\"command\":\"4\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
        "name":"Number4",
        "label":"4"
    },
    {
        "action":"{\"command\":\"5\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
        "name":"Number5",
        "label":"5"
    },
    {
        "action":"{\"command\":\"6\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
        "name":"Number6",
        "label":"6"
    },
    {
        "action":"{\"command\":\"7\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
        "name":"Number7",
        "label":"7"
    },
    {
        "action":"{\"command\":\"8\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
        "name":"Number8",
        "label":"8"
    },
    {
        "action":"{\"command\":\"9\",\"type\":\"IRCommand\",\"deviceId\":\"62951606\"}",
        "name":"Number9",
        "label":"9"
    }

Pour corriger, dans le preupdate, vers la ligne 208 j’ai fait ceci:

  • rajouter la variable $actionCommand:
$actionCommand = json_decode($function["action"],true)['command'];

et utilsations dans le set du parameters au lieu de $action

$harmonyhubCmd->setConfiguration('parameters', $actionCommand);

ce qui donne:

			foreach ($result_json["device"] as $device) {
				if ($device["id"]==$this->getConfiguration('dispositifid')){
					$this->setConfiguration('dispoid', $device["id"]);
					$this->setConfiguration('disponame', $device["label"]);
					foreach ($device["controlGroup"] as $controlGroup) {
						foreach ($controlGroup["function"] as $function) {
							$action=$function["name"];
							$actionCommand = json_decode($function["action"],true)['command'];
							$name=str_replace('#','sharp',$function["label"]);
							$harmonyhubCmd = $this->getCmd(null, $action);
							if (!is_object($harmonyhubCmd)) {
								$harmonyhubCmd = new harmonyhubCmd();
								$harmonyhubCmd->setName(__($name, __FILE__));
								$harmonyhubCmd->setLogicalId($action);
								$harmonyhubCmd->setEqLogic_id($this->getId());
								$harmonyhubCmd->setConfiguration('parameters', $actionCommand);
								$harmonyhubCmd->setConfiguration('type', 'device');
								$harmonyhubCmd->setType('action');
								$harmonyhubCmd->setSubType('other');
								$harmonyhubCmd->setIsVisible(0);
								$harmonyhubCmd->save();
							}
						}
					}
				}
			}

Je met ici pour référence d’autres sujets qui semblent être le même problème (investigation en cours, j’ai demandé les logs):

Bonjour,
Il faudrait remonter ca a Jeedom SAS je ne m’occupe pas du tout de ce plugin…

Ok désolé je pensais.

Non désolé et pour être franc pour moi logitech harmony c’est une télécommande infrarouge…

Salut,

La correction proposée par @Mips est disponible en beta.

@Beta-testeurs : Dans l’attente de retours positifs pour passage en stable.

Et c’est passé en stable :slight_smile:

2 « J'aime »

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