Gardena/Husqvarna Smart Sileno Mähroboter einbinden

Hallo,

sodela … bissle gespielt … Steuern des Bewässerungscomputers geht mit den Befehlen - Wenn man im Debug Modus Safari den Befehl aufruft (Neuer Tab) … kann man per Cut und Paste den Befehl kopieren / Safari Aufruf (Sollte dann verdeutlichen wie die Bewässerungscomputer bei Jimmy „auseinandergehalten“ werden) … Im wesentlichen folgt es den API Befehlen und Methoden wie für den Sensor.

Leider nach wie vor muss ich das mit meiner externen Software machen … aber zumindest geht es ja und Ihr könnt es in Euer Schema implementieren.

Starten / Stoppen / Default Bewässerungszeit „schreiben“ geht ohne Probleme.

Grüsse,
MaLu

Hallo Jimmy,

vorab auf die schnelle eine Version für den Bewässerungs Computer.

Es funkt z.Zt. nur EIN /AUS.

Für die verschiedenen BWC habe ich auch noch keine Lösung.

Als vorab Maßnahme wäre die Device ID im Script direkt einzutragen. (Aus dem Auflistescript)

Wenn ich Zeit finde geht es weiter.

Hier die Class


<?php/*//Ref. http://www.dxsdata.com/2016/07/php-class-for-gardena-smart-system-api/* Ref. http://www.roboter-forum.com/showthread.php?16777-Gardena-Smart-System-Analyse* Angepasst 20.08.2016 / WiBo* gardena_waterung.ips.php*/// -----------------------------------------------------------------------------class gardena_wasser{    var $user_id, $token, $locations;    var $devices = array();
    const LOGINURL        = "https://sg-api.dss.husqvarnagroup.net/sg-1/sessions";    const LOCATIONSURL    = "https://sg-api.dss.husqvarnagroup.net/sg-1/locations/?user_id=";    const DEVICESURL    = "https://sg-api.dss.husqvarnagroup.net/sg-1/devices?locationId=";    const CMDURL        = "https://sg-api.dss.husqvarnagroup.net/sg-1/devices/|DEVICEID|/abilities/outlet/command?locationId=";
    var $CMD_VENTIL_START_05            = array("name" => "manual_override", "parameters" => array("duration" => 5));    var $CMD_VENTIL_START_10            = array("name" => "manual_override", "parameters" => array("duration" => 10));    var $CMD_VENTIL_START_30            = array("name" => "manual_override", "parameters" => array("duration" => 30));
    var $CMD_VENTIL_START_MANUAL_AUF    = array("name" => "manual_override", "parameters" => array("duration" => 1));    var $CMD_VENTIL_START_MANUAL_ZU        = array("name" => "manual_override", "parameters" => array("duration" => 0));// -----------------------------------------------------------------------------    // Mover Mäherstatus    const CATEGORY            = "watering_computer";// -----------------------------------------------------------------------------    function gardena_wasser($user, $pw)    {        $data = array(            "sessions" => array(                "email" => "$user", "password" => "$pw")            );        $data_string = json_encode($data);        $ch = curl_init(self::LOGINURL);        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);        curl_setopt($ch, CURLOPT_HTTPHEADER, array(            'Content-Type:application/json',            'Content-Length: ' . strlen($data_string))        );        $result = curl_exec($ch);        $data = json_decode($result);        $this -> token = $data -> sessions -> token;        $this -> user_id = $data -> sessions -> user_id;        $this -> loadLocations();        $this -> loadDevices();    }// -----------------------------------------------------------------------------    function loadLocations()    {        $url = self::LOCATIONSURL . $this -> user_id;        $ch = curl_init($url);        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);        curl_setopt($ch, CURLOPT_HTTPHEADER, array(            'Content-Type:application/json',            'X-Session:' . $this -> token)        );        $this -> locations = json_decode(curl_exec($ch)) -> locations;      }// -----------------------------------------------------------------------------    function loadDevices()    {        foreach($this->locations as $location)        {            $url = self::DEVICESURL . $location -> id;            $ch = curl_init($url);            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);            curl_setopt($ch, CURLOPT_HTTPHEADER, array(                'Content-Type:application/json',                'X-Session:' . $this -> token)            );            $this -> devices[$location -> id] = json_decode(curl_exec($ch)) -> devices;        }    }// -----------------------------------------------------------------------------    /*    * Finds the first occurrence of a certain category type.    * Example: You want to find your only mower, having one or more gardens.     * @param constant $category    */    function getFirstDeviceOfCategory($category)    {        foreach($this -> devices as $locationId => $devices)        {            foreach($devices as $device)                if ($device -> category == $category)                    return $device;        }    }// -----------------------------------------------------------------------------    function getDeviceLocation($device)    {        foreach($this -> locations as $location)            foreach($location -> devices as $d)                if ($d == $device -> id)                    return $location;    }// -----------------------------------------------------------------------------    function sendCommand($device, $command)    {        $location = $this -> getDeviceLocation($device);        $url = str_replace("|DEVICEID|", $device -> id, self::CMDURL) . $location -> id;        $data_string = json_encode($command);        $ch = curl_init($url);        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);        curl_setopt($ch, CURLOPT_HTTPHEADER, array(            'Content-Type:application/json',            'X-Session:' . $this -> token,            'Content-Length: ' . strlen($data_string)            ));        $result = curl_exec($ch);        if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == "204") //success            return true;        return json_encode($result);    }// -----------------------------------------------------------------------------    function getMowerState($device)    {        foreach ($device -> abilities as $ability)            if ($ability -> name == self::CATEGORY)                foreach($ability -> properties as $property)                    if ($property -> name == self::PROPERTY_STATUS)                        return $property -> value;    }// =============================================================================    function getInfo($device, $category_name, $proberty_name)    {        foreach ($device -> abilities as $ability)            if ($ability -> name == $category_name)                foreach($ability -> properties as $property)                    if ($property -> name == $proberty_name)                        return $property -> value;    }// =============================================================================    function getDeviceStatusReportFriendly($device)    {        $result = "";        foreach ($device -> status_report_history as $entry)        {            $result .= $entry -> timestamp . " | " . $entry -> source . " | " . $entry -> message . "<br>";        }        return $result;    }// -----------------------------------------------------------------------------}
