Merge pull request #4 from bihlmaier/master
Aqara Weather Sensor V2 added
This commit is contained in:
@@ -84,7 +84,7 @@ sub XiaomiSmartHome_Initialize($) {
|
|||||||
$hash->{AttrList} = "disable:1,0 " .
|
$hash->{AttrList} = "disable:1,0 " .
|
||||||
$readingFnAttributes;
|
$readingFnAttributes;
|
||||||
|
|
||||||
$hash->{MatchList} = { "1:XiaomiSmartHome_Device" => "^.+magnet",
|
$hash->{MatchList} = { "1:XiaomiSmartHome_Device" => "^.+magnet",
|
||||||
"2:XiaomiSmartHome_Device" => "^.+motion",
|
"2:XiaomiSmartHome_Device" => "^.+motion",
|
||||||
"3:XiaomiSmartHome_Device" => "^.+sensor_ht",
|
"3:XiaomiSmartHome_Device" => "^.+sensor_ht",
|
||||||
"4:XiaomiSmartHome_Device" => "^.+switch",
|
"4:XiaomiSmartHome_Device" => "^.+switch",
|
||||||
@@ -93,14 +93,15 @@ sub XiaomiSmartHome_Initialize($) {
|
|||||||
"7:XiaomiSmartHome_Device" => "^.+86sw1",
|
"7:XiaomiSmartHome_Device" => "^.+86sw1",
|
||||||
"8:XiaomiSmartHome_Device" => "^.+86sw2",
|
"8:XiaomiSmartHome_Device" => "^.+86sw2",
|
||||||
"9:XiaomiSmartHome_Device" => "^.+ctrl_neutral1",
|
"9:XiaomiSmartHome_Device" => "^.+ctrl_neutral1",
|
||||||
"10:XiaomiSmartHome_Device" => "^.+ctrl_neutral2",
|
"10:XiaomiSmartHome_Device" => "^.+ctrl_neutral2",
|
||||||
"11:XiaomiSmartHome_Device" => "^.+rgbw_light",
|
"11:XiaomiSmartHome_Device" => "^.+rgbw_light",
|
||||||
"12:XiaomiSmartHome_Device" => "^.+curtain",
|
"12:XiaomiSmartHome_Device" => "^.+curtain",
|
||||||
"13:XiaomiSmartHome_Device" => "^.+ctrl_ln1",
|
"13:XiaomiSmartHome_Device" => "^.+ctrl_ln1",
|
||||||
"14:XiaomiSmartHome_Device" => "^.+ctrl_ln2",
|
"14:XiaomiSmartHome_Device" => "^.+ctrl_ln2",
|
||||||
"15:XiaomiSmartHome_Device" => "^.+86plug",
|
"15:XiaomiSmartHome_Device" => "^.+86plug",
|
||||||
"16:XiaomiSmartHome_Device" => "^.+natgas",
|
"16:XiaomiSmartHome_Device" => "^.+natgas",
|
||||||
"17:XiaomiSmartHome_Device" => "^.+smoke"};
|
"17:XiaomiSmartHome_Device" => "^.+smoke"};
|
||||||
|
"18:XiaomiSmartHome_Device" => "^.+weather.v1"};
|
||||||
FHEM_colorpickerInit();
|
FHEM_colorpickerInit();
|
||||||
}
|
}
|
||||||
#####################################
|
#####################################
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ sub XiaomiSmartHome_Device_Initialize($)
|
|||||||
{
|
{
|
||||||
my ($hash) = @_;
|
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->{DefFn} = "XiaomiSmartHome_Device_Define";
|
||||||
$hash->{SetFn} = "XiaomiSmartHome_Device_Set";
|
$hash->{SetFn} = "XiaomiSmartHome_Device_Set";
|
||||||
$hash->{UndefFn} = "XiaomiSmartHome_Device_Undef";
|
$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;
|
Log3 $name, 3, "$name: DEV_Read>" . " Name: " . $hash->{NAME} . " SID: " . $sid . " Type: " . $hash->{MODEL} . " Humidity: " . $hum;
|
||||||
readingsBulkUpdate($hash, "humidity", "$hum", 1 );
|
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
|
#86sw1 + 86sw2 + ctrl_neutral1 + ctrl_neutral2 start
|
||||||
if (defined $data->{channel_0}){
|
if (defined $data->{channel_0}){
|
||||||
Log3 $name, 3, "$name: DEV_Read>" . " Name: " . $hash->{NAME} . " SID: " . $sid . " Type: " . $hash->{MODEL} . " Channel_0: " . $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') {
|
elsif ( $type eq 'sensor_ht') {
|
||||||
$attr{$name}{stateFormat} = 'temperature °C, humidity %' if( !defined( $attr{$name}{stateFormat} ) );
|
$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 ) {
|
if( $init_done ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user