diff --git a/FHEM/71_XiaomiSmartHome.pm b/FHEM/71_XiaomiSmartHome.pm index 98ccaaa..06f33a4 100644 --- a/FHEM/71_XiaomiSmartHome.pm +++ b/FHEM/71_XiaomiSmartHome.pm @@ -40,6 +40,8 @@ eval "use Crypt::CBC"; return "\nERROR: Please install Crypt::CBC" if($@); eval "use Net::Ping"; return "\nERROR: Please install Net::Ping" if($@); +eval "use Math::Round"; +return "\nERROR: Please install libmath-round-perl" if($@); use Color; @@ -50,7 +52,9 @@ use SetExtensions; sub XiaomiSmartHome_Notify($$); sub XiaomiSmartHome_updateSingleReading($$); my $iv="\x17\x99\x6d\x09\x3d\x28\xdd\xb3\xba\x69\x5a\x2e\x6f\x58\x56\x2e"; + my $version = "1.19"; + my %XiaomiSmartHome_gets = ( "getDevices" => ["get_id_list", '^.+get_id_list_ack' ], diff --git a/FHEM/71_XiaomiSmartHome_Device.pm b/FHEM/71_XiaomiSmartHome_Device.pm index dd36e59..f3e0329 100644 --- a/FHEM/71_XiaomiSmartHome_Device.pm +++ b/FHEM/71_XiaomiSmartHome_Device.pm @@ -24,9 +24,11 @@ package main; use strict; use warnings; +use Math::Round qw/nearest/; my $version = "1.19"; + sub XiaomiSmartHome_Device_updateSReading($); @@ -44,9 +46,11 @@ sub XiaomiSmartHome_Device_Initialize($) $hash->{AttrList} = "IODev follow-on-for-timer:1,0 follow-on-timer ". "do_not_notify:1,0 ignore:1,0 dummy:1,0 showtime:1,0 valueFn:textField-long ". + "rnd_tmp:1,2,3 ". "rnd_hum:1,2,3 ". "rnd_bat:1,2,3 ". + $readingFnAttributes ; } ##################################### @@ -194,9 +198,11 @@ sub XiaomiSmartHome_Device_on_timeout($){ ##################################### sub XiaomiSmartHome_Device_Read($$$){ my ($hash, $msg, $name) = @_; + my $XMIround_tmp = AttrVal( $hash->{NAME}, "rnd_tmp", "2" ); my $XMIround_hum = AttrVal( $hash->{NAME}, "rnd_hum", "2" ); my $XMIround_bat = AttrVal( $hash->{NAME}, "rnd_bat", "1" ); + my $decoded = eval{decode_json($msg)}; if ($@) { Log3 $name, 1, "$name: DEV_Read> Error while request: $@"; @@ -222,6 +228,7 @@ sub XiaomiSmartHome_Device_Read($$$){ readingsBulkUpdate($hash, "no_close", "0", 1 ); } } + if (defined $data->{no_motion}){ Log3 $name, 4, "$name: DEV_Read>" . " Name: " . $hash->{NAME} . " SID: " . $sid . " Type: " . $hash->{MODEL} . " NO_motion: " . $data->{no_motion}; readingsBulkUpdate($hash, "no_motion", "$data->{no_motion}", 1 ); diff --git a/README.md b/README.md index a4caeba..36a6ef9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,38 @@ # fhem-XiaomiSmartHome Gateway -With this module, the XiaomiGateway is bound to Fhem. The module listens for multicast messages from the gateway. Currently only for the sensortype Magnet, Motion, Temperature-Humidity, Switch, Cube, Curtain, Smoke and Gas. -Changing and switching the led of the gateway and changing ringtone and volume of the gateway is also possible +With this module, the Xiaomi Smarthome Gateway is bound to FHEM. The module listens for multicast messages from the gateway. +Changing and switching the LED from the gateway and changing ringtone and volume of the gateway is also possible * Please read the Wiki !! you need to install some Perl modules. * https://github.com/T0RST3N/fhem-XiaomiSmartHome/wiki + +# Supported Sensors +* magnet: Window/Door magnetic sensor +* motion: Human body motion sensor +* sensor_motion.aq2: Aqara Human body motion sensor with lux readings +* sensor_ht: Temperature and humidity sensor +* weather.v1: Aqara Temperature, pressure and humidity sensor +* switch: Wireless sensor switch +* plug & 86plug: Smart socket +* cube: Cube sensor +* 86sw1: Wireless switch single +* 86sw2: Wireless switch double +* ctrl_neutral1: Single bond ignition switch +* ctrl_neutral2: Double bond ignition switch +* rgbw_light: Smart lights (report only) +* curtain: Curtain (Control only if device has reporte curtain_level) +* wleak: Watersensor +* smoke: smoke alarm detector +* * 0: disarm +* * 1: arlarm +* * 8: battery arlarm +* * 64: arlarm sensitivity +* * 32768: ICC communication failure +* gas: gas alarm detector +* * 0: disarm +* * 1: arlarm +* * 2: analog arlarm +* * 64: arlarm sensitivity +* * 32768: ICC communication failure + +# A BIG ThankYOU to my Supporters +* StefanB from Coburg diff --git a/images/7.PNG b/images/7.PNG new file mode 100644 index 0000000..d4a7314 Binary files /dev/null and b/images/7.PNG differ