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
- FHEM-FORUM: AutomowerConnect und AutomowerConnectDevice
+ FHEM-FORUM: AutomowerConnect und AutomowerConnectDevice
+ FHEM-Wiki: AutomowerConnect und AutomowerConnectDevice: Wie erstellt man eine Karte des Mähbereiches?
Introduction
@@ -1288,6 +1286,7 @@ sub readMap {
- Max 1 request per second and application key.
- Max 10 000 request per month and application key.
+ - 'There is a timeout of 10 minutes in the mower to preserve data traffic and save battery...'
- This results in a recommended interval of 600 seconds.
Requirements
@@ -1304,7 +1303,7 @@ sub readMap {
define <device name> AutomowerConnect <application key> [<mower number>]
Example:
define myMower AutomowerConnect 123456789012345678901234567890123456
First device: the default mower number is 0.
- It has to be set a client_secret. It's the application secret from the Husqvarna Developer Portal.
+ It has to be set a client_secret. It's the application secret from the Husqvarna Developer Portal.
set myMower <client secret>
Additional mower devices
@@ -1361,7 +1360,8 @@ sub readMap {
set <name> sendScheduleFromAttributeToMower
Sends the schedule to the mower. NOTE: Do not use for 550 EPOS and Ceora.
-
+
+
set <name>
@@ -1449,6 +1449,8 @@ sub readMap {
Longitude: (LongitudeMeter_1 - LongitudeMeter_2) / (LongitudeDegree_1 - LongitudeDegree _2)
Latitude: (LatitudeMeter_1 - LatitudeMeter_2) / (LatitudeDegree_1 - LatitudeDegree _2)
+ - disable
+ - disabledForIntervals
@@ -1463,7 +1465,7 @@ sub readMap {
- api_MowerFound - all mower registered under the application key (client_id)
- api_token_expires - date when session of Husqvarna Cloud expires
- api_access_token - current session token (shortend) of Husqvarna Cloud
- - batteryPercent - Battery power in percent
+ - batteryPercent - battery state of charge in percent
- mower_activity - current activity "UNKNOWN" | "NOT_APPLICABLE" | "MOWING" | "GOING_HOME" | "CHARGING" | "LEAVING" | "PARKED_IN_CS" | "STOPPED_IN_GARDEN"
- mower_commandStatus - Status of the last sent command cleared each status update
- mower_errorCode - last error code
@@ -1538,6 +1540,7 @@ sub readMap {
- Maximal 1 Request pro Sekunde und Application Key.
- Maximal 10 000 Requests pro Monat und Application Key.
+ - 'Der Mäher sendet seine Daten nur alle 10 Minuten, um den Datenverkehr zu begrenzen und Batterie zu sparen...'
- Daraus ergibt sich ein empfohlenes Abfrageinterval von 600 Sekunden
Anforderungen
@@ -1554,13 +1557,13 @@ sub readMap {
define <device name> AutomowerConnect <application key> [<mower number>]
Beispiel:
define myMower AutomowerConnect 123456789012345678901234567890123456
Erstes Gerät: die Defaultmähernummer ist 0.
- Es muss ein client_secret gesetzt werden. Es ist das Application Secret vom Husqvarna Developer Portal.
+ Es muss ein client_secret gesetzt werden. Es ist das Application Secret vom Husqvarna Developer Portal.
set myMower <client secret>
Zusätzlicher Mähroboter
define <device name> AutomowerConnectDevice <host name> <mower number>
Beispiel:
- define myAdditionalMower AutomowerConnectDevice MyMower 1
Zweites Gerät mit Hostname myMower und Mähernumme 1
+ define myAdditionalMower AutomowerConnectDevice MyMower 1
Zweites Gerät mit Hostname myMower und Mähernummer 1
@@ -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
- - api_MowerFound - Alle Mährobuter, die unter dem genutzten Application Key (client_id) registriert sind.
+ - api_MowerFound - Alle Mähroboter, die unter dem genutzten Application Key (client_id) registriert sind.
- api_token_expires - Datum wann die Session der Husqvarna Cloud abläuft
- api_access_token - aktueller Sitzungstoken (gekürzt) für die Husqvarna Cloud
- - batteryPercent - Batteryladung in Prozent
+ - batteryPercent - Batterieladung in Prozent
- mower_activity - aktuelle Aktivität "UNKNOWN" | "NOT_APPLICABLE" | "MOWING" | "GOING_HOME" | "CHARGING" | "LEAVING" | "PARKED_IN_CS" | "STOPPED_IN_GARDEN"
- mower_commandStatus - Status des letzten uebermittelten Kommandos wird duch Statusupdate zurückgesetzt.
- mower_errorCode - last error code
diff --git a/fhem/FHEM/75_AutomowerConnectDevice.pm b/fhem/FHEM/75_AutomowerConnectDevice.pm
index e231e4227..6a7975cee 100644
--- a/fhem/FHEM/75_AutomowerConnectDevice.pm
+++ b/fhem/FHEM/75_AutomowerConnectDevice.pm
@@ -44,6 +44,7 @@ BEGIN {
getKeyValue
InternalTimer
InternalVal
+ IsDisabled
Log3
readingFnAttributes
readingsBeginUpdate
@@ -92,6 +93,7 @@ sub Initialize() {
$hash->{FW_detailFn}= \&FW_detailFn;
$hash->{AttrFn} = \&Attr;
$hash->{AttrList} = "disable:1,0 " .
+ "disabledForIntervals " .
"mapImagePath " .
"mapImageWidthHeight " .
"mapImageCoordinatesToRegister:textField-long " .
@@ -200,6 +202,9 @@ EOF
$attr{$name}{room} = $type if( !defined( $attr{$name}{room} ) );
$attr{$name}{icon} = 'automower' if( !defined( $attr{$name}{icon} ) );
+ if (::AnalyzeCommandChain(undef,"version 75_AutomowerConnectDevice.pm noheader") =~ "^75_AutomowerConnectDevice.pm (.*)Z") {
+ $hash->{VERSION}=$1;
+ }
RemoveInternalTimer($hash);
InternalTimer( gettimeofday() + 25, \&readMap, $hash, 0);
@@ -229,6 +234,12 @@ sub Notify {
my $mowerNumber = $hash->{helper}{mowerNumber};
my $events = ::deviceEvents($hosthash,1);
+ if ( IsDisabled($name) ) {
+
+ return undef
+
+ }
+
if(grep /^state:.connected$/, @{$events}) {
my $maxMower = @{$hosthash->{helper}{mowers}};
@@ -363,7 +374,13 @@ sub CMD {
my $hostname = $hash->{helper}{hostname};
my $hosthash = $defs{$hostname};
- if ( AttrVal($name, 'disable', '') ) {
+ if ( IsDisabled($hostname) ) {
+
+ Log3 $name, 3, "$iam Host $hostname disabled";
+ return undef
+
+ }
+ if ( IsDisabled($name) ) {
Log3 $name, 3, "$iam disabled";
return undef
@@ -500,7 +517,7 @@ sub Set {
return undef;
################
- } elsif ( ReadingsVal( $name, 'state', 'defined' ) !~ /defined/ && $setName eq 'mowerScheduleToAttribute' ) {
+ } elsif ( ReadingsVal( $name, 'state', 'defined' ) !~ /defined|initialized/ && $setName eq 'mowerScheduleToAttribute' ) {
my $calendarjson = JSON::XS->new->pretty(1)->encode ($hash->{helper}{mower}{attributes}{calendar}{tasks});
if ( $@ ) {
@@ -510,21 +527,21 @@ sub Set {
return undef;
################
- } elsif ( ReadingsVal( $name, 'state', 'defined' ) !~ /defined/ && $setName =~ /^(Start|Park|cuttingHeight)$/ ) {
+ } elsif ( ReadingsVal( $name, 'state', 'defined' ) !~ /defined|initialized/ && $setName =~ /^(Start|Park|cuttingHeight)$/ ) {
if ( $setVal =~ /^(\d+)$/) {
CMD($hash ,$setName, $setVal);
return undef;
}
################
- } elsif ( ReadingsVal( $name, 'state', 'defined' ) !~ /defined|/ && $setName eq 'headlight' ) {
+ } elsif ( ReadingsVal( $name, 'state', 'defined' ) !~ /defined|initialized/ && $setName eq 'headlight' ) {
if ( $setVal =~ /^(ALWAYS_OFF|ALWAYS_ON|EVENING_ONLY|EVENING_AND_NIGHT)$/) {
CMD($hash ,$setName, $setVal);
return undef;
}
################
- } elsif (ReadingsVal( $name, 'state', 'defined' ) !~ /defined/ && $setName =~ /ParkUntilFurtherNotice|ParkUntilNextSchedule|Pause|ResumeSchedule|sendScheduleFromAttributeToMower/) {
+ } elsif (ReadingsVal( $name, 'state', 'defined' ) !~ /defined|initialized/ && $setName =~ /ParkUntilFurtherNotice|ParkUntilNextSchedule|Pause|ResumeSchedule|sendScheduleFromAttributeToMower/) {
CMD($hash,$setName);
return undef;
}
@@ -540,7 +557,7 @@ sub FW_detailFn {
my ($FW_wname, $name, $room, $pageHash) = @_; # pageHash is set for summaryFn.
my $hash = $defs{$name};
my $type = $hash->{TYPE};
- return undef if( AttrVal($name, 'disable', 0) || !AttrVal($name, 'showMap', 1) );
+ return undef if( IsDisabled($name) || !AttrVal($name, 'showMap', 1) );
if ( $hash->{helper} && $hash->{helper}{mower} && $hash->{helper}{mower}{attributes} && $hash->{helper}{mower}{attributes}{positions} && @{$hash->{helper}{mower}{attributes}{positions}} > 0 ) {
my $img = "./fhem/$type/$name/map";
my $zoom=AttrVal($name,"mapImageZoom",0.7);
@@ -1024,7 +1041,8 @@ sub readMap {
AutomowerConnectDevice
+ disable
+ disabledForIntervals
+
attr <name> <>
@@ -1188,7 +1209,7 @@ sub readMap {
Readings
- - batteryPercent - Battery power in percent
+ - batteryPercent - battery state of charge in percent
- mower_activity - current activity "UNKNOWN" | "NOT_APPLICABLE" | "MOWING" | "GOING_HOME" | "CHARGING" | "LEAVING" | "PARKED_IN_CS" | "STOPPED_IN_GARDEN"
- mower_commandStatus - Status of the last sent command cleared each status update
- mower_errorCode - last error code
@@ -1263,7 +1284,7 @@ sub readMap {
Anforderungen
- - Es wird eine aktive Instanz (Device, FHEM-Gerät) des Moduls AutomowerConnect vorausgesetzt, die mit einem Application Key läuft unter dem mindestens zwei Husqvarna Automower registriert sind..
+ - Es wird eine aktive Instanz (Device, FHEM-Gerät) des Moduls AutomowerConnect vorausgesetzt..
- Readings und der Status connected wird erst angezeigt, wenn in dem Hostgerät ein Update erfolgt ist..
@@ -1405,6 +1426,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> <>
@@ -1416,7 +1440,7 @@ sub readMap {
Readings
- - batteryPercent - Batteryladung in Prozent (ohne %-Zeichen)
+ - batteryPercent - Batterieladung in Prozent
- mower_activity - aktuelle Aktivität "UNKNOWN" | "NOT_APPLICABLE" | "MOWING" | "GOING_HOME" | "CHARGING" | "LEAVING" | "PARKED_IN_CS" | "STOPPED_IN_GARDEN"
- mower_commandStatus - Status des letzten uebermittelten Kommandos wird duch Statusupdate zurückgesetzt.
- mower_errorCode - last error code