applied patch up to WriteToCloud
This commit is contained in:
parent
ff79d0c662
commit
fc6e74dd3c
@ -1,5 +1,6 @@
|
|||||||
package FHEM::EaseeWallbox;
|
package FHEM::EaseeWallbox;
|
||||||
use GPUtils qw(GP_Import GP_Export);
|
|
||||||
|
# use GPUtils qw(GP_Import GP_Export); hast Du auch weiter unten stehen
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
@ -69,7 +70,9 @@ eval {
|
|||||||
# Import von Funktionen und/oder Variablen aus der FHEM main
|
# Import von Funktionen und/oder Variablen aus der FHEM main
|
||||||
# man kann ::Funktionaname wählen und sich so den Import schenken. Variablen sollten aber
|
# man kann ::Funktionaname wählen und sich so den Import schenken. Variablen sollten aber
|
||||||
# sauber importiert werden
|
# sauber importiert werden
|
||||||
use GPUtils qw(GP_Import);
|
# use GPUtils qw(GP_Import);
|
||||||
|
use GPUtils qw(GP_Import GP_Export)
|
||||||
|
; # da Du beide Funktionen aus dem package verwendest
|
||||||
|
|
||||||
## Import der FHEM Funktionen
|
## Import der FHEM Funktionen
|
||||||
#-- Run before package compilation
|
#-- Run before package compilation
|
||||||
@ -104,18 +107,17 @@ GP_Export(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
my %gets = (
|
my %gets = (
|
||||||
update => "noArg",
|
update => "noArg",
|
||||||
health => "noArg",
|
health => "noArg",
|
||||||
charger => "noArg",
|
charger => "noArg",
|
||||||
);
|
);
|
||||||
|
|
||||||
my %sets = (
|
my %sets = (
|
||||||
enabled => "",
|
enabled => "",
|
||||||
disabled => "",
|
disabled => "",
|
||||||
enableSmartButton => "true,false",
|
enableSmartButton => "true,false",
|
||||||
authorizationRequired => "true,false",
|
authorizationRequired => "true,false",
|
||||||
startCharging => "",
|
startCharging => "",
|
||||||
stopCharging => "",
|
stopCharging => "",
|
||||||
pauseCharging => "",
|
pauseCharging => "",
|
||||||
@ -135,7 +137,6 @@ my %sets = (
|
|||||||
deactivateTimer => "",
|
deactivateTimer => "",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
## Datapoint, all behind API URI
|
## Datapoint, all behind API URI
|
||||||
my %dpoints = (
|
my %dpoints = (
|
||||||
getOAuthToken => 'accounts/login',
|
getOAuthToken => 'accounts/login',
|
||||||
@ -153,17 +154,19 @@ my %dpoints = (
|
|||||||
getCurrentSession => 'chargers/#ChargerID#/sessions/ongoing',
|
getCurrentSession => 'chargers/#ChargerID#/sessions/ongoing',
|
||||||
setCableLockState => 'chargers/#ChargerID#/commands/lock_state',
|
setCableLockState => 'chargers/#ChargerID#/commands/lock_state',
|
||||||
setReboot => 'chargers/#ChargerID#/commands/reboot',
|
setReboot => 'chargers/#ChargerID#/commands/reboot',
|
||||||
setUpdateFirmware => 'chargers/#ChargerID#/commands/update_firmware',
|
setUpdateFirmware => 'chargers/#ChargerID#/commands/update_firmware',
|
||||||
setEnableSmartCharging => 'chargers/#ChargerID#/commands/smart_charging',
|
setEnableSmartCharging => 'chargers/#ChargerID#/commands/smart_charging',
|
||||||
setStartCharging => 'chargers/#ChargerID#/commands/start_charging',
|
setStartCharging => 'chargers/#ChargerID#/commands/start_charging',
|
||||||
setStopCharging => 'chargers/#ChargerID#/commands/stop_charging',
|
setStopCharging => 'chargers/#ChargerID#/commands/stop_charging',
|
||||||
setPauseCharging => 'chargers/#ChargerID#/commands/pause_charging',
|
setPauseCharging => 'chargers/#ChargerID#/commands/pause_charging',
|
||||||
setResumeCharging => 'chargers/#ChargerID#/commands/resume_charging',
|
setResumeCharging => 'chargers/#ChargerID#/commands/resume_charging',
|
||||||
setToggleCharging => 'chargers/#ChargerID#/commands/toggle_charging',
|
setToggleCharging => 'chargers/#ChargerID#/commands/toggle_charging',
|
||||||
setOverrideChargingSchedule => 'chargers/#ChargerID#/commands/override_schedule',
|
setOverrideChargingSchedule =>
|
||||||
setPairRFIDTag => 'chargers/#ChargerID#/commands/set_rfid_pairing_mode_async',
|
'chargers/#ChargerID#/commands/override_schedule',
|
||||||
changeChargerSettings => 'chargers/#ChargerID#/settings',
|
setPairRFIDTag =>
|
||||||
setChargingPrice => 'sites/#SiteID#/price',
|
'chargers/#ChargerID#/commands/set_rfid_pairing_mode_async',
|
||||||
|
changeChargerSettings => 'chargers/#ChargerID#/settings',
|
||||||
|
setChargingPrice => 'sites/#SiteID#/price',
|
||||||
);
|
);
|
||||||
my %reasonsForNoCurrent = (
|
my %reasonsForNoCurrent = (
|
||||||
0 => 'OK', #charger is allocated current
|
0 => 'OK', #charger is allocated current
|
||||||
@ -174,8 +177,8 @@ my %reasonsForNoCurrent = (
|
|||||||
5 => 'WaitingInQueue',
|
5 => 'WaitingInQueue',
|
||||||
6 => 'WaitingInFully'
|
6 => 'WaitingInFully'
|
||||||
, #charged queue (charger assumes one of: EV uses delayed charging, EV charging complete)
|
, #charged queue (charger assumes one of: EV uses delayed charging, EV charging complete)
|
||||||
7 => 'IllegalGridType',
|
7 => 'IllegalGridType',
|
||||||
8 => 'PrimaryUnitHasNotReceivedCurrentRequestFromSecondaryUnit',
|
8 => 'PrimaryUnitHasNotReceivedCurrentRequestFromSecondaryUnit',
|
||||||
50 => 'SecondaryUnitNotRequestingCurrent', #no car connected...
|
50 => 'SecondaryUnitNotRequestingCurrent', #no car connected...
|
||||||
51 => 'MaxChargerCurrentTooLow',
|
51 => 'MaxChargerCurrentTooLow',
|
||||||
52 => 'MaxDynamicChargerCurrentTooLow',
|
52 => 'MaxDynamicChargerCurrentTooLow',
|
||||||
@ -201,32 +204,31 @@ my %operationModes = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
my %commandCodes = (
|
my %commandCodes = (
|
||||||
1 => "Reboot",
|
1 => "Reboot",
|
||||||
2 => "Poll single observation",
|
2 => "Poll single observation",
|
||||||
3 => "Poll all observations",
|
3 => "Poll all observations",
|
||||||
4 => "Upgrade Firmware",
|
4 => "Upgrade Firmware",
|
||||||
5 => "Download settings",
|
5 => "Download settings",
|
||||||
7 => "Scan Wifi",
|
7 => "Scan Wifi",
|
||||||
11 => "Set smart charging",
|
11 => "Set smart charging",
|
||||||
23 => "Abort charging",
|
23 => "Abort charging",
|
||||||
25 => "Start Charging",
|
25 => "Start Charging",
|
||||||
26 => "Stop Charging",
|
26 => "Stop Charging",
|
||||||
29 => "Set enabled",
|
29 => "Set enabled",
|
||||||
30 => "Set cable lock",
|
30 => "Set cable lock",
|
||||||
11 => "Set smart charging",
|
11 => "Set smart charging",
|
||||||
40 => "Set lightstripe brightness",
|
40 => "Set lightstripe brightness",
|
||||||
43 => "Add keys",
|
43 => "Add keys",
|
||||||
44 => "Clear keys",
|
44 => "Clear keys",
|
||||||
48 => "Pause/Resume/Toggle Charging",
|
48 => "Pause/Resume/Toggle Charging",
|
||||||
60 => "Add schedule",
|
60 => "Add schedule",
|
||||||
61 => "Cear Schedule",
|
61 => "Cear Schedule",
|
||||||
62 => "Get Schedule",
|
62 => "Get Schedule",
|
||||||
63 => "Override Schedule",
|
63 => "Override Schedule",
|
||||||
64 => "Purge Schedule",
|
64 => "Purge Schedule",
|
||||||
69 => "Set RFID Pairing Mode",
|
69 => "Set RFID Pairing Mode",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
#Private function to evaluate command-lists
|
#Private function to evaluate command-lists
|
||||||
# private funktionen beginnen immer mit _
|
# private funktionen beginnen immer mit _
|
||||||
|
|
||||||
@ -238,14 +240,16 @@ sub _GetCmdList {
|
|||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
#return, if cmd is valid
|
#return, if cmd is valid
|
||||||
return undef if ( defined($cmd) and defined( $cmdArray{$cmd} ) );
|
return if ( defined($cmd) and defined( $cmdArray{$cmd} ) );
|
||||||
|
|
||||||
#response for gui or the user, if command is invalid
|
#response for gui or the user, if command is invalid
|
||||||
my $retVal;
|
my $retVal;
|
||||||
foreach my $mySet ( keys %cmdArray ) {
|
foreach my $mySet ( keys %cmdArray ) {
|
||||||
|
|
||||||
#append set-command
|
#append set-command
|
||||||
$retVal = $retVal . " " if ( defined($retVal) );
|
$retVal = $retVal . " "
|
||||||
|
if ( defined($retVal) )
|
||||||
|
; # Macht denke ich keinen Sinn da durch my $retVal bereits $retVal definiert ist
|
||||||
$retVal = $retVal . $mySet;
|
$retVal = $retVal . $mySet;
|
||||||
|
|
||||||
#get options
|
#get options
|
||||||
@ -253,18 +257,21 @@ sub _GetCmdList {
|
|||||||
|
|
||||||
#append option, if valid
|
#append option, if valid
|
||||||
$retVal = $retVal . ":" . $myOpt
|
$retVal = $retVal . ":" . $myOpt
|
||||||
if ( defined($myOpt) and ( length($myOpt) > 0 ) );
|
if ( defined($myOpt) and ( length($myOpt) > 0 ) );
|
||||||
$myOpt = "" if ( !defined($myOpt) );
|
$myOpt = "" if ( !defined($myOpt) );
|
||||||
|
|
||||||
#Log3 ($name, 5, "parse cmd-table - Set:$mySet, Option:$myOpt, RetVal:$retVal");
|
#Log3 ($name, 5, "parse cmd-table - Set:$mySet, Option:$myOpt, RetVal:$retVal");
|
||||||
}
|
}
|
||||||
if ( !defined($retVal) ) {
|
if ( !defined($retVal) ) {
|
||||||
$retVal = "error while parsing set-table";
|
return "error while parsing set-table";
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$retVal = "Unknown argument $cmd, choose one of " . $retVal;
|
return "Unknown argument $cmd, choose one of " . $retVal;
|
||||||
}
|
|
||||||
return $retVal;
|
# versuche wo wenig wie möglich if else zu verwenden.
|
||||||
|
# else {
|
||||||
|
# $retVal = "Unknown argument $cmd, choose one of " . $retVal;
|
||||||
|
# }
|
||||||
}
|
}
|
||||||
|
|
||||||
sub Initialize {
|
sub Initialize {
|
||||||
@ -285,7 +292,7 @@ sub Initialize {
|
|||||||
. $readingFnAttributes;
|
. $readingFnAttributes;
|
||||||
|
|
||||||
#Log3, 'EaseeWallbox', 3, "EaseeWallbox module initialized.";
|
#Log3, 'EaseeWallbox', 3, "EaseeWallbox module initialized.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub Define {
|
sub Define {
|
||||||
@ -300,22 +307,23 @@ sub Define {
|
|||||||
|
|
||||||
my $errmsg = '';
|
my $errmsg = '';
|
||||||
|
|
||||||
# Check parameter(s) - Must be min 4 in total (counts strings not purly parameter, interval is optional)
|
# Check parameter(s) - Must be min 4 in total (counts strings not purly parameter, interval is optional)
|
||||||
if ( int(@param) < 4 ) {
|
if ( int(@param) < 4 ) {
|
||||||
$errmsg = return
|
$errmsg = return
|
||||||
"syntax error: define <name> EaseeWallbox <username> <password> [Interval]";
|
"syntax error: define <name> EaseeWallbox <username> <password> [Interval]";
|
||||||
Log3 $name, 1, "EaseeWallbox $name: " . $errmsg;
|
Log3 $name, 1, "EaseeWallbox $name: " . $errmsg;
|
||||||
return $errmsg;
|
return $errmsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
#Check if the username is an email address
|
#Check if the username is an email address
|
||||||
if ( $param[2] =~ /^.+@.+$/ ) {
|
if ( $param[2] =~ /^.+@.+$/x )
|
||||||
|
{ # Regular expression without "/x" flag. See page 236 of PBP (RegularExpressions::RequireExtendedFormatting)
|
||||||
my $username = $param[2];
|
my $username = $param[2];
|
||||||
$hash->{Username} = $username;
|
$hash->{Username} = $username;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$errmsg
|
$errmsg =
|
||||||
= "specify valid email address within the field username. Format: define <name> EaseeWallbox <username> <password> [interval]";
|
"specify valid email address within the field username. Format: define <name> EaseeWallbox <username> <password> [interval]";
|
||||||
Log3 $name, 1, "EaseeWallbox $name: " . $errmsg;
|
Log3 $name, 1, "EaseeWallbox $name: " . $errmsg;
|
||||||
return $errmsg;
|
return $errmsg;
|
||||||
}
|
}
|
||||||
@ -342,12 +350,13 @@ sub Define {
|
|||||||
#If not an integer abort with failure.
|
#If not an integer abort with failure.
|
||||||
my $interval = 60;
|
my $interval = 60;
|
||||||
if ( defined $param[4] ) {
|
if ( defined $param[4] ) {
|
||||||
if ( $param[4] =~ /^\d+$/ ) {
|
if ( $param[4] =~ /^\d+$/x )
|
||||||
|
{ # Regular expression without "/x" flag. See page 236 of PBP (RegularExpressions::RequireExtendedFormatting)
|
||||||
$interval = $param[4];
|
$interval = $param[4];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$errmsg
|
$errmsg =
|
||||||
= "Specify valid integer value for interval. Whole numbers > 5 only. Format: define <name> EaseeWallbox <username> <password> [interval]";
|
"Specify valid integer value for interval. Whole numbers > 5 only. Format: define <name> EaseeWallbox <username> <password> [interval]";
|
||||||
Log3 $name, 1, "EaseeWallbox $name: " . $errmsg;
|
Log3 $name, 1, "EaseeWallbox $name: " . $errmsg;
|
||||||
return $errmsg;
|
return $errmsg;
|
||||||
}
|
}
|
||||||
@ -359,25 +368,31 @@ sub Define {
|
|||||||
readingsSingleUpdate( $hash, 'state', 'Undefined', 0 );
|
readingsSingleUpdate( $hash, 'state', 'Undefined', 0 );
|
||||||
|
|
||||||
#Initial load of data
|
#Initial load of data
|
||||||
WriteToCloudAPI($hash, 'getChargers', 'GET');
|
WriteToCloudAPI( $hash, 'getChargers', 'GET' );
|
||||||
|
|
||||||
Log3 $name, 1, sprintf("EaseeWallbox_Define %s: Starting timer with interval %s", $name, InternalVal($name,'INTERVAL', undef));
|
Log3 $name, 1,
|
||||||
InternalTimer(gettimeofday()+ InternalVal($name,'INTERVAL', undef), "FHEM::EaseeWallbox::UpdateDueToTimer", $hash) if (defined $hash);
|
sprintf( "EaseeWallbox_Define %s: Starting timer with interval %s",
|
||||||
return undef;
|
$name, InternalVal( $name, 'INTERVAL', undef ) );
|
||||||
|
InternalTimer( gettimeofday() + InternalVal( $name, 'INTERVAL', undef ),
|
||||||
|
"FHEM::EaseeWallbox::UpdateDueToTimer", $hash )
|
||||||
|
if ( defined $hash );
|
||||||
|
|
||||||
|
## return; sollte es nicht geben, ein return; ist per see mit Rückgabe undef
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub Undef {
|
sub Undef {
|
||||||
my ( $hash, $arg ) = @_;
|
my ( $hash, $arg ) = @_;
|
||||||
|
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
return undef;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub Get {
|
sub Get {
|
||||||
my ( $hash, $name, @args ) = @_;
|
my ( $hash, $name, @args ) = @_;
|
||||||
|
|
||||||
return '"get EaseeWallbox" needs at least one argument'
|
return '"get EaseeWallbox" needs at least one argument'
|
||||||
if ( int(@args) < 1 );
|
if ( int(@args) < 1 );
|
||||||
|
|
||||||
my $opt = shift @args;
|
my $opt = shift @args;
|
||||||
|
|
||||||
@ -386,10 +401,10 @@ sub Get {
|
|||||||
return $cmdTemp if ( defined($cmdTemp) );
|
return $cmdTemp if ( defined($cmdTemp) );
|
||||||
|
|
||||||
$hash->{LOCAL} = 1;
|
$hash->{LOCAL} = 1;
|
||||||
WriteToCloudAPI($hash, 'getChargers', 'GET') if $opt eq "charger";
|
WriteToCloudAPI( $hash, 'getChargers', 'GET' ) if $opt eq "charger";
|
||||||
RefreshData($hash) if $opt eq "update";
|
RefreshData($hash) if $opt eq "update";
|
||||||
delete $hash->{LOCAL};
|
delete $hash->{LOCAL};
|
||||||
return undef;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub Set {
|
sub Set {
|
||||||
@ -397,31 +412,40 @@ sub Set {
|
|||||||
|
|
||||||
return '"set $name" needs at least one argument' if ( int(@param) < 1 );
|
return '"set $name" needs at least one argument' if ( int(@param) < 1 );
|
||||||
|
|
||||||
my $opt = shift @param;
|
my $opt = shift @param;
|
||||||
my $value = join( "", @param );
|
my $value = join( "", @param );
|
||||||
|
my %message;
|
||||||
|
|
||||||
#create response, if cmd is wrong or gui asks
|
#create response, if cmd is wrong or gui asks
|
||||||
my $cmdTemp = _GetCmdList( $hash, $opt, \%sets );
|
my $cmdTemp = _GetCmdList( $hash, $opt, \%sets );
|
||||||
return $cmdTemp if ( defined($cmdTemp) );
|
return $cmdTemp if ( defined($cmdTemp) );
|
||||||
|
|
||||||
if ( $opt eq "deactivateTimer" ) {
|
if ( $opt eq "deactivateTimer" ) {
|
||||||
|
|
||||||
|
# Cascading if-elsif chain. See pages 117,118 of PBP (ControlStructures::ProhibitCascadingIfElse) kann man anders machen. Später machen wir das
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
Log3 $name, 1,
|
Log3 $name, 1,
|
||||||
"EaseeWallbox_Set $name: Stopped the timer to automatically update readings";
|
"EaseeWallbox_Set $name: Stopped the timer to automatically update readings";
|
||||||
readingsSingleUpdate( $hash, 'state', 'Initialized', 0 );
|
readingsSingleUpdate( $hash, 'state', 'Initialized', 0 );
|
||||||
return undef;
|
return;
|
||||||
}
|
}
|
||||||
elsif ( $opt eq "activateTimer" ) {
|
elsif ( $opt eq "activateTimer" ) {
|
||||||
|
|
||||||
#Update once manually and then start the timer
|
#Update once manually and then start the timer
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
$hash->{LOCAL} = 1;
|
$hash->{LOCAL} = 1;
|
||||||
RefreshData($hash);
|
RefreshData($hash);
|
||||||
delete $hash->{LOCAL};
|
delete $hash->{LOCAL};
|
||||||
InternalTimer(gettimeofday()+ InternalVal($name,'INTERVAL', undef), "FHEM::EaseeWallbox::UpdateDueToTimer", $hash);
|
InternalTimer( gettimeofday() + InternalVal( $name, 'INTERVAL', undef ),
|
||||||
readingsSingleUpdate($hash,'state','Started',0);
|
"FHEM::EaseeWallbox::UpdateDueToTimer", $hash );
|
||||||
Log3 $name, 1, sprintf("EaseeWallbox_Set %s: Updated readings and started timer to automatically update readings with interval %s", $name, InternalVal($name,'INTERVAL', undef));
|
readingsSingleUpdate( $hash, 'state', 'Started', 0 );
|
||||||
|
Log3 $name, 1,
|
||||||
|
sprintf(
|
||||||
|
"EaseeWallbox_Set %s: Updated readings and started timer to automatically update readings with interval %s",
|
||||||
|
$name, InternalVal( $name, 'INTERVAL', undef ) );
|
||||||
}
|
}
|
||||||
elsif ( $opt eq "interval" ) {
|
elsif ( $opt eq "interval" )
|
||||||
|
{ # interval wird immer über Attribut gesetzt. Also in die Funktion AttrFn aus Initialize
|
||||||
my $interval = shift @param;
|
my $interval = shift @param;
|
||||||
|
|
||||||
$interval = 60 unless defined($interval);
|
$interval = 60 unless defined($interval);
|
||||||
@ -430,103 +454,117 @@ sub Set {
|
|||||||
Log3 $name, 1, "EaseeWallbox_Set $name: Set interval to" . $interval;
|
Log3 $name, 1, "EaseeWallbox_Set $name: Set interval to" . $interval;
|
||||||
$hash->{INTERVAL} = $interval;
|
$hash->{INTERVAL} = $interval;
|
||||||
}
|
}
|
||||||
elsif ( $opt eq "cableLock" ) {
|
elsif ( $opt eq "cableLock" ) {
|
||||||
my %message;
|
|
||||||
$message{'state'} = $value;
|
$message{'state'} = $value;
|
||||||
WriteToCloudAPI($hash, 'setCableLockState', 'POST', \%message)
|
WriteToCloudAPI( $hash, 'setCableLockState', 'POST', \%message );
|
||||||
}
|
}
|
||||||
elsif ( $opt eq "pricePerKWH" ) {
|
elsif ( $opt eq "pricePerKWH" ) {
|
||||||
my %message;
|
|
||||||
$message{'currencyId'} = "EUR";
|
$message{'currencyId'} = "EUR";
|
||||||
$message{'vat'} = "19";
|
$message{'vat'} = "19";
|
||||||
$message{'costPerKWh'} = shift @param;
|
$message{'costPerKWh'} = shift @param;
|
||||||
WriteToCloudAPI($hash, 'setChargingPrice', 'POST', \%message)
|
WriteToCloudAPI( $hash, 'setChargingPrice', 'POST', \%message );
|
||||||
}
|
}
|
||||||
elsif ( $opt eq "pairRfidTag" ) {
|
elsif ( $opt eq "pairRfidTag" ) {
|
||||||
my $timeout = shift @param;
|
my $timeout = shift @param;
|
||||||
#if (defined $timeout and /^\d+$/) { print "is a whole number\n" }
|
|
||||||
$timeout = '60' if not defined $timeout or $timeout = '';
|
#if (defined $timeout and /^\d+$/) { print "is a whole number\n" }
|
||||||
my %message;
|
$timeout = '60' if not defined $timeout or $timeout = '';
|
||||||
|
|
||||||
$message{'timeout'} = "60";
|
$message{'timeout'} = "60";
|
||||||
WriteToCloudAPI($hash, 'setPairRFIDTag', 'POST', \%message)
|
WriteToCloudAPI( $hash, 'setPairRFIDTag', 'POST', \%message );
|
||||||
}
|
}
|
||||||
elsif ( $opt eq "enableSmartCharging" ) {
|
elsif ( $opt eq "enableSmartCharging" ) {
|
||||||
my %message;
|
|
||||||
$message{'smartCharging'} = shift @param;
|
$message{'smartCharging'} = shift @param;
|
||||||
WriteToCloudAPI($hash, 'changeChargerSettings', 'POST', \%message)
|
WriteToCloudAPI( $hash, 'changeChargerSettings', 'POST', \%message );
|
||||||
}
|
}
|
||||||
elsif ( $opt eq "enabled" ) {
|
elsif ( $opt eq "enabled" ) {
|
||||||
my %message;
|
|
||||||
$message{'enabled'} = "true";
|
$message{'enabled'} = "true";
|
||||||
WriteToCloudAPI($hash, 'changeChargerSettings', 'POST', \%message)
|
WriteToCloudAPI( $hash, 'changeChargerSettings', 'POST', \%message );
|
||||||
}
|
}
|
||||||
elsif ( $opt eq "disabled" ) {
|
elsif ( $opt eq "disabled" ) {
|
||||||
my %message;
|
|
||||||
$message{'enabled'} = "false";
|
$message{'enabled'} = "false";
|
||||||
WriteToCloudAPI($hash, 'changeChargerSettings', 'POST', \%message)
|
WriteToCloudAPI( $hash, 'changeChargerSettings', 'POST', \%message );
|
||||||
}
|
}
|
||||||
elsif ( $opt eq "authorizationRequired" ) {
|
elsif ( $opt eq "authorizationRequired" ) {
|
||||||
my %message;
|
|
||||||
$message{'authorizationRequired'} = shift @param;
|
$message{'authorizationRequired'} = shift @param;
|
||||||
WriteToCloudAPI($hash, 'changeChargerSettings', 'POST', \%message)
|
WriteToCloudAPI( $hash, 'changeChargerSettings', 'POST', \%message );
|
||||||
}
|
}
|
||||||
elsif ( $opt eq "enableSmartButton" ) {
|
elsif ( $opt eq "enableSmartButton" ) {
|
||||||
my %message;
|
|
||||||
$message{'smartButtonEnabled'} = shift @param;
|
$message{'smartButtonEnabled'} = shift @param;
|
||||||
WriteToCloudAPI($hash, 'changeChargerSettings', 'POST', \%message)
|
WriteToCloudAPI( $hash, 'changeChargerSettings', 'POST', \%message );
|
||||||
}
|
}
|
||||||
elsif ( $opt eq "ledStripBrightness" ) {
|
elsif ( $opt eq "ledStripBrightness" ) {
|
||||||
my %message;
|
|
||||||
$message{'ledStripBrightness'} = shift @param;
|
$message{'ledStripBrightness'} = shift @param;
|
||||||
WriteToCloudAPI($hash, 'changeChargerSettings', 'POST', \%message)
|
WriteToCloudAPI( $hash, 'changeChargerSettings', 'POST', \%message );
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
$hash->{LOCAL} = 1;
|
||||||
$hash->{LOCAL} = 1;
|
WriteToCloudAPI( $hash, 'setStartCharging', 'POST' )
|
||||||
WriteToCloudAPI($hash, 'setStartCharging', 'POST') if $opt eq "startCharging";
|
if $opt eq "startCharging";
|
||||||
WriteToCloudAPI($hash, 'setStopCharging', 'POST') if $opt eq 'stopCharging';
|
WriteToCloudAPI( $hash, 'setStopCharging', 'POST' )
|
||||||
WriteToCloudAPI($hash, 'setPauseCharging', 'POST') if $opt eq 'pauseCharging';
|
if $opt eq 'stopCharging';
|
||||||
WriteToCloudAPI($hash, 'setResumeCharging', 'POST') if $opt eq 'resumeCharging';
|
WriteToCloudAPI( $hash, 'setPauseCharging', 'POST' )
|
||||||
WriteToCloudAPI($hash, 'setToggleCharging', 'POST') if $opt eq 'toggleCharging';
|
if $opt eq 'pauseCharging';
|
||||||
WriteToCloudAPI($hash, 'setUpdateFirmware', 'POST') if $opt eq 'updateFirmware';
|
WriteToCloudAPI( $hash, 'setResumeCharging', 'POST' )
|
||||||
WriteToCloudAPI($hash, 'setOverrideChargingSchedule', 'POST') if $opt eq 'overrideChargingSchedule';
|
if $opt eq 'resumeCharging';
|
||||||
WriteToCloudAPI($hash, 'setReboot', 'POST') if $opt eq 'reboot';
|
WriteToCloudAPI( $hash, 'setToggleCharging', 'POST' )
|
||||||
_loadToken($hash) if $opt eq 'refreshToken';
|
if $opt eq 'toggleCharging';
|
||||||
|
WriteToCloudAPI( $hash, 'setUpdateFirmware', 'POST' )
|
||||||
|
if $opt eq 'updateFirmware';
|
||||||
|
WriteToCloudAPI( $hash, 'setOverrideChargingSchedule', 'POST' )
|
||||||
|
if $opt eq 'overrideChargingSchedule';
|
||||||
|
WriteToCloudAPI( $hash, 'setReboot', 'POST' ) if $opt eq 'reboot';
|
||||||
|
_loadToken($hash) if $opt eq 'refreshToken';
|
||||||
delete $hash->{LOCAL};
|
delete $hash->{LOCAL};
|
||||||
}
|
}
|
||||||
readingsSingleUpdate( $hash, 'state', 'Initialized', 0 );
|
readingsSingleUpdate( $hash, 'state', 'Initialized', 0 )
|
||||||
return undef;
|
; # Die Modulinstanz ist doch nicht erst bei einem set Initialized, das ist doch schon nach dem define. Wenn dann ist hier ein status ala "processing setter" oder so.
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub Attr {
|
sub Attr {
|
||||||
my ( $cmd, $name, $attrName, $attrVal ) = @_;
|
my ( $cmd, $name, $attrName, $attrVal ) = @_;
|
||||||
|
|
||||||
|
# hier kannst Du das setzen des Intervals umsetzen
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub RefreshData{
|
sub RefreshData {
|
||||||
my $hash = shift;
|
my $hash = shift;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
WriteToCloudAPI($hash, 'getChargerSite', 'GET');
|
WriteToCloudAPI( $hash, 'getChargerSite', 'GET' );
|
||||||
WriteToCloudAPI($hash, 'getChargerState', 'GET');
|
WriteToCloudAPI( $hash, 'getChargerState', 'GET' );
|
||||||
WriteToCloudAPI($hash, 'getCurrentSession', 'GET');
|
WriteToCloudAPI( $hash, 'getCurrentSession', 'GET' );
|
||||||
WriteToCloudAPI($hash, 'getChargerConfiguration', 'GET');
|
WriteToCloudAPI( $hash, 'getChargerConfiguration', 'GET' );
|
||||||
WriteToCloudAPI($hash, 'getChargerSessionsMonthly', 'GET');
|
WriteToCloudAPI( $hash, 'getChargerSessionsMonthly', 'GET' );
|
||||||
WriteToCloudAPI($hash, 'getChargerSessionsDaily', 'GET');
|
WriteToCloudAPI( $hash, 'getChargerSessionsDaily', 'GET' );
|
||||||
|
|
||||||
|
return; # immer mit einem return eine funktion beenden
|
||||||
}
|
}
|
||||||
|
|
||||||
sub UpdateDueToTimer($) {
|
sub UpdateDueToTimer {
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
#local allows call of function without adding new timer.
|
#local allows call of function without adding new timer.
|
||||||
#must be set before call ($hash->{LOCAL} = 1) and removed after (delete $hash->{LOCAL};)
|
#must be set before call ($hash->{LOCAL} = 1) and removed after (delete $hash->{LOCAL};)
|
||||||
if ( !$hash->{LOCAL} ) {
|
if ( !$hash->{LOCAL} ) {
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
|
|
||||||
#Log3 "Test", 1, Dumper($hash);
|
#Log3 "Test", 1, Dumper($hash);
|
||||||
InternalTimer(
|
InternalTimer( gettimeofday() + InternalVal( $name, 'INTERVAL', undef ),
|
||||||
gettimeofday() + InternalVal( $name, 'INTERVAL', undef ), "FHEM::EaseeWallbox::UpdateDueToTimer", $hash );
|
"FHEM::EaseeWallbox::UpdateDueToTimer", $hash );
|
||||||
}
|
}
|
||||||
RefreshData($hash);
|
|
||||||
|
return RefreshData($hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub WriteToCloudAPI {
|
sub WriteToCloudAPI {
|
||||||
@ -1071,4 +1109,4 @@ sub _transcodeDate{
|
|||||||
|
|
||||||
=end html
|
=end html
|
||||||
|
|
||||||
=cut
|
=cut
|
Loading…
x
Reference in New Issue
Block a user