?>

Und hier Test Aktionsscript


<?php
    error_reporting(E_ALL);    include("pass.ips.php");    include("gardena_waterung.ips.php");
    $gardena  = new gardena_wasser($pw_user_maeher, $pw_pawo_maeher);//    print_r($gardena);    $watering = $gardena -> getFirstDeviceOfCategory($gardena::CATEGORY);//    print_r($watering);
//    $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_MANUAL_AUF);    $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_MANUAL_ZU);
    echo $result;
?>

Neue Watering CLASS

<?php/*
//Ref. http://www.dxsdata.com/2016/07/php-class-for-gardena-smart-system-api/
* Ref. http://www.roboter-forum.com/showthread.php?16777-Gardena-Smart-System-Analyse
* Angepasst 25.08.2016 / WiBo
* gardena_waterung.ips.php
*/
// -----------------------------------------------------------------------------
class gardena_wasser
{
    var $user_id, $token, $locations;
    var $devices = array();


    const LOGINURL        = "https://sg-api.dss.husqvarnagroup.net/sg-1/sessions";
    const LOCATIONSURL    = "https://sg-api.dss.husqvarnagroup.net/sg-1/locations/?user_id=";
    const DEVICESURL    = "https://sg-api.dss.husqvarnagroup.net/sg-1/devices?locationId=";
    const CMDURL        = "https://sg-api.dss.husqvarnagroup.net/sg-1/devices/|DEVICEID|/abilities/outlet/command?locationId=";


    var $CMD_VENTIL_START_01    = array("name" => "manual_override", "parameters" => array("manual_override" => "open","duration" =>  1));
    var $CMD_VENTIL_START_02    = array("name" => "manual_override", "parameters" => array("manual_override" => "open","duration" =>  2));
    var $CMD_VENTIL_START_03    = array("name" => "manual_override", "parameters" => array("manual_override" => "open","duration" =>  3));
    var $CMD_VENTIL_START_04    = array("name" => "manual_override", "parameters" => array("manual_override" => "open","duration" =>  4));
    var $CMD_VENTIL_START_05    = array("name" => "manual_override", "parameters" => array("manual_override" => "open","duration" =>  5));
    var $CMD_VENTIL_START_10    = array("name" => "manual_override", "parameters" => array("manual_override" => "open","duration" => 10));
    var $CMD_VENTIL_START_15    = array("name" => "manual_override", "parameters" => array("manual_override" => "open","duration" => 15));
    var $CMD_VENTIL_START_20    = array("name" => "manual_override", "parameters" => array("manual_override" => "open","duration" => 20));
    var $CMD_VENTIL_START_25    = array("name" => "manual_override", "parameters" => array("manual_override" => "open","duration" => 25));
    var $CMD_VENTIL_START_30    = array("name" => "manual_override", "parameters" => array("manual_override" => "open","duration" => 30));


