setter test

This commit is contained in:
Sebastian 2021-05-29 21:43:38 +02:00
parent 46ab0c9b1d
commit 940c0d43af
2 changed files with 37 additions and 17 deletions

View File

@ -1,2 +1,2 @@
UPD 2021-05-25_20:13:57 4394 FHEM/73_HailoLibero.pm
UPD 2021-05-24_22:53:00 10892 lib/FHEM/Hailo/Libero.pm
UPD 2021-05-29_21:43:21 11674 lib/FHEM/Hailo/Libero.pm

View File

@ -226,11 +226,21 @@ sub Set {
getCookie($hash)
if (ReadingsVal( $name, 'cookie', 'none' ) eq 'none');
# sende befehl
# cmd = setter, $aArg->[0] = value
if (lc $cmd ne 'open') {
$payload = 'led=' if (lc $cmd eq 'led_brightness');
$payload = 'pwr=' if (lc $cmd eq 'eject_power');
$payload = 'dist=' if (lc $cmd eq 'detection_area');
$payload = 'delay=' if (lc $cmd eq 'detection_sensitivity');
$payload = 'pdelay=' if (lc $cmd eq 'eject_delay');
# reade settings
getSettings($hash)
if(lc $cmd ne 'open');
write($hash, $payload)
getSettings($hash)
}
write($hash,undef)
if (lc $cmd eq 'open');
}
else {
@ -267,6 +277,23 @@ sub getCookie {
)
}
sub openDoor {
#curl 'http://192.168.1.216:81/settings' \
# -H 'Referer: http://192.168.1.216:81/admin' \
# -H 'Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7' \
# -H 'Cookie: c=dm40qfdeulkw0phbl95rtcrt1sul4p66' \
# --data-raw 'led=6&pwr=5&dist=50&delay=1&pdelay=1&sbsettings=' \
# --compressed \
# --insecure
}
sub setSettings {
my $hash = shift;
my $name = $hash->{NAME};
Write( $hash, undef, undef, undef );
}
sub getSettings {
my $hash = shift;
my $name = $hash->{NAME};
@ -357,24 +384,17 @@ sub createHttpValueStrings {
if ( ReadingsVal( $name, 'cookie', 'none' ) eq 'none' ){
$uri .= '/login';
readingsSingleUpdate( $hash, 'state', 'fetch cookie', 1 );
} else {
} elsif ( defined($payload)){
$uri .= '/settings';
} elsif ( $payload eq '{}'){
uri .= '/open';
}else {
$uri .= '/admin';
$method = 'GET';
}
return ( $payload, $header, $uri, $method );
}
sub WriteReadings {
my $hash = shift;
my $decode_json = shift;
my $name = $hash->{NAME};
Log3 $name, 4, "HailoLibero ($name) - readings would be written";
return;
}
####################################
####################################
#### my little helpers Sub's #######