From 117ebca8bce6797c652738e3381bb6f4d6d80fc4 Mon Sep 17 00:00:00 2001
From: Marko Oldenburg <leongaultier@gmail.com>
Date: Wed, 9 Jan 2019 12:55:21 +0100
Subject: [PATCH] change data handle for callBackFn - wichtig alle Module
 Updaten

---
 59_Weather.pm        | 7 +++----
 DarkSkyAPI.pm        | 4 ++--
 OpenWeatherMapAPI.pm | 4 ++--
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/59_Weather.pm b/59_Weather.pm
index 80de882..e75ac28 100755
--- a/59_Weather.pm
+++ b/59_Weather.pm
@@ -336,8 +336,8 @@ sub Weather_ReturnWithError($$) {
 
 sub Weather_RetrieveCallbackFn($) {
 
-    my $hash = shift;
-    my $name = $hash->{NAME};
+    my $name = shift;
+    my $hash = $defs{$name};
     my $responseRef = $hash->{fhem}{api}->getWeather;
     
     if ( $responseRef->{status} eq 'ok' ) {
@@ -602,8 +602,7 @@ sub Weather_Define($$) {
   Weather_LanguageInitialize($hash->{LANG});
 
   my $apistring = $api . '::Weather';
-#   $hash->{fhem}{api} = $api . '::Weather'->new( { hash => $hash, apikey => $hash->{APIKEY}, location => $hash->{LOCATION}, cachemaxage => 600, language => $hash->{LANG} } );
-  $hash->{fhem}{api} = $apistring->new( { hash => $hash, apikey => $hash->{APIKEY}, location => $hash->{LOCATION}, cachemaxage => 600, language => $hash->{LANG} } );
+  $hash->{fhem}{api} = $apistring->new( { devName => $hash->{NAME}, apikey => $hash->{APIKEY}, location => $hash->{LOCATION}, cachemaxage => 600, language => $hash->{LANG} } );
   
   Weather_GetUpdate($hash) if($init_done);
 
diff --git a/DarkSkyAPI.pm b/DarkSkyAPI.pm
index 9b5e620..8473dec 100644
--- a/DarkSkyAPI.pm
+++ b/DarkSkyAPI.pm
@@ -66,7 +66,7 @@ sub new {
     my ( $class, $argsRef ) = @_;
 
     my $self = {
-        devHash => $argsRef->{hash},
+        devName => $argsRef->{devName},
         key => ( defined( $argsRef->{apikey} ) ? $argsRef->{apikey} : 'none' ),
         cachemaxage => $argsRef->{cachemaxage},
         lang        => $argsRef->{language},
@@ -437,7 +437,7 @@ sub _CallWeatherCallbackFn($) {
     my $self = shift;
 
     #     ## Aufruf der callbackFn
-    main::Weather_RetrieveCallbackFn( $self->{devHash} );
+    main::Weather_RetrieveCallbackFn( $self->{devName} );
 }
 
 sub _ErrorHandling($$) {
diff --git a/OpenWeatherMapAPI.pm b/OpenWeatherMapAPI.pm
index 39f8f68..dc95e6f 100644
--- a/OpenWeatherMapAPI.pm
+++ b/OpenWeatherMapAPI.pm
@@ -89,7 +89,7 @@ sub new {
     my ( $class, $argsRef ) = @_;
 
     my $self = {
-        devHash => $argsRef->{hash},
+        devName     => $argsRef->{devName},
         key => ( defined( $argsRef->{apikey} ) ? $argsRef->{apikey} : 'none' ),
         cachemaxage => $argsRef->{cachemaxage},
         lang        => $argsRef->{language},
@@ -286,7 +286,7 @@ sub _CallWeatherCallbackFn($) {
     my $self = shift;
 
     #     ## Aufruf der callbackFn
-    main::Weather_RetrieveCallbackFn( $self->{devHash} );
+    main::Weather_RetrieveCallbackFn( $self->{devName} );
 }
 
 sub _ErrorHandling($$) {