    var $CMD_VENTIL_START_ON    = array("name" => "manual_override");
    var $CMD_VENTIL_START_ZU    = array("name" => "manual_override", "parameters" => array("manual_override" => "close","duration" => 0));
// -----------------------------------------------------------------------------


    const CATEGORY_WATERING     = "watering_computer";


// -----------------------------------------------------------------------------
    function gardena_wasser($user, $pw)
    {
        $data = array(
            "sessions" => array(
                "email" => "$user", "password" => "$pw")
            );
        $data_string = json_encode($data);
        $ch = curl_init(self::LOGINURL);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type:application/json',
            'Content-Length: ' . strlen($data_string))
        );
        $result = curl_exec($ch);
        $data = json_decode($result);
        $this -> token = $data -> sessions -> token;
        $this -> user_id = $data -> sessions -> user_id;
        $this -> loadLocations();
        $this -> loadDevices();
    }
// -----------------------------------------------------------------------------
    function loadLocations()
    {
        $url = self::LOCATIONSURL . $this -> user_id;
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type:application/json',
            'X-Session:' . $this -> token)
        );
        $this -> locations = json_decode(curl_exec($ch)) -> locations;  
    }
// -----------------------------------------------------------------------------
    function loadDevices()
    {
        foreach($this->locations as $location)
        {
            $url = self::DEVICESURL . $location -> id;
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                'Content-Type:application/json',
                'X-Session:' . $this -> token)
            );
            $this -> devices[$location -> id] = json_decode(curl_exec($ch)) -> devices;
        }
    }
// -----------------------------------------------------------------------------
    /*
    * Finds the first occurrence of a certain category type.
    * Example: You want to find your only mower, having one or more gardens. 
    * @param constant $category
    */
    function getFirstDeviceOfCategory($category)
    {
        foreach($this -> devices as $locationId => $devices)
        {
            foreach($devices as $device)
                if ($device -> category == $category)
                    return $device;
        }
    }
// -----------------------------------------------------------------------------
    function getDeviceLocation($device)
    {
        foreach($this -> locations as $location)
            foreach($location -> devices as $d)
                if ($d == $device -> id)
                    return $location;
    }
// -----------------------------------------------------------------------------
    function sendCommand($device, $command)
    {
        $location = $this -> getDeviceLocation($device);
        $url = str_replace("|DEVICEID|", $device -> id, self::CMDURL) . $location -> id;
        $data_string = json_encode($command);
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type:application/json',
            'X-Session:' . $this -> token,
            'Content-Length: ' . strlen($data_string)
            ));
        $result = curl_exec($ch);
        if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == "204") //success
            return true;
        return json_encode($result);
    }
// -----------------------------------------------------------------------------
    function getMowerState($device)
    {
        foreach ($device -> abilities as $ability)
            if ($ability -> name == self::CATEGORY)
                foreach($ability -> properties as $property)
                    if ($property -> name == self::PROPERTY_STATUS)
                        return $property -> value;
    }
// =============================================================================
    function getInfo($device, $category_name, $proberty_name)
    {
        foreach ($device -> abilities as $ability)
            if ($ability -> name == $category_name)
                foreach($ability -> properties as $property)
                    if ($property -> name == $proberty_name)
                        return $property -> value;
    }
// =============================================================================
    function getDeviceStatusReportFriendly($device)
    {
        $result = "";
        foreach ($device -> status_report_history as $entry)
        {
            $result .= $entry -> timestamp . " | " . $entry -> source . " | " . $entry -> message . "<br>";
        }
        return $result;
    }
}


?>

Aktions Script

