2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-09 20:57:11 +00:00

74_XiaomiFlowerSens: 0.6.8 new set command

git-svn-id: https://svn.fhem.de/fhem/trunk@13407 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2017-02-13 20:40:31 +00:00
parent 5f45916be3
commit 7ffbf17887
2 changed files with 21 additions and 11 deletions

View File

@ -1,7 +1,8 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- bugfix: 74_XiaomiFlowerSens: 0.6.8 new set command
- feature: 23_LUXTRONIK2: new heatSourceDefrost-Readings
- bugfix : 74_XiaomiFlowerSens: 0.6.6 change RegEx for Error Handling
- bugfix: 74_XiaomiFlowerSens: 0.6.6 change RegEx for Error Handling
- feature: 93_DBLog: attributes colEvent, colReading, colValue now also
valid for SQLite DB
- update: 98_DOIFtools: two more checks in checkDOIF

View File

@ -35,7 +35,7 @@ use POSIX;
use JSON;
use Blocking;
my $version = "0.6.6";
my $version = "0.6.8";
@ -229,14 +229,21 @@ sub XiaomiFlowerSens_stateRequestTimer($) {
sub XiaomiFlowerSens_Set($$@) {
my ($hash, $name, @aa) = @_;
my ($cmd, $arg) = @aa;
my $action;
my ($cmd, @args) = @aa;
if( $cmd eq 'statusRequest' ) {
return "usage: statusRequest" if( @args != 0 );
XiaomiFlowerSens_stateRequest($hash);
} elsif( $cmd eq 'clearFirmwareReading' ) {
return "usage: clearFirmwareReading" if( @args != 0 );
readingsSingleUpdate($hash,'firmware','',0);
} else {
my $list = "statusRequest:noArg";
my $list = "statusRequest:noArg clearFirmwareReading:noArg";
return "Unknown argument $cmd, choose one of $list";
}
@ -252,13 +259,13 @@ sub XiaomiFlowerSens_Run($) {
my $wfr;
if( ReadingsVal($name, "firmware", 0) eq "2.6.2" ) {
if( ReadingsVal($name, 'firmware', '') eq "2.6.2" ) {
$wfr = 0;
} else {
$wfr = 1;
}
my $response_encode = XiaomiFlowerSens_forRun_encodeJSON($mac,$wfr);
$hash->{helper}{RUNNING_PID} = BlockingCall("XiaomiFlowerSens_BlockingRun", $name."|".$response_encode, "XiaomiFlowerSens_BlockingDone", 30, "XiaomiFlowerSens_BlockingAborted", $hash) unless(exists($hash->{helper}{RUNNING_PID}));
@ -338,7 +345,7 @@ sub XiaomiFlowerSens_BlockingRun($) {
sub XiaomiFlowerSens_callGatttool($@) {
my ($name,$mac,$wfr) = @_;
my $hci = ReadingsVal($name,"hciDevice","hci0");
my $hci = AttrVal($name,"hciDevice","hci0");
my $loop;
my $wresp;
@ -358,17 +365,18 @@ sub XiaomiFlowerSens_callGatttool($@) {
#### Read Sensor Data
## support for Firmware 2.6.6, man muß erst einen Characterwert schreiben
Log3 $name, 5, "Sub XiaomiFlowerSens_callGatttool ($name) - WFR: $wfr";
if($wfr == 1) {
$loop = 0;
do {
$wresp = qx(gatttool -i $hci -b $mac --char-write-req -a 0x33 -n A01F 2>&1 /dev/null) if($wfr == 1);
$wresp = qx(gatttool -i $hci -b $mac --char-write-req -a 0x33 -n A01F 2>&1 /dev/null);
$loop++;
Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - call gatttool charWrite loop $loop";
Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - charWrite wresp: $wresp" if(defined($wresp));
Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - charWrite wresp: $wresp" if(defined($wresp) and ($wresp) );
} while( ($loop < 10) and (not defined($wresp)) );
} while( ($loop < 10) and (not $wresp =~ /^Characteristic value was written successfully$/) );
}
Log3 $name, 4, "Sub XiaomiFlowerSens_callGatttool ($name) - run gatttool";
@ -571,6 +579,7 @@ sub XiaomiFlowerSens_BlockingAborted($) {
<b>Set</b>
<ul>
<li>statusRequest - retrieves the current state of the Xiaomi Flower Monitor.</li>
<li>clearFirmwareReading - clear firmware reading for new begin.</li>
<br>
</ul>
<br><br>