diff --git a/fhem/CHANGED b/fhem/CHANGED index 0c4cc274f..63c8ac9cd 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # 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. + - feature: 74_AutomowerConnect: add attr disabledForIntervals + - feature: 75_AutomowerConnectDevice: add attr disabledForIntervals - bugfix: 98_WeekdayTimer: !$we handling - new: 74_AutomowerConnect: Control Automower + Host - new: 75_AutomowerConnectDevice: Control Automower Client diff --git a/fhem/FHEM/74_AutomowerConnect.pm b/fhem/FHEM/74_AutomowerConnect.pm index cad0350c0..16f4d759d 100644 --- a/fhem/FHEM/74_AutomowerConnect.pm +++ b/fhem/FHEM/74_AutomowerConnect.pm @@ -1,4 +1,6 @@ ############################################################################### +# +# $Id$ # # This script is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,8 +18,6 @@ # GNU General Public License for more details. # # -# $Id$ -# # # Husqvarnas Open API is used # based on some ideas from HusqvarnaAutomower and BOTVAC module @@ -47,6 +47,7 @@ BEGIN { getKeyValue InternalTimer InternalVal + IsDisabled Log3 Log readingFnAttributes @@ -96,6 +97,7 @@ sub Initialize() { $hash->{AttrFn} = \&Attr; $hash->{AttrList} = "interval " . "disable:1,0 " . + "disabledForIntervals " . "mapImagePath " . "mapImageWidthHeight " . "mapImageCoordinatesToRegister:textField-long " . @@ -211,6 +213,9 @@ EOF $attr{$name}{room} = $type if( !defined( $attr{$name}{room} ) ); $attr{$name}{icon} = 'automower' if( !defined( $attr{$name}{icon} ) ); + if (::AnalyzeCommandChain(undef,"version 74_AutomowerConnect.pm noheader") =~ "^74_AutomowerConnect.pm (.*)Z") { + $hash->{VERSION}=$1; + } RemoveInternalTimer($hash); InternalTimer( gettimeofday() + 2, \&APIAuth, $hash, 1); @@ -235,11 +240,14 @@ sub APIAuth { my $name = $hash->{NAME}; my $type = $hash->{TYPE}; my $iam = "$type $name APIAuth:"; + my $interval = $hash->{helper}{interval}; + if ( IsDisabled($name) ) { - if ( AttrVal($name, 'disable', '') ) { + readingsSingleUpdate($hash,'state','disabled',1) if( ReadingsVal($name,'state','') ne 'disabled' ); + RemoveInternalTimer( $hash, \&APIAuth ); + InternalTimer( gettimeofday() + $interval, \&APIAuth, $hash, 0 ); - Log3 $name, 3, "$iam disabled"; - return undef + return undef; } @@ -252,6 +260,7 @@ sub APIAuth { } else { + readingsSingleUpdate( $hash, 'state', 'authentification', 1 ); my $client_id = $hash->{helper}->{client_id}; my $client_secret = $hash->{helper}->{passObj}->getReadPassword($name); my $grant_type = $hash->{helper}->{grant_type}; @@ -267,7 +276,6 @@ sub APIAuth { data => $data, callback => \&APIAuthResponse, }); - readingsSingleUpdate( $hash, 'state', 'authentification', 1 ); } } else { RemoveInternalTimer( $hash, \&APIAuth); @@ -347,12 +355,6 @@ sub getMower { my $name = $hash->{NAME}; my $type = $hash->{TYPE}; my $iam = "$type $name getMower:"; - - if ( AttrVal($name, 'disable', '') ) { - Log3 $name, 3, "$iam disabled"; - return undef - } - my $access_token = ReadingsVal($name,".access_token",""); my $provider = ReadingsVal($name,".provider",""); my $client_id = $hash->{helper}->{client_id}; @@ -545,7 +547,7 @@ sub sendCMD { my $type = $hash->{TYPE}; my $iam = "$type $name sendCMD:"; - if ( AttrVal($name, 'disable', '') ) { + if ( IsDisabled($name) ) { Log3 $name, 3, "$iam disabled"; return undef } @@ -675,7 +677,8 @@ sub Set { Log3 $name, 4, "$iam called with $setName " . ($setVal ? $setVal : "") if ($setName !~ /^(\?|client_secret)$/); - if ( $setName eq 'getUpdate' ) { + if ( !IsDisabled($name) && $setName eq 'getUpdate' ) { + RemoveInternalTimer($hash, \&APIAuth); APIAuth($hash); return undef; @@ -716,14 +719,14 @@ sub Set { return undef; } - } elsif ( $setName eq 'getNewAccessToken' ) { + } elsif ( !IsDisabled($name) && $setName eq 'getNewAccessToken' ) { if ( $setVal ) { - readingsBeginUpdate($hash); - readingsBulkUpdateIfChanged( $hash, '.access_token', '', 0 ); - readingsBulkUpdateIfChanged( $hash, 'state', 'initialized'); - readingsBulkUpdateIfChanged( $hash, 'mower_commandStatus', 'cleared'); - readingsEndUpdate($hash, 1); + readingsBeginUpdate($hash); + readingsBulkUpdateIfChanged( $hash, '.access_token', '', 0 ); + readingsBulkUpdateIfChanged( $hash, 'state', 'initialized'); + readingsBulkUpdateIfChanged( $hash, 'mower_commandStatus', 'cleared'); + readingsEndUpdate($hash, 1); RemoveInternalTimer($hash, \&APIAuth); APIAuth($hash); @@ -869,16 +872,10 @@ sub Attr { if( $attrName eq "disable" ) { if( $cmd eq "set" and $attrVal eq "1" ) { - RemoveInternalTimer( $hash ); - readingsSingleUpdate ( $hash, "state", "disabled", 1 ); Log3 $name, 3, "$iam $cmd $attrName disabled"; } elsif( $cmd eq "del" or $cmd eq 'set' and !$attrVal ) { - readingsSingleUpdate ( $hash, "state", "initialized", 1 ); - readMap( $hash ); - RemoveInternalTimer( $hash, \&APIAuth ); - InternalTimer( gettimeofday() + 2, \&APIAuth, $hash, 0 ); Log3 $name, 3, "$iam $cmd $attrName enabled"; } @@ -1269,7 +1266,8 @@ sub readMap {

AutomowerConnect


@@ -1701,6 +1704,9 @@ sub readMap { Longitude: (LongitudeMeter_1 - LongitudeMeter_2) / (LongitudeDegree_1 - LongitudeDegree _2)
Latitude: (LatitudeMeter_1 - LatitudeMeter_2) / (LatitudeDegree_1 - LatitudeDegree _2) +
  • disable
  • +
  • disabledForIntervals
  • +

  • attr <name> <>
    @@ -1712,10 +1718,10 @@ sub readMap { Readings