get devicename, get firmware
This commit is contained in:
parent
42f412c007
commit
c2f3bfb90a
@ -49,7 +49,7 @@ use JSON;
|
|||||||
use Blocking;
|
use Blocking;
|
||||||
|
|
||||||
|
|
||||||
my $version = "0.0.5";
|
my $version = "0.0.11";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +57,8 @@ my $version = "0.0.5";
|
|||||||
my %gatttChar = (
|
my %gatttChar = (
|
||||||
'devicename' => '0x3',
|
'devicename' => '0x3',
|
||||||
'battery' => '0x3f',
|
'battery' => '0x3f',
|
||||||
'payload' => '0x3d'
|
'payload' => '0x3d',
|
||||||
|
'firmware' => '0x18'
|
||||||
);
|
);
|
||||||
|
|
||||||
my %CallBatteryAge = ( '8h' => 28800,
|
my %CallBatteryAge = ( '8h' => 28800,
|
||||||
@ -97,6 +98,8 @@ sub CometBlueBTLE_CreateDevicenameHEX($);
|
|||||||
|
|
||||||
sub CometBlueBTLE_HandlePayload($$);
|
sub CometBlueBTLE_HandlePayload($$);
|
||||||
sub CometBlueBTLE_HandleBattery($$);
|
sub CometBlueBTLE_HandleBattery($$);
|
||||||
|
sub CometBlueBTLE_HandleFirmware($$);
|
||||||
|
sub CometBlueBTLE_HandleDevicename($$);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -282,7 +285,7 @@ sub CometBlueBTLE_stateRequest($) {
|
|||||||
|
|
||||||
|
|
||||||
if( !IsDisabled($name) ) {
|
if( !IsDisabled($name) ) {
|
||||||
#if( ReadingsVal($name,'firmware','none') ne 'none' ) {
|
if( ReadingsVal($name,'firmware','none') ne 'none' ) {
|
||||||
|
|
||||||
return CometBlueBTLE_CreateParamGatttool($hash,'read',$gatttChar{'battery'})
|
return CometBlueBTLE_CreateParamGatttool($hash,'read',$gatttChar{'battery'})
|
||||||
if( CometBlueBTLE_CallBattery_IsUpdateTimeAgeToOld($hash,$CallBatteryAge{AttrVal($name,'BatteryFirmwareAge','24h')}) );
|
if( CometBlueBTLE_CallBattery_IsUpdateTimeAgeToOld($hash,$CallBatteryAge{AttrVal($name,'BatteryFirmwareAge','24h')}) );
|
||||||
@ -298,10 +301,10 @@ sub CometBlueBTLE_stateRequest($) {
|
|||||||
# return;
|
# return;
|
||||||
#}
|
#}
|
||||||
|
|
||||||
#} else {
|
} else {
|
||||||
|
|
||||||
# CometBlueBTLE_CreateParamGatttool($hash,'read',$XiaomiModels{AttrVal($name,'model','')}{firmware});
|
CometBlueBTLE_CreateParamGatttool($hash,'read',$gatttChar{'firmware'});
|
||||||
#}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
readingsSingleUpdate($hash,"state","disabled",1);
|
readingsSingleUpdate($hash,"state","disabled",1);
|
||||||
@ -340,14 +343,15 @@ sub CometBlueBTLE_Set($$@) {
|
|||||||
my $handle;
|
my $handle;
|
||||||
my $value = 'write';
|
my $value = 'write';
|
||||||
|
|
||||||
if( $cmd eq 'devicename' ) {
|
if( $cmd eq 'desired-temp' ) {
|
||||||
return "usage: devicename <name>" if( @args < 1 );
|
return "usage: desired-temp <name>" if( @args < 1 );
|
||||||
|
|
||||||
#my $devicename = join( " ", @args );
|
#my $devicename = join( " ", @args);
|
||||||
#$mod = 'write'; $handle = $XiaomiModels{AttrVal($name,'model','')}{devicename}; $value = CometBlueBTLE_CreateDevicenameHEX(makeDeviceName($devicename));
|
$mod = 'write'; $handle = $gatttChar{'payload'};
|
||||||
|
$value =;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
my $list = "";
|
my $list = ""; #desired-temp:on,off,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30
|
||||||
return "Unknown argument $cmd, choose one of $list";
|
return "Unknown argument $cmd, choose one of $list";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +378,7 @@ sub CometBlueBTLE_Get($$@) {
|
|||||||
} elsif( $cmd eq 'firmware' ) {
|
} elsif( $cmd eq 'firmware' ) {
|
||||||
return "usage: firmware" if( @args != 0 );
|
return "usage: firmware" if( @args != 0 );
|
||||||
|
|
||||||
$mod = 'read'; $handle = 'test';
|
$mod = 'read'; $handle = $gatttChar{'firmware'};
|
||||||
|
|
||||||
} elsif( $cmd eq 'devicename' ) {
|
} elsif( $cmd eq 'devicename' ) {
|
||||||
return "usage: devicename" if( @args != 0 );
|
return "usage: devicename" if( @args != 0 );
|
||||||
@ -382,7 +386,7 @@ sub CometBlueBTLE_Get($$@) {
|
|||||||
$mod = 'read'; $handle = $gatttChar{'devicename'};
|
$mod = 'read'; $handle = $gatttChar{'devicename'};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
my $list = "temperatures:noArg";
|
my $list = "temperatures:noArg devicename:noArg firmware:noArg";
|
||||||
return "Unknown argument $cmd, choose one of $list";
|
return "Unknown argument $cmd, choose one of $list";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,6 +592,18 @@ sub CometBlueBTLE_ProcessingNotification($@) {
|
|||||||
Log3 $name, 3, "CometBlueBTLE ($name) - ProcessingNotification: handle $gatttChar{'payload'}";
|
Log3 $name, 3, "CometBlueBTLE ($name) - ProcessingNotification: handle $gatttChar{'payload'}";
|
||||||
|
|
||||||
$readings = CometBlueBTLE_HandlePayload($hash,$notification);
|
$readings = CometBlueBTLE_HandlePayload($hash,$notification);
|
||||||
|
|
||||||
|
} elsif( $handle eq $gatttChar{'firmware'} ) {
|
||||||
|
### firmware abrufen
|
||||||
|
Log3 $name, 3, "CometBlueBTLE ($name) - ProcessingNotification: handle $gatttChar{'firmware'}";
|
||||||
|
|
||||||
|
$readings = CometBlueBTLE_HandleFirmware($hash,$notification);
|
||||||
|
|
||||||
|
} elsif( $handle eq $gatttChar{'devicename'} ) {
|
||||||
|
### firmware abrufen
|
||||||
|
Log3 $name, 3, "CometBlueBTLE ($name) - ProcessingNotification: handle $gatttChar{'devicename'}";
|
||||||
|
|
||||||
|
$readings = CometBlueBTLE_HandleDevicename($hash,$notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -595,7 +611,7 @@ sub CometBlueBTLE_ProcessingNotification($@) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub CometBlueBTLE_HandleBattery($$) {
|
sub CometBlueBTLE_HandleBattery($$) {
|
||||||
### FlowerSens - Read Firmware and Battery Data
|
### Read Battery Data
|
||||||
my ($hash,$notification) = @_;
|
my ($hash,$notification) = @_;
|
||||||
|
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
@ -613,7 +629,7 @@ sub CometBlueBTLE_HandleBattery($$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub CometBlueBTLE_HandlePayload($$) {
|
sub CometBlueBTLE_HandlePayload($$) {
|
||||||
### Flower Sens - Read Sensor Data
|
### Read Payload Data
|
||||||
my ($hash,$notification) = @_;
|
my ($hash,$notification) = @_;
|
||||||
|
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
@ -648,6 +664,38 @@ sub CometBlueBTLE_HandlePayload($$) {
|
|||||||
return \%readings;
|
return \%readings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub CometBlueBTLE_HandleFirmware($$) {
|
||||||
|
### Read Firmware Data
|
||||||
|
my ($hash,$notification) = @_;
|
||||||
|
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
my %readings;
|
||||||
|
|
||||||
|
|
||||||
|
Log3 $name, 3, "CometBlueBTLE ($name) - FlowerSens handle $gatttChar{'firmware'}";
|
||||||
|
|
||||||
|
$readings{'firmware'} = pack('H*'.$notification);
|
||||||
|
|
||||||
|
$hash->{helper}{CallBattery} = 0;
|
||||||
|
return \%readings;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub CometBlueBTLE_HandleDevicename($$) {
|
||||||
|
### Read Devicename Data
|
||||||
|
my ($hash,$notification) = @_;
|
||||||
|
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
my %readings;
|
||||||
|
|
||||||
|
|
||||||
|
Log3 $name, 3, "CometBlueBTLE ($name) - FlowerSens handle $gatttChar{'devicename'}";
|
||||||
|
|
||||||
|
$readings{'devicename'} = pack('H*'.$notification);
|
||||||
|
|
||||||
|
$hash->{helper}{CallBattery} = 0;
|
||||||
|
return \%readings;
|
||||||
|
}
|
||||||
|
|
||||||
sub CometBlueBTLE_WriteReadings($$) {
|
sub CometBlueBTLE_WriteReadings($$) {
|
||||||
|
|
||||||
my ($hash,$readings) = @_;
|
my ($hash,$readings) = @_;
|
||||||
@ -744,6 +792,21 @@ sub CometBlueBTLE_ConvertPintoHexLittleEndian($) {
|
|||||||
#my $pinHexLittleEndian;
|
#my $pinHexLittleEndian;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub CometBlueBTLE_CreatePayloadString($$) {
|
||||||
|
|
||||||
|
my ($setCmd,$value) = @_;
|
||||||
|
|
||||||
|
sprintf('%.2x',ReadingsVal($name,'measured-temp',0)*2)
|
||||||
|
sprintf('%.2x',$value*2)
|
||||||
|
sprintf('%.2x',ReadingsVal($name,'tempEco',0)*2)
|
||||||
|
sprintf('%.2x',ReadingsVal($name,'tempComfort',0)*2)
|
||||||
|
sprintf('%.2x',ReadingsVal($name,'tempOffset',0))
|
||||||
|
sprintf('%.2x',ReadingsVal($name,'winOpnState',0))
|
||||||
|
sprintf('%.2x',ReadingsVal($name,'winOpnPeriod',0))
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user