Forum eedomus
https://forum.eedomus.com/

[Store] Gardena Smart System
https://forum.eedomus.com/viewtopic.php?f=50&t=8501
« Précédent  Page 2 sur 4  Suivant »
Auteur:  ghostrider [ 29 Avr 2020 13:09 ]
Sujet du message:  Re: [Store] Gardena Smart System

Bonjour,

Avant tout un grand merci pour le travail formidable réalisé, je viens tout juste de m'inscrire sur le forum, bien que je le suis depuis mes débuts avec Eedomus. J'ai fais la dernière mise à jour du script et étonnement les actions de commande fonctionnent sur mon système d'arrosage lorsque je fais un test des valeurs en mode configuration, avec cependant le message d'erreur suivant :

## ERROR: Querying [https://api.smart.gardena.dev/v1/command/ff093e31-8d42-4a79-9b1b-04328138cae0] Error 0:

Et si j'essaye d'utiliser les actions dans le plugin rien ne se passe... Savez vous d'ou cela peut venir ?
Merci d'avance pour votre aide.
Auteur:  influman [ 29 Avr 2020 14:20 ]
Sujet du message:  Re: [Store] Gardena Smart System

J’ai le meme message en mode tester, c’est sans doute lié au mode d’appel PUT.
Mais ca n’empeche pas le fonctionnement.
Ca marche tres bien cote lancement classique chez moi.

As tu change qqchose ?
Var3 doit etre un multiple de 60 secondes.
Auteur:  ghostrider [ 30 Avr 2020 10:27 ]
Sujet du message:  Re: [Store] Gardena Smart System

Et bien non j'ai même relancé une installation sans succès, le VAR3 est toujours à 600 par défaut.
Je vais retenter c'est étrange que cela ne marche pas en mode classique mais bien en test, j'ai jamais eu ça par avant...

