From a8aabd8b07f768b1cfd09866b8139eeadc34f10b Mon Sep 17 00:00:00 2001 From: LeonGaultier Date: Thu, 7 Sep 2017 07:02:07 +0000 Subject: [PATCH] 73_GardenaSmartBridge: code clean, update german tranlation git-svn-id: https://svn.fhem.de/fhem/trunk@15024 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/73_GardenaSmartBridge.pm | 61 ++++++++++++-------- fhem/FHEM/74_GardenaSmartDevice.pm | 90 +++++++++++++++--------------- 3 files changed, 83 insertions(+), 69 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index b7a2fb638..1325c7381 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - bugfix: 73_GardenaSmartBridge: code clean, update german tranlation - feature: 74_AMADDevice: add ttsMsgVol, sets automatically a preset volume - feature: proxy global attribute for HttpUtils (Forum #60471) - bugfix: 93_DbLog: V2.22.5, several fixes Forum:#75894 diff --git a/fhem/FHEM/73_GardenaSmartBridge.pm b/fhem/FHEM/73_GardenaSmartBridge.pm index 928d0e843..a76c731d7 100644 --- a/fhem/FHEM/73_GardenaSmartBridge.pm +++ b/fhem/FHEM/73_GardenaSmartBridge.pm @@ -70,7 +70,7 @@ eval "use IO::Socket::SSL;1" or $missingModul .= "IO::Socket::SSL "; ###todo Hier fehlt noch Modulabfrage für ssl -my $version = "0.2.1"; +my $version = "0.2.2"; @@ -91,6 +91,7 @@ sub GardenaSmartBridge_ParseJSON($$); sub GardenaSmartBridge_getDevices($); sub GardenaSmartBridge_getToken($); sub GardenaSmartBridge_InternalTimerGetDeviceData($); +sub GardenaSmartBridge_createHttpValueStrings($@); @@ -285,33 +286,15 @@ sub GardenaSmartBridge_InternalTimerGetDeviceData($) { sub GardenaSmartBridge_Write($@) { my ($hash,$payload,$deviceId,$abilities) = @_; - my $name = $hash->{NAME}; + my $name = $hash->{NAME}; - my $session_id = $hash->{helper}{session_id}; - my $header = "Content-Type: application/json"; - my $uri = ''; - my $method = 'POST'; - $header .= "\r\nX-Session: $session_id" if( defined($hash->{helper}{session_id}) ); - $payload = '{' . $payload . '}' if( defined($payload) ); - $payload = '{}' if( not defined($payload) ); - - - if( $payload eq '{}' ) { - $method = 'GET'; - $uri .= '/locations/?user_id=' . $hash->{helper}{user_id} if( not defined($hash->{helper}{locations_id}) ); - readingsSingleUpdate($hash,'state','fetch locationId',1) if( not defined($hash->{helper}{locations_id}) ); - $uri .= '/sessions' if( not defined($hash->{helper}{session_id})); - $uri .= '/devices' if( not defined($abilities) and defined($hash->{helper}{locations_id}) ); - } + my ($session_id,$header,$uri,$method); - $uri .= '/sessions' if( not defined($hash->{helper}{session_id})); - - if( defined($hash->{helper}{locations_id}) ) { - $uri .= '/devices/' . $deviceId . '/abilities/' . $abilities . '/command' if( defined($abilities) and defined($payload) ); - $uri .= '?locationId=' . $hash->{helper}{locations_id}; - } + + ($payload,$session_id,$header,$uri,$method,$deviceId,$abilities) = GardenaSmartBridge_createHttpValueStrings($hash,$payload,$deviceId,$abilities); + HttpUtils_NonblockingGet( { url => $hash->{URL} . $uri, @@ -738,6 +721,36 @@ sub GardenaSmartBridge_ParseJSON($$) { return ($msg,$tail); } +sub GardenaSmartBridge_createHttpValueStrings($@) { + + my ($hash,$payload,$deviceId,$abilities) = @_; + my $session_id = $hash->{helper}{session_id}; + my $header = "Content-Type: application/json"; + my $uri = ''; + my $method = 'POST'; + $header .= "\r\nX-Session: $session_id" if( defined($hash->{helper}{session_id}) ); + $payload = '{' . $payload . '}' if( defined($payload) ); + $payload = '{}' if( not defined($payload) ); + + + if( $payload eq '{}' ) { + $method = 'GET'; + $uri .= '/locations/?user_id=' . $hash->{helper}{user_id} if( not defined($hash->{helper}{locations_id}) ); + readingsSingleUpdate($hash,'state','fetch locationId',1) if( not defined($hash->{helper}{locations_id}) ); + $uri .= '/sessions' if( not defined($hash->{helper}{session_id})); + $uri .= '/devices' if( not defined($abilities) and defined($hash->{helper}{locations_id}) ); + } + + $uri .= '/sessions' if( not defined($hash->{helper}{session_id})); + + if( defined($hash->{helper}{locations_id}) ) { + $uri .= '/devices/' . $deviceId . '/abilities/' . $abilities . '/command' if( defined($abilities) and defined($payload) ); + $uri .= '?locationId=' . $hash->{helper}{locations_id}; + } + + return ($payload,$session_id,$header,$uri,$method,$deviceId,$abilities); +} + diff --git a/fhem/FHEM/74_GardenaSmartDevice.pm b/fhem/FHEM/74_GardenaSmartDevice.pm index c1054174a..180b2b1c4 100644 --- a/fhem/FHEM/74_GardenaSmartDevice.pm +++ b/fhem/FHEM/74_GardenaSmartDevice.pm @@ -68,7 +68,7 @@ use Data::Dumper; #debugging eval "use JSON;1" or $missingModul .= "JSON "; -my $version = "0.2.2"; +my $version = "0.2.3"; @@ -391,9 +391,9 @@ sub GardenaSmartDevice_ReadingLangGerman($$) { 'off_disabled' => 'der Mäher ist ausgeschaltet', 'off_hatch_open' => 'deaktiviert. Abdeckung ist offen oder PIN-Code erforderlich', 'unknown' => 'unbekannter Status', - 'error' => 'fehler', - 'error_at_power_up' => 'neustart ...', - 'off_hatch_closed' => 'deaktiviert. Manueller Start erforderlich', + 'error' => 'Fehler', + 'error_at_power_up' => 'Neustart ...', + 'off_hatch_closed' => 'Deaktiviert. Manueller Start erforderlich', 'ok_cutting_timer_overridden' => 'manuelles mähen', 'parked_autotimer' => 'geparkt durch SensorControl', 'parked_daily_limit_reached' => 'abgeschlossen', @@ -401,72 +401,72 @@ sub GardenaSmartDevice_ReadingLangGerman($$) { 'outside_working_area' => 'außerhalb des Arbeitsbereichs', 'no_loop_signal' => 'kein Schleifensignal', 'wrong_loop_signal' => 'falsches Schleifensignal', - 'loop_sensor_problem_front' => 'problem Schleifensensor, vorne', - 'loop_sensor_problem_rear' => 'problem Schleifensensor, hinten', + 'loop_sensor_problem_front' => 'Problem Schleifensensor, vorne', + 'loop_sensor_problem_rear' => 'Problem Schleifensensor, hinten', 'trapped' => 'eingeschlossen', 'upside_down' => 'steht auf dem Kopf', 'low_battery' => 'niedriger Batteriestand', - 'empty_battery' => 'empty_battery', - 'no_drive' => 'no_drive', + 'empty_battery' => 'Batterie leer', + 'no_drive' => 'fährt nicht', 'lifted' => 'angehoben', 'stuck_in_charging_station' => 'eingeklemmt in Ladestation', - 'charging_station_blocked' => 'ladestation blockiert', - 'collision_sensor_problem_rear' => 'problem Stoßsensor hinten', - 'collision_sensor_problem_front' => 'problem Stoßsensor vorne', - 'wheel_motor_blocked_right' => 'radmotor rechts blockiert', - 'wheel_motor_blocked_left' => 'radmotor links blockiert', - 'wheel_drive_problem_right' => 'problem Antrieb, rechts', - 'wheel_drive_problem_left' => 'problem Antrieb, links', - 'cutting_system_blocked' => 'schneidsystem blockiert', - 'invalid_sub_device_combination' => 'Fehlerhafte Verbindung', - 'settings_restored' => 'standardeinstellungen', + 'charging_station_blocked' => 'Ladestation blockiert', + 'collision_sensor_problem_rear' => 'Problem Stoßsensor hinten', + 'collision_sensor_problem_front' => 'Problem Stoßsensor vorne', + 'wheel_motor_blocked_right' => 'Radmotor rechts blockiert', + 'wheel_motor_blocked_left' => 'Radmotor links blockiert', + 'wheel_drive_problem_right' => 'Problem Antrieb, rechts', + 'wheel_drive_problem_left' => 'Problem Antrieb, links', + 'cutting_system_blocked' => 'Schneidsystem blockiert', + 'invalid_sub_device_combination' => 'fehlerhafte Verbindung', + 'settings_restored' => 'Standardeinstellungen', 'electronic_problem' => 'elektronisches Problem', - 'charging_system_problem' => 'problem Ladesystem', - 'tilt_sensor_problem' => 'kippsensorproblem', + 'charging_system_problem' => 'Problem Ladesystem', + 'tilt_sensor_problem' => 'Kippsensor Problem', 'wheel_motor_overloaded_right' => 'rechter Radmotor überlastet', 'wheel_motor_overloaded_left' => 'linker Radmotor überlastet', - 'charging_current_too_high' => 'ladestrom zu hoch', + 'charging_current_too_high' => 'Ladestrom zu hoch', 'temporary_problem' => 'vorübergehendes Problem', - 'guide_1_not_found' => 'sk 1 nicht gefunden', - 'guide_2_not_found' => 'sk 2 nicht gefunden', - 'guide_3_not_found' => 'sk 3 nicht gefunden', - 'difficult_finding_home' => 'problem die Ladestation zu finden', - 'guide_calibration_accomplished' => 'kalibration des Suchkabels beendet', - 'guide_calibration_failed' => 'kalibration des Suchkabels fehlgeschlagen', + 'guide_1_not_found' => 'SK 1 nicht gefunden', + 'guide_2_not_found' => 'SK 2 nicht gefunden', + 'guide_3_not_found' => 'SK 3 nicht gefunden', + 'difficult_finding_home' => 'Problem die Ladestation zu finden', + 'guide_calibration_accomplished' => 'Kalibrierung des Suchkabels beendet', + 'guide_calibration_failed' => 'Kalibrierung des Suchkabels fehlgeschlagen', 'temporary_battery_problem' => 'kurzzeitiges Batterieproblem', - 'battery_problem' => 'batterieproblem', - 'alarm_mower_switched_off' => 'alarm! Mäher ausgeschalten', - 'alarm_mower_stopped' => 'alarm! Mäher gestoppt', - 'alarm_mower_lifted' => 'alarm! Mäher angehoben', - 'alarm_mower_tilted' => 'alarm! Mäher gekippt', - 'connection_changed' => 'verbindung geändert', - 'connection_not_changed' => 'verbindung nicht geändert', - 'com_board_not_available' => 'com board nicht verfügbar', + 'battery_problem' => 'Batterieproblem', + 'alarm_mower_switched_off' => 'Alarm! Mäher ausgeschalten', + 'alarm_mower_stopped' => 'Alarm! Mäher gestoppt', + 'alarm_mower_lifted' => 'Alarm! Mäher angehoben', + 'alarm_mower_tilted' => 'Alarm! Mäher gekippt', + 'connection_changed' => 'Verbindung geändert', + 'connection_not_changed' => 'Verbindung nicht geändert', + 'com_board_not_available' => 'COM Board nicht verfügbar', 'slipped' => 'rutscht', 'out_of_operation' => 'ausser Betrieb', 'replace_now' => 'kritischer Batteriestand, wechseln Sie jetzt', 'low' => 'niedrig', 'ok' => 'oK', 'no_source' => 'oK', - 'mower_charging' => 'mäher wurde geladen', - 'completed_cutting_autotimer' => 'sensorControl erreicht', - 'week_timer' => 'wochentimer erreicht', - 'countdown_timer' => 'stoppuhr Timer', + 'mower_charging' => 'Mäher wurde geladen', + 'completed_cutting_autotimer' => 'Sensor Control erreicht', + 'week_timer' => 'Wochentimer erreicht', + 'countdown_timer' => 'Stoppuhr Timer', 'undefined' => 'unklar', 'unknown' => 'unklar', - 'status_device_unreachable' => 'gerät ist nicht in Reichweite', - 'status_device_alive' => 'gerät ist in Reichweite', + 'status_device_unreachable' => 'Gerät ist nicht in Reichweite', + 'status_device_alive' => 'Gerät ist in Reichweite', 'bad' => 'schlecht', 'poor' => 'schwach', 'good' => 'gut', 'undefined' => 'unklar', 'idle' => 'nichts zu tun', - 'firmware_cancel' => 'firmwareupload unterbrochen', - 'firmware_upload' => 'firmwareupload', + 'firmware_cancel' => 'Firmwareupload unterbrochen', + 'firmware_upload' => 'Firmwareupload', 'unsupported' => 'nicht unterstützt', 'up_to_date' => 'auf dem neusten Stand', - 'mower' => 'mäher', - 'watering_computer' => 'bewässerungscomputer', + 'mower' => 'Mäher', + 'watering_computer' => 'Bewässerungscomputer', 'no_frost' => 'kein Frost', 'open' => 'offen', 'closed' => 'geschlossen',