added commands: enabled/disabled/smartbutton/authrequired

This commit is contained in:
Matthias Sandmann 2022-03-19 16:00:05 +01:00
parent dbf7fb844e
commit 4f7350cc3e

View File

@ -111,6 +111,10 @@ my %gets = (
); );
my %sets = ( my %sets = (
enabled => "",
disabled => "",
enableSmartButton => "true,false",
authorizationRequired => "true,false",
startCharging => "", startCharging => "",
stopCharging => "", stopCharging => "",
pauseCharging => "", pauseCharging => "",
@ -449,6 +453,26 @@ sub Set {
$message{'smartCharging'} = shift @param; $message{'smartCharging'} = shift @param;
WriteToCloudAPI($hash, 'changeChargerSettings', 'POST', \%message) WriteToCloudAPI($hash, 'changeChargerSettings', 'POST', \%message)
} }
elsif ( $opt eq "enabled" ) {
my %message;
$message{'enabled'} = "true";
WriteToCloudAPI($hash, 'changeChargerSettings', 'POST', \%message)
}
elsif ( $opt eq "disabled" ) {
my %message;
$message{'enabled'} = "false";
WriteToCloudAPI($hash, 'changeChargerSettings', 'POST', \%message)
}
elsif ( $opt eq "authorizationRequired" ) {
my %message;
$message{'authorizationRequired'} = shift @param;
WriteToCloudAPI($hash, 'changeChargerSettings', 'POST', \%message)
}
elsif ( $opt eq "enableSmartButton" ) {
my %message;
$message{'smartButtonEnabled'} = shift @param;
WriteToCloudAPI($hash, 'changeChargerSettings', 'POST', \%message)
}
else else
{ {
$hash->{LOCAL} = 1; $hash->{LOCAL} = 1;
@ -604,18 +628,20 @@ sub ResponseHandling {
eval { eval {
my $d = decode_json($data); my $d = decode_json($data);
Log3 $name, 5, 'Decoded: ' . Dumper($d); Log3 $name, 5, 'Decoded: ' . Dumper($d);
Log3 $name, 5, 'Ref of d: ' . ref($d);
$d = $d->[0] if ref($d) eq "ARRAY";
if ( defined $d and $d ne '' and ref($d) eq "HASH") { if ( defined $d and $d ne '' and ref($d) eq "HASH") {
if($param->{dpoint} eq 'getChargers') if($param->{dpoint} eq 'getChargers')
{ {
my $site = $d->[0]; my $site = $d;
my $circuit = $site->{circuits}->[0]; my $circuit = $site->{circuits}->[0];
my $charger = $circuit->{chargers}->[0]; my $charger = $circuit->{chargers}->[0];
readingsBeginUpdate($hash); readingsBeginUpdate($hash);
my $chargerId = $charger->{id}; my $chargerId = $charger->{id};
readingsBulkUpdate( $hash, "site_id", $site->{id} ); readingsBulkUpdate( $hash, "site_id", $site->{id} );
readingsBulkUpdate( $hash, "site_key", $d->{siteKey} ); readingsBulkUpdate( $hash, "site_key", $site->{siteKey} );
readingsBulkUpdate( $hash, "charger_id", $chargerId ); readingsBulkUpdate( $hash, "charger_id", $chargerId );
readingsBulkUpdate( $hash, "charger_name", $charger->{name} ); readingsBulkUpdate( $hash, "charger_name", $charger->{name} );
readingsBulkUpdate( $hash, "lastResponse", 'OK - getReaders', 1); readingsBulkUpdate( $hash, "lastResponse", 'OK - getReaders', 1);