<?php

    error_reporting(E_ALL);
    include("pass.ips.php");
    include("php_gardena_watering_class.ips.php");


    $id_wfc_1 = 28992 /*[Webfront Terminal]*/;
    $id_wfc_2 = 50755 /*[Webfront iPad Home]*/;
    $text_1   = "Robi Schaltaktion";
    $text_2   = "Kann wegen Regen nicht raus";
    $icon     = "Speaker";
    $anzeig   = 20;
    $id_ereig = 56440 /*[Gardena\Watering\Terasse\Ventilstatus auslesen\]*/;
    $min_lese = 1;
    $id_regen = 57255 /*[Enozean\Multisensor Wetter\0189162E_Eltako FWS61 - über Gateway Wohnen\Regen]*/;
    $st_regen = GetValue($id_regen);


    $gardena  = new gardena_wasser($pw_user_maeher, $pw_pawo_maeher);
    $watering = $gardena -> getFirstDeviceOfCategory($gardena::CATEGORY_WATERING);


    if( $_IPS['SENDER'] == 'WebFront' OR $_IPS['SENDER'] == 'Execute' )
        {
            SetValue($_IPS['VARIABLE'], $_IPS['VALUE']);
            $switch = $_IPS['VALUE'];
            switch ($switch)
            {
            case 0:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_ZU);
                $text_1 = "Robi Nächster Zeitplan";
                break;
            // Parken ----------------------------------------------------------
            case 1:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_01);
                $text_1 = "Robi Nächster Zeitplan";
                break;
            case 2:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_02);
                $text_1 = "Robi Zeitplan pausieren";
                break;
            case 3:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_03);
                $text_1 = "Robi Zeitplan fortsetzen";
                break;
            case 4:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_04);
                $text_1 = "Robi - 12 Std. Mähen";
                break;
            case 5:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_05);
                $text_1 = "Robi - 24 Std. Mähen";
                break;
            case 6:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_06);
                $text_1 = "Robi - 3 Tage Mähen";
                break;
            case 7:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_07);
                $text_1 = "Robi Nächster Zeitplan";
                break;
            case 8:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_08);
                $text_1 = "Robi Zeitplan pausieren";
                break;
            case 9:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_09);
                $text_1 = "Robi Zeitplan fortsetzen";
                break;
            case 10:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_10);
                $text_1 = "Robi - 12 Std. Mähen";
                break;
            case 11:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_15);
                $text_1 = "Robi - 24 Std. Mähen";
                break;
            case 12:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_20);
                $text_1 = "Robi - 3 Tage Mähen";
                break;
            case 13:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_25);
                $text_1 = "Robi - 24 Std. Mähen";
                break;
            case 14:
                $result = $gardena -> sendCommand($watering, $gardena -> CMD_VENTIL_START_30);
                $text_1 = "Robi - 3 Tage Mähen";
                break;
            }
        IPS_RunScript(56848 /*[Gardena\Watering\Terasse\Ventilstatus auslesen]*/);
        IPS_SetEventCyclic($id_ereig, 0, 0, 0, 2, 2, $min_lese);
        IPS_SetEventActive($id_ereig, true);
//        WFC_SendNotification($id_wfc_1, $text_1, $result, $icon, $anzeig);
        }
?>

Und dann noch Statusabfragen

<?php

    error_reporting(E_ALL); 
    include("pass.ips.php"); 
    include("php_gardena_watering_class.ips.php"); 


    $gardena  = new gardena_wasser($pw_user_maeher, $pw_pawo_maeher); 
    $watering = $gardena -> getFirstDeviceOfCategory($gardena::CATEGORY_WATERING); 


// -----------------------------------------------------------------------------


    $category_name = "outlet"; 
    $ventil_open                        = 12951 /*[Gardena\Watering\Terasse\Ventil_Open]*/;
    $ventil_manual_override                = 42078 /*[Gardena\Watering\Terasse\Ventil_Manual_Override]*/;
    $ventil_button_manual_override_time    = 28038 /*[Gardena\Watering\Terasse\Ventil_Button_Manual_Override_Time]*/;


    $proberty_name = "valve_open"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name);
    SetValue($ventil_open, $status); 


    $proberty_name = "manual_override"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($ventil_manual_override, $status); 


    $proberty_name = "button_manual_override_time"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($ventil_button_manual_override_time, $status); 


?>
<?php

    error_reporting(E_ALL); 
    include("pass.ips.php"); 
    include("php_gardena_watering_class.ips.php"); 


    $gardena  = new gardena_wasser($pw_user_maeher, $pw_pawo_maeher); 
    $watering = $gardena -> getFirstDeviceOfCategory($gardena::CATEGORY_WATERING); 


