fixed init error
This commit is contained in:
parent
eb39c00f49
commit
0ca85f25d4
|
@ -91,11 +91,7 @@ sub TadoAPI_Init($$)
|
|||
{
|
||||
my ($hash,$args) = @_;
|
||||
my $u = "wrong syntax: define <name> TadoAPI <username> <homeID> [<mobileID>]";
|
||||
|
||||
return $u if(int(@$args) < 2);
|
||||
|
||||
#TadoAPI_Connect($hash) if($init_done);
|
||||
|
||||
return $u if(int(@$args) < 2);
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
@ -120,25 +116,24 @@ sub TadoAPI_Define($$)
|
|||
$hash->{TADO_USER} = $user;
|
||||
|
||||
if ( defined($homeID) && $homeID ne "" ) {
|
||||
$attr{$name}{"homeID"} = $homeID;
|
||||
$attr{$name}{homeID} = $homeID;
|
||||
}
|
||||
|
||||
if ( defined($mobileID) && $mobileID ne "" ) {
|
||||
$attr{$name}{"mobileID"} = $mobileID;
|
||||
$main::attr{$a[0]}{"mobileID"}= $mobileID;
|
||||
}
|
||||
|
||||
my @args = ($homeID, $mobileID);
|
||||
|
||||
if ($main::init_done) {
|
||||
|
||||
$main::attr{$a[0]}{"homeID"}= $homeID;
|
||||
$main::attr{$a[0]}{"mobileID"}= $mobileID;
|
||||
# do something?
|
||||
|
||||
return TadoAPI_Catch($@) if $@;
|
||||
}
|
||||
|
||||
# start the status update timer
|
||||
TadoAPI_Update($hash);
|
||||
RemoveInternalTimer($hash);
|
||||
InternalTimer( gettimeofday() + 10, "TadoAPI_Update", $hash, 0 );
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
@ -349,9 +344,9 @@ sub TadoAPI_callback($$$){
|
|||
if($param->{code} == 401 || $param->{code} == 400){
|
||||
$apiStatus = 1;
|
||||
readingsBeginUpdate($hash);
|
||||
readingsBulkUpdate($hash, "API-Status", "online");
|
||||
readingsBulkUpdate($hash, "API-Status", "reachable");
|
||||
readingsEndUpdate( $hash, 1 );
|
||||
Log3 $name, 3, "TadoAPI $name" . ": " . "API is online. Callback Status: " . $param->{code} if $debug;
|
||||
Log3 $name, 3, "TadoAPI $name" . ": " . "API is reachable. Callback Status: " . $param->{code} if $debug;
|
||||
|
||||
}else{
|
||||
$apiStatus = 0;
|
||||
|
@ -460,7 +455,7 @@ sub TadoAPI_requestNewToken(@) {
|
|||
|
||||
#return to apistatus
|
||||
readingsBeginUpdate($hash);
|
||||
readingsBulkUpdate($hash, "API-Status", "online");
|
||||
readingsBulkUpdate($hash, "API-Status", "reachable");
|
||||
readingsEndUpdate( $hash, 1 );
|
||||
return 1;
|
||||
}else{
|
||||
|
@ -548,8 +543,6 @@ sub TadoAPI_Update(@){
|
|||
return undef;
|
||||
}
|
||||
|
||||
|
||||
|
||||
######################## tado methods ########################
|
||||
##############################################################
|
||||
sub TadoAPI_GetUpdate(@){
|
||||
|
|
Loading…
Reference in New Issue