Edit : je viens de supprimer le plugin, supprimer le script, refaire une installation du plugin en autorisant tous les périphérique (jusqu'à maintenant je mettais que le WaterControl...) et toujours pas de succès sauf le test
Auteur:  influman [ 30 Avr 2020 12:15 ]
Sujet du message:  Re: [Store] Gardena Smart System

ghostrider a écrit:Et bien non j'ai même relancé une installation sans succès, le VAR3 est toujours à 600 par défaut.
Je vais retenter c'est étrange que cela ne marche pas en mode classique mais bien en test, j'ai jamais eu ça par avant...

Edit : je viens de supprimer le plugin, supprimer le script, refaire une installation du plugin en autorisant tous les périphérique (jusqu'à maintenant je mettais que le WaterControl...) et toujours pas de succès sauf le test


Tu lances depuis quelle interface ?
Pc, smartphone ?
Essaye via une regle aussi
Auteur:  ghostrider [ 30 Avr 2020 14:08 ]
Sujet du message:  Re: [Store] Gardena Smart System

Je lance depuis le pc, je vais tenter à partir d'une règle c'est une bonne idée, je tente.

Edit : Bon et bien ne fonctionne pas à partir d'une règle ou d'un lancement Smartphone...
Auteur:  ghostrider [ 30 Avr 2020 16:24 ]
Sujet du message:  Re: [Store] Gardena Smart System

Bon et bien c'est réglé, si cela peut servir à quelqu'un, j'ai simplement renouvelé la demande de clé API chez Gardena, c'est tout bon ! à nouveau un grand merci à toi pour ce super plugin ! C'est du super boulot ! ;)
Auteur:  ghostrider [ 01 Mai 2020 09:45 ]
Sujet du message:  Re: [Store] Gardena Smart System

Ah et si je peux faire une petite remarque, je pense qu'il y a une erreur sur la variable créée par le plugin, car il spécifie que le timer est indiqué en VAR2 au lieu de VAR3.

Enfin chez moi...

Bonne journée
Auteur:  influman [ 01 Mai 2020 11:01 ]
Sujet du message:  Re: [Store] Gardena Smart System

ghostrider a écrit:Ah et si je peux faire une petite remarque, je pense qu'il y a une erreur sur la variable créée par le plugin, car il spécifie que le timer est indiqué en VAR2 au lieu de VAR3.

Enfin chez moi...

Bonne journée


T’as raison merci. C’est corrige.
Je peux pas livrer sur le store, ca ne marche pas
Auteur:  oakado@gmail.com [ 17 Fév 2021 16:09 ]
Sujet du message:  Re: [Store] Gardena Smart System

Hello,

merciiiiiii beaucoup pour ce plug in !!!
je viens d'acquerir le system smart water, avec la valve et un capteur de sol.
l'année prochain j'ajouterais le module pour les electrovannes et de nouveau capteurs
Aucun soucis pour la valve elle remonte impeccable.
Par contre impossible de recuperer les info du capteur de sol.

J'ai remarqué que pour recuperer le status de la valve "Gardena - Valve 1 - Activity"
le Xpath est : /GARDENA/VALVE/VALUE
et l'url est : http://localhost/script/?exec=gardena.p ... ng&server=[VAR1]&clientid=[VAR2]&location=1&device=1&valve=1
et que le type de donnée est "Liste de valeurs"

Par contre pour le capteur de sol si je prend l'exemple de "Gardena - Sensor 1 - humidity"
l'url est : http://localhost/script/?exec=gardena.p ... ng&server=[VAR1]&clientid=[VAR2]&location=1&device=1
le Xpath est /GARDENA/HUMIDITY
et le type de donnée est "texte"

en regardant la doc sur l'API j'ai l'impression que dans ce cas les valeurs à remonter ne sont pas HUMIDITY mais SOILHUMIDITY
je me demande si le Xpath ne devrait pas être /GARDENA/SENSOR/SOILHUMIDITY
et au niveau de l'url il faudrait-il rajouter "&Sensor=1" à la fin ?
est ce qu'il faudrait changer le type de valeur ?

J'ai essayé avec ces modifs mais rien ne remonte.
quand je test le Xpath j'ai ERREUR: Valeur lue vide

Ce ne sont que des déductions mais si il y a avait moyen d'avoir un petit coup de main pour faire remonter les infos ce serait génial.

un très grand merci d'avance

Julien
Auteur:  oakado@gmail.com [ 24 Fév 2021 15:56 ]
Sujet du message:  Re: [Store] Gardena Smart System

please, un ptit coup de main :)

merciiii
Auteur:  KikiFUNstyle [ 24 Fév 2021 17:06 ]
Sujet du message:  Re: [Store] Gardena Smart System

Copie/colle le XML et dis nous qu'elle valeur tu veux récupérer du XML.
Auteur:  oakado@gmail.com [ 24 Fév 2021 17:55 ]
Sujet du message:  Re: [Store] Gardena Smart System

Hello,

Voici le XML, les infos que je n'arrive pas à recuperer sont celle du Sensor, je mets à la suite la conf des peripheriques qui sont toutes identiques seul change le chemin XPATH
/GARDENA/AMBIENTTEMPERATURE
/GARDENA/LIGHT
/GARDENA/SOILTEMPERATURE
/GARDENA/HUMIDITY

Code : Tout sélectionner
<?php
   $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";     
   //***********************************************************************************************************************
   // V2.04 : Gardena / copyright Influman 2020
   /**
   * API officiel Husqvarna - Gardena Smart System API - https://developer.1689.cloud/
   */
   $action = getArg("action", true);
   $server = getArg("server", true); // VAR1
   $clientid = getArg("clientid", true);
   $value = getArg("value", false);
   $location = getArg("location", false,1);
   $appareil = getArg("device", false,1);
   $valve = getArg("valve", false,1);
   $timer = getArg("timer", false);
   $debug = getArg("debug", false, 0);
   $periph_id = getArg('eedomus_controller_module_id');
   if ($action == '' ) {
      die();
   }
   $xml .= "<GARDENA>";
   
   // SESSIONS // Ouverture de sessions
   if ($action != "polling") {
      $token_expire = loadVariable("GARDENA_EXPIRE");
      if (time() > $token_expire) {
         $tab_param = explode(",",$server);
         $login = $tab_param[0];
         $pass = utf8_decode($tab_param[1]);
         $credentials = "grant_type=password&client_id=".$clientid."&username=".$login."&password=".$pass;
         $url = "https://api.authentication.husqvarnagroup.dev/v1/oauth2/token";
         $response = httpQuery($url, 'POST', $credentials, NULL, NULL, true, false);
         $return_api = sdk_json_decode($response);
         if (array_key_exists("access_token",$return_api)) {
            $token = $return_api['access_token'];
            $user_id = $return_api['user_id'];
            $provider = $return_api['provider'];
            saveVariable("GARDENA_TOKEN", $token);
            saveVariable("GARDENA_PROVIDER", $provider);
            $token_expire = $return_api['expires_in'] + time();
            saveVariable("GARDENA_EXPIRE", $token_expire);
            
         } else {
            $xml .= "<STATUS>Erreur Authentification: ".$return_api['error_description']."</STATUS>";
            $xml .= "</GARDENA>";
            sdk_header('text/xml');
            echo $xml;
            die();
         }
      } else {
         $token = loadVariable("GARDENA_TOKEN");
         $provider = loadVariable("GARDENA_PROVIDER");
      }
      $headers = array(     
         'Authorization: Bearer '.$token,
         'Authorization-Provider: '.$provider,                                                                               
         'X-Api-Key: '.$clientid); 
   }
   
   // GLOBAL STATUS // Lecture des donnees API
   if ($action == "getstatus") {
      $status = "";
      $tab_devices = array();
      $url = "https://api.smart.gardena.dev/v1/locations";
      $response = httpQuery($url, 'GET', NULL, NULL, $headers, true, false);
      $return_api = sdk_json_decode($response);
      $i = 0;
      $j = 0;
      $k = 0;
      $l = 0;
      $tab_location = array();
      $tab_devices = array();
      $tab_services = array();
      $tab_common = array();
      $tab_valve_set = array();
      $tab_valves = array();
      $tab_sensor = array();
      $tab_mower = array();
      $tab_power_socket = array();
      foreach($return_api['data'] as $location) {
         $i++;
         $l = 0;
         $tab_location[$i]['id'] = $location['id'];
         $tab_location[$i]['name'] = $location['attributes']['name'];
         // recherche des devices de cette location
         $url = "https://api.smart.gardena.dev/v1/locations/".$location['id'];
         $response_device = httpQuery($url, 'GET', NULL, NULL, $headers, true, false);
         $return_device = sdk_json_decode(utf8_encode($response_device));
         // récupération des devices et services
         foreach($return_device['included'] as $device) {
             if ($device['type'] == "DEVICE") {
               $j++;
               $l++;
               $tab_devices[$j]['location_id'] = $location['id'];
               $tab_devices[$j]['id'] = $device['id'];
               $tab_devices[$j]['num'] = $l;
               $tab_devices[$j]['is_valve'] = false;
               $tab_devices[$j]['is_sensor'] = false;
               $tab_devices[$j]['is_mower'] = false;
               $tab_devices[$j]['is_power_socket'] = false;
               
               $nb_valve = 0;
               foreach($device['relationships']['services']['data'] as $service) {
                     $k++;
                  $tab_services[$k]['device_id'] = $device['id'];
                  $tab_services[$k]['id'] = $service['id'];
                  $tab_services[$k]['type'] = $service['type'];
                  if ($service['type'] == 'VALVE') {
                     $nb_valve++;
                     $tab_devices[$j]['is_valve'] = true;
                     $tab_devices[$j]['nbvalve'] = $nb_valve;
                  }
                  if ($service['type'] == 'SENSOR') {
                     $tab_devices[$j]['is_sensor'] = true;
                  }
                  if ($service['type'] == 'MOWER') {
                     $tab_devices[$j]['is_mower'] = true;
                  }
                  if ($service['type'] == 'POWER_SOCKET') {
                     $tab_devices[$j]['is_power_socket'] = true;
                  }
               } // fin boucle services du device
            }
            if ($device['type'] == "COMMON") {
               $tab_common[$device['id']]['name'] = $device['attributes']['name']['value'];
                 $tab_common[$device['id']]['batterylevel'] = $device['attributes']['batteryLevel']['value'];
                 $tab_common[$device['id']]['batterystate'] = $device['attributes']['batteryState']['value'];
                 $tab_common[$device['id']]['rflinklevel'] = $device['attributes']['rfLinkLevel']['value'];
                 $tab_common[$device['id']]['rflinkstate'] = $device['attributes']['rfLinkState']['value'];
                 $tab_common[$device['id']]['modeltype'] = $device['attributes']['modelType']['value'];
               
            }
            if ($device['type'] == "VALVE_SET") {
               $tab_valve_set[$device['id']]['state'] = $device['attributes']['state']['value'];
             }
            if ($device['type'] == "VALVE") {
               $tab_valves[$device['id']]['state'] = $device['attributes']['state']['value'];
               $tab_valves[$device['id']]['name'] = $device['attributes']['name']['value'];
                 $tab_valves[$device['id']]['activity'] = $device['attributes']['activity']['value'];
               if (strpos($device['id'], ":") !== false) {
                  $tab_valves[$device['id']]['num'] = substr($device['id'],-1);
               } else {
                  $tab_valves[$device['id']]['num'] = 1;
               }
             }
            if ($device['type'] == "SENSOR") {
               $tab_sensor[$device['id']]['soilHumidity'] = $device['attributes']['soilHumidity']['value'];
               $tab_sensor[$device['id']]['soilTemperature'] = $device['attributes']['soilTemperature']['value'];
               $tab_sensor[$device['id']]['ambientTemperature'] = $device['attributes']['ambientTemperature']['value'];
               $tab_sensor[$device['id']]['lightIntensity'] = $device['attributes']['lightIntensity']['value'];
             }
            if ($device['type'] == "MOWER") {
               $tab_mower[$device['id']]['state'] = $device['attributes']['state']['value'];
               $tab_mower[$device['id']]['activity'] = $device['attributes']['activity']['value'];
               $tab_mower[$device['id']]['operatingHours'] = $device['attributes']['operatingHours']['value'];
            }
            if ($device['type'] == "POWER_SOCKET") {
               $tab_power_socket[$device['id']]['state'] = $device['attributes']['state']['value'];
               $tab_power_socket[$device['id']]['activity'] = $device['attributes']['activity']['value'];
               $tab_power_socket[$device['id']]['duration'] = $device['attributes']['duration']['value'];
            }
         
         } // fin boucle devices de la location   
      } // fin boucle Location
      
      // alimentation du XML
      $i = 0;
      foreach($tab_location as $location) {
         $i++;
         $k = 0;
         $l = 0;
         $xml .= "<TOKEN>".$token."</TOKEN>";
         $xml .= "<LOCATION_".$i.">";
         $xml .= "<ID>".$location['id']."</ID>";
         $xml .= "<NAME>".$location['name']."</NAME>";
         $xml .= "<DEVICES>";
         $nbdevices = 0;
         $nbvalves = 0;
         foreach($tab_devices as $device) {
            if ($device['location_id'] == $location['id']) {
               $k++;
               $nbdevices++;
               $xml .= "<DEVICE_".$device['num'].">";
               $xml .= "<ID>".$device['id']."</ID>";
               if ($device['is_valve']) {
                  $xml .= "<NBVALVE>".$device['nbvalve']."</NBVALVE>";
               }
               
               foreach($tab_services as $service) {
                  if ($service['device_id'] == $device['id']) {
                     
                     //$xml .= "<TYPE>".$service['type']."</TYPE>";
                     if ($service['type'] == 'COMMON') {
                        $xml .= "<MODEL>".$tab_common[$service['id']]['modeltype']."</MODEL>";
                        $xml .= "<BATTERYLVL>".$tab_common[$service['id']]['batterylevel']."</BATTERYLVL>";
                        $xml .= "<BATTERYSTA>".$tab_common[$service['id']]['batterystate']."</BATTERYSTA>";
                        $xml .= "<RFLINKLVL>".$tab_common[$service['id']]['rflinklevel']."</RFLINKLVL>";
                        $xml .= "<RFLINKSTA>".$tab_common[$service['id']]['rflinkstate']."</RFLINKSTA>";
                     }
                     if ($service['type'] == 'VALVE_SET') {
                        $xml .= "<VALVE_SET>".$tab_valve_set[$service['id']]['state']."</VALVE_SET>";
                     }
                     if ($service['type'] == 'VALVE') {
                        $l++;
                        $xml .= "<VALVE_".$tab_valves[$service['id']]['num'].">";
                        $xml .= "<NAME>".$tab_valves[$service['id']]['name']."</NAME>";
                        $xml .= "<STATE>".$tab_valves[$service['id']]['state']."</STATE>";
                        $xml .= "<ACTIVITY>".$tab_valves[$service['id']]['activity']."</ACTIVITY>";
                        $xml .= "<SERVICE_ID>".$service['id']."</SERVICE_ID>";
                        $xml .= "</VALVE_".$tab_valves[$service['id']]['num'].">";
                        if ($tab_valves[$service['id']]['state'] != "UNAVAILABLE") {
                           if ($l>1) {$status_valve .= " | ";}
                           $status_valve .= "D".$device['num'].".V".$tab_valves[$service['id']]['num'].". ".$tab_valves[$service['id']]['state'];
                        }
                        $nbvalves ++;
                     }
                     if ($service['type'] == 'SENSOR') {
                        $xml .= "<HUMIDITY>".$tab_sensor[$service['id']]['soilHumidity']."</HUMIDITY>";
                        $xml .= "<SOILTEMPERATURE>".$tab_sensor[$service['id']]['soilTemperature']."</SOILTEMPERATURE>";
                        $xml .= "<AMBIENTTEMPERATURE>".$tab_sensor[$service['id']]['ambientTemperature']."</AMBIENTTEMPERATURE>";
                        $xml .= "<LIGHT>".$tab_sensor[$service['id']]['lightIntensity']."</LIGHT>";
                     }
                     if ($service['type'] == 'MOWER') {
                        $xml .= "<STATE>".$tab_mower[$service['id']]['state']."</STATE>";
                        $xml .= "<ACTIVITY>".$tab_mower[$service['id']]['activity']."</ACTIVITY>";
                        $xml .= "<HOURS>".$tab_mower[$service['id']]['operatingHours']."</HOURS>";
                     }
                     if ($service['type'] == 'POWER_SOCKET') {
                        $xml .= "<STATE>".$tab_power_socket[$service['id']]['state']."</STATE>";
                        $xml .= "<ACTIVITY>".$tab_power_socket[$service['id']]['activity']."</ACTIVITY>";
                        $xml .= "<DURATION>".$tab_power_socket[$service['id']]['duration']."</DURATION>";
                     }
                    }
               }
               $nbvalves += $mydevice['nbvalve'];
               $xml .= "</DEVICE_".$device['num'].">";
             }
            
         }
         $xml .= "</DEVICES>";
      }
      $xml .= "</LOCATION_".$i.">";
      
      if ($status_valve == "") {
          $status = "Gardena Smart System | ".$nbdevices." device";
          if ($nbdevices > 1) { $status .= "s";}
          $status .= " ".$nbvalves. " valve";
          if ($nbvalves > 1) { $status .= "s";}
      } else {
          $status = $status_valve;
      }
      saveVariable("GARDENA_LOCATION",$tab_location);
      saveVariable("GARDENA_DEVICES",$tab_devices);
      saveVariable("GARDENA_SERVICES",$tab_services);
      saveVariable("GARDENA_COMMON",$tab_common);
      saveVariable("GARDENA_VALVE_SET",$tab_valve_set);
      saveVariable("GARDENA_VALVE",$tab_valves);
      saveVariable("GARDENA_SENSOR",$tab_sensor);
      saveVariable("GARDENA_MOWER",$tab_mower);
      saveVariable("GARDENA_POWER_SOCKET",$tab_power_socket);
      $xml .= "<STATUS>".$status."</STATUS>";
      $xml .= "</GARDENA>";
      sdk_header('text/xml');
      echo $xml;
      die();
   }
   
   // COMMANDS // Actionner un appareil
   if (($action == "water" || $action == "mower" || $action == "power") && $location != "" && $appareil != "") {
      $tab_location = loadVariable("GARDENA_LOCATION");
      $tab_devices = loadVariable("GARDENA_DEVICES");
      $tab_services = loadVariable("GARDENA_SERVICES");
      $tab_valves = loadVariable("GARDENA_VALVE");
      $deviceid = sdk_get_deviceid($location, $appareil, $tab_location, $tab_devices);
      if ($action == "water") {
            if ($value == "stop") {
               $commands = "{\"data\": {\"id\": \"request-1\", \"type\": \"VALVE_CONTROL\", \"attributes\": {\"command\": \"STOP_UNTIL_NEXT_TASK\"}}}";     
            }
            if ($value == "stop" && $valve == 0) {
               $commands = "{\"data\": {\"id\": \"request-1\", \"type\": \"VALVE_SET_CONTROL\", \"attributes\": {\"command\": \"STOP_UNTIL_NEXT_TASK\"}}}";     
            }
            if ($value == "pause") {
               $commands = "{\"data\": {\"id\": \"request-1\", \"type\": \"VALVE_CONTROL\", \"attributes\": {\"command\": \"PAUSE\"}}}";     
            }
            if ($value == "unpause") {
               $commands = "{\"data\": {\"id\": \"request-1\", \"type\": \"VALVE_CONTROL\", \"attributes\": {\"command\": \"UNPAUSE\"}}}";     
            }
            if ($value == "start") {
               if ($timer == "" || $timer == 0) {
                  $timer = 600;
               }
               $commands = "{\"data\": {\"id\": \"request-1\", \"type\": \"VALVE_CONTROL\", \"attributes\": {\"command\": \"START_SECONDS_TO_OVERRIDE\", \"seconds\": ".$timer."}}}"; 
               
            }
            if ($valve == 0) {
               $serviceid = sdk_get_serviceid($deviceid, "VALVE_SET", null, $tab_services, $tab_valves);
            } else {
               $serviceid = sdk_get_serviceid($deviceid, "VALVE", $valve, $tab_services, $tab_valves);
            }
            
            $url = "https://api.smart.gardena.dev/v1/command/".$serviceid;
      }
      if ($action == "power") {
            if ($value == "stop") {
               $commands = "{\"data\": {\"id\": \"request-1\", \"type\": \"POWER_SOCKET_CONTROL\", \"attributes\": {\"command\": \"STOP_UNTIL_NEXT_TASK\"}}}";     
            }
            if ($value == "pause") {
               $commands = "{\"data\": {\"id\": \"request-1\", \"type\": \"POWER_SOCKET_CONTROL\", \"attributes\": {\"command\": \"PAUSE\"}}}";     
            }
            if ($value == "unpause") {
               $commands = "{\"data\": {\"id\": \"request-1\", \"type\": \"POWER_SOCKET_CONTROL\", \"attributes\": {\"command\": \"UNPAUSE\"}}}";     
            }
            if ($value == "startseconds") {
               if ($timer == "" || $timer == 0) {
                  $timer = 600;
               }
               $commands = "{\"data\": {\"id\": \"request-1\", \"type\": \"POWER_SOCKET_CONTROL\", \"attributes\": {\"command\": \"START_SECONDS_TO_OVERRIDE\", \"seconds\": ".$timer."}}}"; 
            
            }
            if ($value == "start") {
               $commands = "{\"data\": {\"id\": \"request-1\", \"type\": \"POWER_SOCKET_CONTROL\", \"attributes\": {\"command\": \"START_OVERRIDE\"}}}"; 
            }
            $serviceid = sdk_get_serviceid($deviceid, "POWER_SOCKET", null, $tab_services, $tab_valves);
            $url = "https://api.smart.gardena.dev/v1/command/".$serviceid;
            
            
      }
      if ($action == "mower") {
            if ($value == "park_timer") {
               $commands = "{\"data\": {\"id\": \"request-1\", \"type\": \"MOWER_CONTROL\", \"attributes\": {\"command\": \"PARK_UNTIL_NEXT_TASK\"}}}";     
            }
            if ($value == "park_notice") {
               $commands = "{\"data\": {\"id\": \"request-1\", \"type\": \"MOWER_CONTROL\", \"attributes\": {\"command\": \"PARK_UNTIL_FURTHER_NOTICE\"}}}";     
            }
            if ($value == "resume") {
               $commands = "{\"data\": { \"id\": \"request-1\", \"type\": \"MOWER_CONTROL\", \"attributes\": {\"command\": \"START_DONT_OVERRIDE\"}}}";     
            }
            if ($value == "start") {
                if ($timer == "" || $timer == 0) {
                  $timer = 3600;
               }
               $commands = "{\"data\": {\"id\": \"request-1\", \"type\": \"MOWER_CONTROL\", \"attributes\": {\"command\": \"START_SECONDS_TO_OVERRIDE\", \"seconds\": ".$timer."}}}";   
            }
            $serviceid = sdk_get_serviceid($deviceid, "MOWER",null, $tab_services, $tab_valves);
            $url = "https://api.smart.gardena.dev/v1/command/".$serviceid;
      }
      $headers = array(   
      "Content-Type: application/vnd.api+json",      
      "Authorization: Bearer ".$token,
      "Authorization-Provider: ".$provider,
      "X-Api-Key: ".$clientid);
      $response = httpQuery($url, "PUT", $commands, NULL, $headers, true, false);
      die();
   }
   
   // POLLING // Lecture des données par capteur
   if ($action == "polling") {
      $tab_location = loadVariable("GARDENA_LOCATION");
      $tab_devices = loadVariable("GARDENA_DEVICES");
      $tab_services = loadVariable("GARDENA_SERVICES");
      $tab_sensor = loadVariable("GARDENA_SENSOR");
      $tab_valves = loadVariable("GARDENA_VALVE");
      $tab_common = loadVariable("GARDENA_COMMON");
      $tab_valve_set = loadVariable("GARDENA_VALVE_SET");
      $tab_mower = loadVariable("GARDENA_MOWER");
      $tab_power_socket = loadVariable("GARDENA_POWER_SOCKET");
      $deviceid = sdk_get_deviceid($location, $appareil, $tab_location, $tab_devices);
      $xml .= "<LOCATION_ID>".$tab_location[$location]['id']."</LOCATION_ID>";
      $xml .= "<LOCATION_NAME>".$tab_location[$location]['name']."</LOCATION_NAME>";
      $xml .= "<DEVICEID>".$deviceid."</DEVICEID>";
            
      foreach($tab_services as $service) {
         if ($service['device_id'] == $deviceid) {
            if ($service['type'] == 'COMMON') {
               $xml .= "<MODEL>".$tab_common[$service['id']]['modeltype']."</MODEL>";
               $xml .= "<BATTERYLVL>".$tab_common[$service['id']]['batterylevel']."</BATTERYLVL>";
               $xml .= "<BATTERYSTA>".$tab_common[$service['id']]['batterystate']."</BATTERYSTA>";
               $xml .= "<RFLINKLVL>".$tab_common[$service['id']]['rflinklevel']."</RFLINKLVL>";
               $xml .= "<RFLINKSTA>".$tab_common[$service['id']]['rflinkstate']."</RFLINKSTA>";
            }
            if ($service['type'] == 'VALVE_SET') {
               $xml .= "<VALVE_SET>".$tab_valve_set[$service['id']]['state']."</VALVE_SET>";
            }
            if ($service['type'] == 'VALVE') {
               if ($tab_valves[$service['id']]['num'] == $valve) {
                  $xml .= "<VALVE>";
                  $xml .= "<NAME>".$tab_valves[$service['id']]['name']."</NAME>";
                  $xml .= "<STATE>".$tab_valves[$service['id']]['state']."</STATE>";
                  $activity = $tab_valves[$service['id']]['activity'];
                  $xml .= "<ACTIVITY>".$activity."</ACTIVITY>";
                  if ($activity == "CLOSED") { $activity = "0";}
                  if ($activity == "MANUAL_WATERING") { $activity = "50";}
                  if ($activity == "SCHEDULED_WATERING") { $activity = "100";}
                  $xml .= "<VALUE>".$activity."</VALUE>";
                  $xml .= "</VALVE>";
               }
            }
            if ($service['type'] == 'SENSOR') {
               $xml .= "<HUMIDITY>".$tab_sensor[$service['id']]['soilHumidity']."</HUMIDITY>";
               $xml .= "<SOILTEMPERATURE>".$tab_sensor[$service['id']]['soilTemperature']."</SOILTEMPERATURE>";
               $xml .= "<AMBIENTTEMPERATURE>".$tab_sensor[$service['id']]['ambientTemperature']."</AMBIENTTEMPERATURE>";
               $xml .= "<LIGHT>".$tab_sensor[$service['id']]['lightIntensity']."</LIGHT>";
            }
            if ($service['type'] == 'MOWER') {
               $xml .= "<STATE>".$tab_mower[$service['id']]['state']."</STATE>";
               $xml .= "<ACTIVITY>".$tab_mower[$service['id']]['activity']."</ACTIVITY>";
               $xml .= "<HOURS>".$tab_mower[$service['id']]['operatingHours']."</HOURS>";
            }
            if ($service['type'] == 'POWER_SOCKET') {
               $xml .= "<STATE>".$tab_power_socket[$service['id']]['state']."</STATE>";
               $xml .= "<ACTIVITY>".$tab_power_socket[$service['id']]['activity']."</ACTIVITY>";
               $xml .= "<DURATION>".$tab_power_socket[$service['id']]['duration']."</DURATION>";
            }
         }   
      }
      $xml .= "</GARDENA>";
      sdk_header('text/xml');
      echo $xml;
      die();
   }
   
   function sdk_get_deviceid($location, $appareil, $tab_location, $tab_devices) {
      $locationid =  $tab_location[$location]['id'];
      foreach ($tab_devices as $devices) {
         if ($devices['location_id'] == $locationid && $devices['num'] == $appareil) {
            return $devices['id'];
         }
      }
   }
   function sdk_get_serviceid($deviceid, $type, $valve, $tab_services, $tab_valves) {
      foreach ($tab_services as $services) {
         if ($services['device_id'] == $deviceid && $services['type'] == $type) {
            if ($type == "MOWER" || $type == "VALVE_SET" || $type == "POWER_CONTROL") {
               return $services['id'];
            }
            if ($type == "VALVE") {
               if ($tab_valves[$services['id']]['num'] == $valve) {
                  return $services['id'];
               }
            }
         }
      }
   }
?>



sensor_Humidity.png
sensor_Humidity.png (18.05 Kio) Consulté 8388 fois



Merci beaucoup
Auteur:  KikiFUNstyle [ 24 Fév 2021 19:02 ]
Sujet du message:  Re: [Store] Gardena Smart System

Arf là ça c'est le code du script ...

Va sur Tester dans les paramètres experts et c'est le XML du résultat qu'il me faut :D
Auteur:  oakado@gmail.com [ 25 Fév 2021 18:40 ]
Sujet du message:  Re: [Store] Gardena Smart System

Hello ,

Arf, mon message n’a pas été envoyé hier !
Quand j’effectue le test le retour c’est valeur lue nul

Merciiiii
Auteur:  oakado@gmail.com [ 25 Fév 2021 18:41 ]
Sujet du message:  Re: [Store] Gardena Smart System

Le boulet j’ai mal lu !
Je fais ça dans la soirée :)
Auteur:  oakado@gmail.com [ 26 Fév 2021 10:19 ]
Sujet du message:  Re: [Store] Gardena Smart System

