diff --git a/FHEM/71_XiaomiSmartHome.pm b/FHEM/71_XiaomiSmartHome.pm index d1c22b5..15d7989 100644 --- a/FHEM/71_XiaomiSmartHome.pm +++ b/FHEM/71_XiaomiSmartHome.pm @@ -84,7 +84,7 @@ sub XiaomiSmartHome_Initialize($) { $hash->{AttrList} = "disable:1,0 " . $readingFnAttributes; - $hash->{MatchList} = { "1:XiaomiSmartHome_Device" => "^.+magnet", + $hash->{MatchList} = { "1:XiaomiSmartHome_Device" => "^.+magnet", "2:XiaomiSmartHome_Device" => "^.+motion", "3:XiaomiSmartHome_Device" => "^.+sensor_ht", "4:XiaomiSmartHome_Device" => "^.+switch", @@ -93,14 +93,15 @@ sub XiaomiSmartHome_Initialize($) { "7:XiaomiSmartHome_Device" => "^.+86sw1", "8:XiaomiSmartHome_Device" => "^.+86sw2", "9:XiaomiSmartHome_Device" => "^.+ctrl_neutral1", - "10:XiaomiSmartHome_Device" => "^.+ctrl_neutral2", - "11:XiaomiSmartHome_Device" => "^.+rgbw_light", - "12:XiaomiSmartHome_Device" => "^.+curtain", - "13:XiaomiSmartHome_Device" => "^.+ctrl_ln1", - "14:XiaomiSmartHome_Device" => "^.+ctrl_ln2", - "15:XiaomiSmartHome_Device" => "^.+86plug", - "16:XiaomiSmartHome_Device" => "^.+natgas", - "17:XiaomiSmartHome_Device" => "^.+smoke"}; + "10:XiaomiSmartHome_Device" => "^.+ctrl_neutral2", + "11:XiaomiSmartHome_Device" => "^.+rgbw_light", + "12:XiaomiSmartHome_Device" => "^.+curtain", + "13:XiaomiSmartHome_Device" => "^.+ctrl_ln1", + "14:XiaomiSmartHome_Device" => "^.+ctrl_ln2", + "15:XiaomiSmartHome_Device" => "^.+86plug", + "16:XiaomiSmartHome_Device" => "^.+natgas", + "17:XiaomiSmartHome_Device" => "^.+smoke"}; + "18:XiaomiSmartHome_Device" => "^.+weather.v1"}; FHEM_colorpickerInit(); } ##################################### diff --git a/FHEM/71_XiaomiSmartHome_Device.pm b/FHEM/71_XiaomiSmartHome_Device.pm index 7d93563..e5730e0 100644 --- a/FHEM/71_XiaomiSmartHome_Device.pm +++ b/FHEM/71_XiaomiSmartHome_Device.pm @@ -35,7 +35,7 @@ sub XiaomiSmartHome_Device_Initialize($) { my ($hash) = @_; - $hash->{Match} = "^.+magnet|motion|sensor_ht|switch|plug|cube|86sw1|86sw2|ctrl_neutral1|ctrl_neutral2|rgbw_light|curtain|ctrl_ln1|ctrl_ln2|86plug|natgas|smoke"; + $hash->{Match} = "^.+magnet|motion|sensor_ht|switch|plug|cube|86sw1|86sw2|ctrl_neutral1|ctrl_neutral2|rgbw_light|curtain|ctrl_ln1|ctrl_ln2|86plug|natgas|smoke|weather.v1"; $hash->{DefFn} = "XiaomiSmartHome_Device_Define"; $hash->{SetFn} = "XiaomiSmartHome_Device_Set"; $hash->{UndefFn} = "XiaomiSmartHome_Device_Undef"; @@ -239,6 +239,12 @@ sub XiaomiSmartHome_Device_Read($$$){ Log3 $name, 3, "$name: DEV_Read>" . " Name: " . $hash->{NAME} . " SID: " . $sid . " Type: " . $hash->{MODEL} . " Humidity: " . $hum; readingsBulkUpdate($hash, "humidity", "$hum", 1 ); } + if (defined $data->{pressure}){ + my $pres = $data->{pressure}; + $pres =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1./g; + Log3 $name, 3, "$name: DEV_Read>" . " Name: " . $hash->{NAME} . " SID: " . $sid . " Type: " . $hash->{MODEL} . " Pressure: " . $pres; + readingsBulkUpdate($hash, "pressure", "$pres", 1 ); + } #86sw1 + 86sw2 + ctrl_neutral1 + ctrl_neutral2 start if (defined $data->{channel_0}){ Log3 $name, 3, "$name: DEV_Read>" . " Name: " . $hash->{NAME} . " SID: " . $sid . " Type: " . $hash->{MODEL} . " Channel_0: " . $data->{channel_0}; @@ -404,6 +410,9 @@ sub XiaomiSmartHome_Device_Define($$) { } elsif ( $type eq 'sensor_ht') { $attr{$name}{stateFormat} = 'temperature °C, humidity %' if( !defined( $attr{$name}{stateFormat} ) ); + } + elsif ( $type eq 'weather.v1') { + $attr{$name}{stateFormat} = 'temperature °C, humidity %, pressure kPa' if( !defined( $attr{$name}{stateFormat} ) ); } if( $init_done ) {