// -----------------------------------------------------------------------------
    $category_name = "device_info"; 
    $id_device_manufaktur        = 19045 /*[Gardena\Watering\Terasse\Device_Manufaktur]*/;
    $id_device_product            = 51995 /*[Gardena\Watering\Terasse\Device_Product]*/;
    $id_device_serial_number    = 38519 /*[Gardena\Watering\Terasse\Device_Serial_Nr]*/; 
    $id_device_version            = 25273 /*[Gardena\Watering\Terasse\Device_Version]*/; 
    $id_device_category            = 11017 /*[Gardena\Watering\Terasse\Device_Category]*/; 
    $id_device_last_time_online    = 12467 /*[Gardena\Watering\Terasse\Device_last_Time]*/; 
    $id_device_sgtin            = 43199 /*[Gardena\Watering\Terasse\Device_sgtin]*/; 


    $proberty_name = "manufacturer"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($id_device_manufaktur, $status); 


    $proberty_name = "product"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($id_device_product, $status); 


    $proberty_name = "serial_number"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($id_device_serial_number, $status); 


    $proberty_name = "version"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($id_device_version, $status); 


    $proberty_name = "category"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($id_device_category, $status); 


    $proberty_name = "last_time_online"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($id_device_last_time_online, $status); 


    $proberty_name = "sgtin"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($id_device_sgtin, $status); 
// -----------------------------------------------------------------------------
    $category_name = "battery"; 
    $id_device_level    = 59685 /*[Gardena\Watering\Terasse\Battery_Level]*/;
    $battery_status        = 14687 /*[Gardena\Watering\Terasse\Battery_Status]*/; 


    $proberty_name = "level"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($id_device_level, $status); 


    $proberty_name = "disposable_battery_status"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    if($status == "out_of_operation") {$status = "Leer";}
    if($status == "replace_now")      {$status = "Erneuern";}
    if($status == "low")              {$status = "Bald erneuern";}
    if($status == "ok")               {$status = "OK";}
    if($status == "undefined")        {$status = "Fehler";}
    SetValue($battery_status, $status); 
// -----------------------------------------------------------------------------
    $category_name = "radio"; 
    $id_device_quality    = 10451 /*[Gardena\Watering\Terasse\Radio_Quality]*/; 
    $connection_status    = 43449 /*[Gardena\Watering\Terasse\Radio_Connection_Status]*/; 
    $signal_status        = 31159 /*[Gardena\Watering\Terasse\Radio_Status]*/; 


    $proberty_name = "quality"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($id_device_quality, $status); 


    $proberty_name = "connection_status"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($connection_status, $status); 


    $proberty_name = "state"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($signal_status, $status); 
// -----------------------------------------------------------------------------
    $category_name = "ambient_temperature";
    
    $temperature    = 20880 /*[Gardena\Watering\Terasse\Sensor_Temperatur]*/; 
    $frost_warning    = 26179 /*[Gardena\Watering\Terasse\Sensor_Fostwarnung]*/; 


    $proberty_name = "temperature"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    SetValue($temperature, $status); 


    $proberty_name = "frost_warning"; 
    $status = $gardena -> getInfo($watering, $category_name, $proberty_name); 
    if($status == "no_frost")  {$status = "Nein";}
    if($status == "frost")     {$status = "Ja";}
    if($status == "undefined") {$status = "Fehler";}
    SetValue($frost_warning, $status); 


?>

Baut ihr da eventuell auch noch ein PHP Modul aus den ganzen Skripten? Das wäre sehr hilfreich. Wie gut funktioniert denn der Bodenfeuchtesensor? Ich suche nach einem Ersatz für den Koubachi.

Hallo zusammen,

auch wenn in diesem Faden schon länger nicht mehr geantwortet wurde, versuche ich diesen nochmals hervorzuholen.

In welchem Zyklus fragt ihr die Sensoren bzw. die Infos aus der Cloud ab? Bzw wie oft aktualisieren sich die Werte in der Gardena Wolke?

Danke und Gruß, Sven

Geht es denn bei Euch noch? Grüsse, MaLu - also seit heute?