Salut,

voici le résultat XML du test :
<?xml version="1.0" encoding="ISO-8859-1" ?><GARDENA><LOCATION_ID>61634e5d-d886-4c7f-b7b8-00b581b285bc</LOCATION_ID><LOCATION_NAME>My Garden</LOCATION_NAME><DEVICEID>53ab5d2a-d0d4-4b12-ad85-26eb40276add</DEVICEID><VALVE_SET>OK</VALVE_SET><VALVE><NAME>Distributeur eau</NAME><STATE>OK</STATE><ACTIVITY>CLOSED</ACTIVITY><VALUE>0</VALUE></VALVE><MODEL>GARDENA smart Water Control</MODEL><BATTERYLVL>83</BATTERYLVL><BATTERYSTA>OK</BATTERYSTA><RFLINKLVL>30</RFLINKLVL><RFLINKSTA>OFFLINE</RFLINKSTA></GARDENA>

je ne comprend pas bien pourquoi ca me parle du statu de la valve alors que la requete devrait porter sur le sensor


Résultat XPath :
ERREUR: Valeur lue vide

Si ca te causais ce serait chouette :)
si seulement on pouvait faire ca en powershell :D

merci beaucoup
Julien
Auteur:  KikiFUNstyle [ 26 Fév 2021 10:49 ]
Sujet du message:  Re: [Store] Gardena Smart System

