Compare commits

...

2 Commits

Author SHA1 Message Date
8101d71c5f Merge pull request 'fix: remove experimental' (#1) from patch-remove-experimental into dev
Reviewed-on: #1
2024-10-12 06:31:13 +00:00
Marko Oldenburg
5c6280539e fix: remove experimental 2024-10-12 08:30:33 +02:00

View File

@ -39,7 +39,8 @@ package FHEM::XiaomiBTLESens;
use strict;
use warnings;
use experimental qw /switch/;
# use experimental qw /switch/; deprecated
use POSIX;
use FHEM::Meta;
@ -279,8 +280,7 @@ sub Attr {
my ( $cmd, $name, $attrName, $attrVal ) = @_;
my $hash = $defs{$name};
given ($attrName) {
when ('disable') {
if ( $attrName eq 'disable' ) {
if ( $cmd eq 'set' && $attrVal == 1 ) {
RemoveInternalTimer($hash);
@ -292,15 +292,14 @@ sub Attr {
Log3( $name, 3, "XiaomiBTLESens ($name) - enabled" );
}
}
when ('disabledForIntervals') {
elsif ( $attrName eq 'disabledForIntervals' ) {
if ( $cmd eq 'set' ) {
## no critic (Only use a capturing group if you plan to use the captured value)
return
'check disabledForIntervals Syntax HH:MM-HH:MM or HH:MM-HH:MM HH:MM-HH:MM ...'
if ( $attrVal !~ /^((\d{2}:\d{2})-(\d{2}:\d{2})\s?)+$/x );
## use critic
Log3( $name, 3,
"XiaomiBTLESens ($name) - disabledForIntervals" );
Log3( $name, 3, "XiaomiBTLESens ($name) - disabledForIntervals" );
stateRequest($hash);
}
@ -309,8 +308,7 @@ sub Attr {
readingsSingleUpdate( $hash, 'state', 'active', 1 );
}
}
when ('interval') {
elsif ( $attrName eq 'interval' ) {
RemoveInternalTimer($hash);
if ( $cmd eq 'set' ) {
@ -334,8 +332,7 @@ sub Attr {
"XiaomiBTLESens ($name) - set interval to default" );
}
}
when ('blockingCallLoglevel') {
elsif ( $attrName eq 'blockingCallLoglevel' ) {
if ( $cmd eq 'set' ) {
$hash->{loglevel} = $attrVal;
Log3( $name, 3,
@ -350,7 +347,6 @@ sub Attr {
);
}
}
}
return;
}
@ -400,7 +396,8 @@ sub Notify {
if (
(
AttrVal( $name, 'model', 'thermoHygroSens' ) eq 'thermoHygroSens'
|| AttrVal( $name, 'model', 'mijiaLYWSD03MMC' ) eq 'mijiaLYWSD03MMC'
|| AttrVal( $name, 'model', 'mijiaLYWSD03MMC' ) eq
'mijiaLYWSD03MMC'
)
&& $devname eq $name
&& grep { /^$name.firmware.+/x } @{$events}
@ -427,8 +424,9 @@ sub stateRequest {
if (
CallBattery_IsUpdateTimeAgeToOld(
$hash,
$CallBatteryAge{ AttrVal( $name, 'BatteryFirmwareAge',
'24h' ) }
$CallBatteryAge{
AttrVal( $name, 'BatteryFirmwareAge', '24h' )
}
)
);
@ -507,12 +505,14 @@ sub Set {
return 'usage: devicename <name>' if ( scalar( @{$arg_ref} ) < 1 );
$mod = 'write';
$handle = $XiaomiModels{ AttrVal( $name, 'model', '' ) }{devicename};
$handle =
$XiaomiModels{ AttrVal( $name, 'model', '' ) }{devicename};
$value = CreateDevicenameHEX( makeDeviceName( $arg_ref->[0] ) );
}
elsif ( $cmd eq 'resetBatteryTimestamp' ) {
return 'usage: resetBatteryTimestamp' if ( scalar( @{$arg_ref} ) != 0 );
return 'usage: resetBatteryTimestamp'
if ( scalar( @{$arg_ref} ) != 0 );
$hash->{helper}{updateTimeCallBattery} = 0;
return;
@ -568,7 +568,8 @@ sub Get {
return "usage: devicename" if ( scalar( @{$arg_ref} ) != 0 );
$mod = 'read';
$handle = $XiaomiModels{ AttrVal( $name, 'model', '' ) }{devicename};
$handle =
$XiaomiModels{ AttrVal( $name, 'model', '' ) }{devicename};
}
else {
@ -748,7 +749,8 @@ qx(ssh $sshHost '$psCommand | grep -E "$gatttoolCmdlineStaticEscaped"')
if ( !defined( $gtResult[0] ) );
$loop++;
} while ( $loop < 5 && ( $returnCode != 0 && $returnCode != 124 ) );
} while ( $loop < 5
&& ( $returnCode != 0 && $returnCode != 124 ) );
Log3( $name, 3,
"XiaomiBTLESens ($name) - ExecGatttool_Run: errorcode: \"$returnCode\", ErrorString: \"$returnString\""
) if ( $returnCode != 0 && $returnCode != 124 );
@ -903,8 +905,7 @@ sub ProcessingNotification {
}
elsif ( AttrVal( $name, 'model', 'none' ) eq 'thermoHygroSens' ) {
given ($handle) {
when ('0x18') {
if ( $handle eq '0x18' ) {
### Thermo/Hygro Sens - Read Battery Data
Log3( $name, 4,
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x18"
@ -912,7 +913,7 @@ sub ProcessingNotification {
$readings = ThermoHygroSensHandle0x18( $hash, $notification );
}
when ('0x10') {
elsif ( $handle eq '0x10' ) {
### Thermo/Hygro Sens - Read Sensor Data
Log3( $name, 4,
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x10"
@ -920,7 +921,7 @@ sub ProcessingNotification {
$readings = ThermoHygroSensHandle0x10( $hash, $notification );
}
when ('0x24') {
elsif ( $handle eq '0x24' ) {
### Thermo/Hygro Sens - Read Firmware Data
Log3( $name, 4,
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x24"
@ -928,11 +929,10 @@ sub ProcessingNotification {
$readings = ThermoHygroSensHandle0x24( $hash, $notification );
}
when ('0x3') {
elsif ( $handle eq '0x3' ) {
### Thermo/Hygro Sens - Read and Write Devicename
Log3( $name, 4,
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x3"
);
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x3" );
return CreateParamGatttool( $hash, 'read',
$XiaomiModels{ AttrVal( $name, 'model', '' ) }{devicename} )
@ -940,10 +940,8 @@ sub ProcessingNotification {
$readings = ThermoHygroSensHandle0x3( $hash, $notification );
}
}
}
elsif ( AttrVal( $name, 'model', 'none' ) eq 'mijiaLYWSD03MMC' ) {
given ($handle) {
when ('0x1b') {
if ( $handle eq '0x1b' ) {
### mijiaLYWSD03MMC - Read Battery Data
Log3( $name, 4,
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x1b"
@ -951,7 +949,7 @@ sub ProcessingNotification {
$readings = mijiaLYWSD03MMC_Handle0x1b( $hash, $notification );
}
when ('0x38') {
elsif ( $handle eq '0x38' ) {
### mijiaLYWSD03MMC - Read Sensor Data
Log3( $name, 4,
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x38"
@ -959,7 +957,7 @@ sub ProcessingNotification {
$readings = mijiaLYWSD03MMC_Handle0x38( $hash, $notification );
}
when ('0x12') {
elsif ( $handle eq '0x12' ) {
### mijiaLYWSD03MMC - Read Firmware Data
Log3( $name, 4,
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x12"
@ -967,11 +965,10 @@ sub ProcessingNotification {
$readings = mijiaLYWSD03MMC_Handle0x12( $hash, $notification );
}
when ('0x3') {
elsif ( $handle eq '0x3' ) {
### mijiaLYWSD03MMC - Read and Write Devicename
Log3( $name, 4,
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x3"
);
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x3" );
return CreateParamGatttool( $hash, 'read',
$XiaomiModels{ AttrVal( $name, 'model', '' ) }{devicename} )
@ -979,10 +976,8 @@ sub ProcessingNotification {
$readings = mijiaLYWSD03MMC_Handle0x3( $hash, $notification );
}
}
}
elsif ( AttrVal( $name, 'model', 'none' ) eq 'clearGrassSens' ) {
given ($handle) {
when ('0x3b') {
if ( $handle eq '0x3b' ) {
### Clear Grass Sens - Read Battery Data
Log3( $name, 4,
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x3b"
@ -990,7 +985,7 @@ sub ProcessingNotification {
$readings = ClearGrassSensHandle0x3b( $hash, $notification );
}
when ('0x1e') {
elsif ( $handle eq '0x1e' ) {
### Clear Grass Sens - Read Sensor Data
Log3( $name, 4,
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x1e"
@ -998,7 +993,7 @@ sub ProcessingNotification {
$readings = ClearGrassSensHandle0x1e( $hash, $notification );
}
when ('0x2a') {
elsif ( $handle eq '0x2a' ) {
### Clear Grass Sens - Read Firmware Data
Log3( $name, 4,
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x2a"
@ -1006,11 +1001,10 @@ sub ProcessingNotification {
$readings = ClearGrassSensHandle0x2a( $hash, $notification );
}
when ('0x3') {
elsif ( $handle eq '0x3' ) {
### Clear Grass Sens - Read and Write Devicename
Log3( $name, 4,
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x3"
);
"XiaomiBTLESens ($name) - ProcessingNotification: handle 0x3" );
return CreateParamGatttool( $hash, 'read',
$XiaomiModels{ AttrVal( $name, 'model', '' ) }{devicename} )
@ -1018,7 +1012,6 @@ sub ProcessingNotification {
$readings = ClearGrassSensHandle0x3( $hash, $notification );
}
}
}
return WriteReadings( $hash, $readings );
}