Weil die Scripte als einzelnes gelinde gesagt ein Trauerspiel waren und die Einrichtung nervig hab ich mal daraus ein Modul gebaut, es ist frühes Alpha-Stadium, aber wer Lust hat kann es testen und mir Feedback geben.
Bislang geht nur der Sileno, also andere Sensoren oder Watering habe ich noch nicht integriert, das kommt vielleicht später.

Hier der Link auf das Module: GitHub - Hagbard235/GardenaSmart

Einfach neue Instanz anlegen und Username und Passwort eingeben… sind die Falsch kommt noch eine riesige Fehlerseite, das behebe ich noch. Viel Spaß damit.

Hallo zusammen,
ich habe einen Husqvarna Automower 310 mit dem Connect Modul inkl. Esim. Den Rasenmäher habe ich eine Garage mit Rolltor gegönnt und war nun auf der Suche Infos zum Zustand des Mähroboters zu erhalten.

Also mein erster kurzer Weg.

Mower_Class

 <?php
/*
//Ref. http://www.dxsdata.com/2016/07/php-class-for-gardena-smart-system-api/
* Ref. http://www.roboter-forum.com/showthread.php?16777-Gardena-Smart-System-Analyse
* Angepasst 03.07.2016 / WiBo
*/
// -----------------------------------------------------------------------------
class gardena
{
    var $user_id, $token, $locations;
    var $devices = array();

    const LOGINURL        = "https://sg-api.dss.husqvarnagroup.net/sg-1/sessions";
    const LOCATIONSURL    = "https://sg-api.dss.husqvarnagroup.net/sg-1/locations/?user_id=";
    const DEVICESURL    = "https://sg-api.dss.husqvarnagroup.net/sg-1/devices?locationId=";
    const CMDURL        = "https://sg-api.dss.husqvarnagroup.net/sg-1/devices/|DEVICEID|/abilities/mower/command?locationId=";

    var $CMD_MOWER_PARK_UNTIL_NEXT_TIMER        = array("name" => "park_until_next_timer");
    var $CMD_MOWER_PARK_UNTIL_FURTHER_NOTICE    = array("name" => "park_until_further_notice");
    var $CMD_MOWER_START_RESUME_SCHEDULE        = array("name" => "start_resume_schedule");
    var $CMD_MOWER_START_24HOURS                = array("name" => "start_override_timer", "parameters" => array("duration" => 1440));
    var $CMD_MOWER_START_3DAYS                    = array("name" => "start_override_timer", "parameters" => array("duration" => 4320));
// -----------------------------------------------------------------------------
    // Gateway
    const CATEGORY_DEVICE_INFO        = "device_info";
    const CATEGORY_GATEWAY            = "gateway";
    // Mover Device Info
    const CATEGORY_DEVICE            = "device_info";
    // Mover Akkuzustand
    const CATEGORY_BATTERY            = "battery";
    // Mover Radio - Funksignal
    const CATEGORY_RADIO            = "radio";
    // Mover Mäherstatus
    const CATEGORY_MOWER            = "mower";
    const PROPERTY_STATUS            = "status";
    // Mover Temperatur
    const CATEGORY_TEMPERATUR        = "internal_temperature";
// -----------------------------------------------------------------------------
    function gardena($user, $pw)
    {
        $data = array(
            "sessions" => array(
                "email" => "$user", "password" => "$pw")
            );
        $data_string = json_encode($data);
        $ch = curl_init(self::LOGINURL);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type:application/json',
            'Content-Length: ' . strlen($data_string))
        );
        $result = curl_exec($ch);
        $data = json_decode($result);
        $this -> token = $data -> sessions -> token;
        $this -> user_id = $data -> sessions -> user_id;
        $this -> loadLocations();
        $this -> loadDevices();
    }
// -----------------------------------------------------------------------------
    function loadLocations()
    {
        $url = self::LOCATIONSURL . $this -> user_id;
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type:application/json',
            'X-Session:' . $this -> token)
        );
        $this -> locations = json_decode(curl_exec($ch)) -> locations;
    }
// -----------------------------------------------------------------------------
    function loadDevices()
    {
        foreach($this->locations as $location)
        {
            $url = self::DEVICESURL . $location -> id;
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                'Content-Type:application/json',
                'X-Session:' . $this -> token)
            );
            $this -> devices[$location -> id] = json_decode(curl_exec($ch)) -> devices;
        }
    }