Tout d'abord dans ton XML tu n'as pas les informations
Code : Tout sélectionner
/GARDENA/AMBIENTTEMPERATURE
/GARDENA/LIGHT
/GARDENA/SOILTEMPERATURE
/GARDENA/HUMIDITY


Ensuite d'après le script pour avoir cela il faut de ton device soit de type
SENSOR


Je n'ai pas de produit gardena pour tester
Tu peux jouer avec le swagger si tu connais -> https://developer.husqvarnagroup.cloud/ ... I#/swagger

(sinon par MP il faudra que tu me donnes tes identifiants)
Auteur:  KikiFUNstyle [ 26 Fév 2021 10:53 ]
Sujet du message:  Re: [Store] Gardena Smart System

Sinon faudrait voir avec @Influman :D
Auteur:  oakado@gmail.com [ 26 Fév 2021 18:55 ]
Sujet du message:  Re: [Store] Gardena Smart System

:) j'ai envoyé un petit message à Influman, ce serait si il avait le temps d'y jeter un oeil.
Si ce n'est pas le cas et que ca ne te dérange pas, je te filerais mes identifiants.

C'est super sympas

Merci
Julien
Auteur:  chris-s [ 15 Mars 2021 21:34 ]
Sujet du message:  Re: [Store] Gardena Smart System

Bonjour,

Merci à Influman pour ce plugin que j'ai installé pour contrôler mon robot tondeuse Sileno.
Je vais pouvoir me créer quelques règles sympa :mrgreen:

Question : est-ce que si j'achète un water sensor je vais pouvoir avoir une info de type "il pleut'" ou "il ne pleut pas" ?
Je voudrais faire rentrer à la base le robot s'il commence à pleuvoir.
Page 2 sur 4 Le fuseau horaire est UTC+1 heure