// -----------------------------------------------------------------------------
    /*
    * Finds the first occurrence of a certain category type.
    * Example: You want to find your only mower, having one or more gardens.
    * @param constant $category
    */
    function getFirstDeviceOfCategory($category)
    {
        foreach($this -> devices as $locationId => $devices)
        {
            foreach($devices as $device)
                if ($device -> category == $category)
                    return $device;
        }
    }
// -----------------------------------------------------------------------------
    function getDeviceLocation($device)
    {
        foreach($this -> locations as $location)
            foreach($location -> devices as $d)
                if ($d == $device -> id)
                    return $location;
    }
// -----------------------------------------------------------------------------
    function sendCommand($device, $command)
    {
        $location = $this -> getDeviceLocation($device);
        $url = str_replace("|DEVICEID|", $device -> id, self::CMDURL) . $location -> id;
        $data_string = json_encode($command);
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type:application/json',
            'X-Session:' . $this -> token,
            'Content-Length: ' . strlen($data_string)
            ));
        $result =  curl_exec($ch);
        if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == "204") //success
            return true;
        return json_encode($result);
    }
// -----------------------------------------------------------------------------
    function getMowerState($device)
    {
        foreach ($device -> abilities as $ability)
            if ($ability -> name == self::CATEGORY_MOWER)
                foreach($ability -> properties as $property)
                    if ($property -> name == self::PROPERTY_STATUS)
                        return $property -> value;
    }
// =============================================================================
    function getInfo($device, $category_name, $proberty_name)
    {
        foreach ($device -> abilities as $ability)
            if ($ability -> name == $category_name)
                foreach($ability -> properties as $property)
                    if ($property -> name == $proberty_name)
                        return $property -> value;
    }
// =============================================================================
    function getDeviceStatusReportFriendly($device)
    {
        $result = "";
        foreach ($device -> status_report_history as $entry)
        {
            $result .= $entry -> timestamp . " | " . $entry -> source . " | " . $entry -> message . "<br>";
        }
        return $result;
    }
// -----------------------------------------------------------------------------
}

?>

Mower Status

 <?php

    error_reporting(E_ALL);
    include("pass.ips.php");
    include("php_gardena_mower_class.ips.php");

    $gardena = new gardena($pw_user_maeher, $pw_pawo_maeher);
    $mower = $gardena -> getFirstDeviceOfCategory($gardena::CATEGORY_MOWER);
    $category_name = "mower";

    $id_mover_operation        = 28133 /*[Garten\Automower\Mower_Status\Mower_Manual_Operation]*/;
    $id_mover_status        = 49950 /*[Garten\Automower\Mower_Status\Mower_Status]*/;
    $id_mover_fornextstart    = 17211 /*[Garten\Automower\Mower_Status\Mower_Source_Next_Start]*/;
    $id_mover_timenextstart    = 20841 /*[Garten\Automower\Mower_Status\Mower_Timestamp_Next_Start]*/;
    $id_mover_endtime        = 28594 /*[Garten\Automower\Mower_Status\Mower_Override_End_Time]*/;

    $proberty_name = "manual_operation";
    $status = $gardena -> getInfo($mower, $category_name, $proberty_name);
    SetValue($id_mover_operation, $status);

    $proberty_name = "status";
    $status = $gardena -> getInfo($mower, $category_name, $proberty_name);
    SetValue($id_mover_status, $status);

    $proberty_name = "source_for_next_start";
    $status = $gardena -> getInfo($mower, $category_name, $proberty_name);
    SetValue($id_mover_fornextstart, $status);

    $proberty_name = "timestamp_next_start";
    $status = $gardena -> getInfo($mower, $category_name, $proberty_name);
    SetValue($id_mover_timenextstart, $status);

    $proberty_name = "override_end_time";
    $status = $gardena -> getInfo($mower, $category_name, $proberty_name);
    SetValue($id_mover_endtime, $status);

?>

Leider bekomme ich beim Ausführen vom Mower Status folgende Fehlermeldung

Notice:  Trying to get property of non-object in /var/lib/symcon/scripts/php_gardena_mower_class.ips.php on line 145

Warning:  Invalid argument supplied for foreach() in /var/lib/symcon/scripts/php_gardena_mower_class.ips.php on line 145

Kann mir hier Jemand helfen?

Hallo,
super Sache die Abfrage in einem Modul zu verfassen. Nur habe ich hier die gleiche Fehlermeldung nur in einer anderen Zeile

Notice:  Trying to get property of non-object in /var/lib/symcon/scripts/php_gardena_mower_class.ips.php on line 147

Warning:  Invalid argument supplied for foreach() in /var/lib/symcon/scripts/php_gardena_mower_class.ips.php on line 147  

Liegt es vielleicht in der Tat daran, dass es doch ein Husqvarna ist und irgendwo etwas quer liegt?

Hallo Hagbard 235,

vielen Dank für Dein tolles Modul!
Bis auf ein Problem hat alles sofort funktioniert:)

Bei mir wird unter anderem der Batterie Level nicht aktualisiert.
Beim ersten Start des Moduls werden die Daten eingelesen. Allerdings nur einmal.

Der Status aktuelle Aktion wird dagegen brav aktualisiert.

Gibt es eine Möglichkeit auch den Batterie Level zu aktualisieren.

Vielen Dank!

Gruß

Axel

So ich habe noch einmal weiter probiert. Wenn ich im Skript Mower_Status in Zeile 10

print_r($gardena);

einfüge, dann kommt folgendes Ergebnis:


  gardena Object
(
    [user_id] => a8f64e35-0c20-4378-934f-###########
    [token] => 7885b88a-b3ff-468f-b5bf-###########
    [locations] => Array
        (
        )

    [devices] => Array
        (
        )

    [CMD_MOWER_PARK_UNTIL_NEXT_TIMER] => Array
        (
            [name] => park_until_next_timer
        )

    [CMD_MOWER_PARK_UNTIL_FURTHER_NOTICE] => Array
        (
            [name] => park_until_further_notice
        )

    [CMD_MOWER_START_RESUME_SCHEDULE] => Array
        (
            [name] => start_resume_schedule
        )

    [CMD_MOWER_START_24HOURS] => Array
        (
            [name] => start_override_timer
            [parameters] => Array
                (
                    [duration] => 1440
                )

        )

    [CMD_MOWER_START_3DAYS] => Array
        (
            [name] => start_override_timer
            [parameters] => Array
                (
                    [duration] => 4320
                )

        )

)

In devices und locations ist nichts enthalten. Woran kann dies liegen?

Hi,
hatte ich im develop-Zweig schon drin, hab es jetzt auch in den Master gepusht… sollte nach einem Modul-Update gehen.

Hi,

vielen Dank die Aktualisierung des Batterielevel haut jetzt super hin:)

Ist es möglich die Aktualisierung auch für den Funk Status zu realisieren?

Vielen Dank!

Gruß

Axel

Ist auch drin, aber per default auf 0 Minuten , also aus…

Da ich noch was anderes geändert habe kann es sein das du deine Instanz löschen und neu anlegen musst.

Vielen Dank!!!
Funktioniert super:)

Gab gerade noch ein MIni_Update weil die Datümer schlecht lesbar und in der falschen Zeitzone von Gardena geliefert werden. Jetzt ist es hübscher. Wenn noch was hübscher werden soll, sagt bescheid.

Ich habe im „develop“-Zweig des Moduls eine neue Version bereit gestellt. Dort kann man selber auswählen welche Werte im Zyklus abgefragt werden sollen. Wer mag kann das gerne mal testen und mir Feedback geben.

Achtung, Modul nicht abwärts kompatibel, weil u.a. die Variablen-Namen sich geändert haben.

Moin,

wie sieht es mit der Implementierung der anderen smart-Komponenten für dieses Paket aus, Feuchtigkeitssensor, Bewässerungscomputer?

Das wäre eine super Sache.

Habe immer noch nicht multiple Bewässerungscomputer vernünftig an den Start bekommen.

Skripte von Weibo liegen ja vor.

Gruß

Jimmy

Die Scripte bauen im Moment wohl auf ein einziges Gerät auf, auch der Rasenmäher ist nur einmal möglich. Die stellen sind zwar relativ leicht umzubauen, wo es nicht beachtet wurde, habe aber leider zum einen nur ein Gerät und zum anderen keine Bewässerungscomputer um es mal auszuprobieren.

Hi,

testen könnte ich. Habe vier Bewässerungscomputer im Einsatz.

Leider bekomme ich die Script nicht vernünftig eingebunden.

Ein komplettes Modul für die gesamte smart-Reihe wäre schon cool.