Add: Readings for PLUG

Support for Plug first only the readings
This commit is contained in:
2017-03-30 08:45:20 +02:00
parent 345de914bd
commit aac105544a
3 changed files with 19 additions and 6 deletions

View File

@@ -36,7 +36,7 @@ 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 = "0.05";
my $version = "0.08";
my %XiaomiSmartHome_gets = (
"getDevices" => ["get_id_list", '^.+get_id_list_ack' ],
@@ -72,7 +72,8 @@ sub XiaomiSmartHome_Initialize($) {
$hash->{MatchList} = { "1:XiaomiSmartHome_Device" => "^.+magnet",
"2:XiaomiSmartHome_Device" => "^.+motion",
"3:XiaomiSmartHome_Device" => "^.+sensor_ht",
"4:XiaomiSmartHome_Device" => "^.+switch"};
"4:XiaomiSmartHome_Device" => "^.+switch",
"5:XiaomiSmartHome_Device" => "^.+plug"};
FHEM_colorpickerInit();
}
#####################################

View File

@@ -25,7 +25,7 @@ package main;
use strict;
use warnings;
my $version = "0.07";
my $version = "0.08";
sub XiaomiSmartHome_Device_updateSReading($);
#####################################
@@ -34,7 +34,7 @@ sub XiaomiSmartHome_Device_Initialize($)
{
my ($hash) = @_;
$hash->{Match} = "^.+magnet|motion|sensor_ht|switch";
$hash->{Match} = "^.+magnet|motion|sensor_ht|switch|plug";
$hash->{DefFn} = "XiaomiSmartHome_Device_Define";
#$hash->{SetFn} = "XiaomiSmartHome_Device_Set";
$hash->{UndefFn} = "XiaomiSmartHome_Device_Undef";
@@ -109,6 +109,18 @@ sub XiaomiSmartHome_Device_Read($$$){
Log3 $name, 3, "$name>" . " SID: " . $sid . " Type: " . $hash->{MODEL} . " Humidity: " . $hum;
readingsSingleUpdate($hash, "humidity", "$hum", 1 );
}
if(defined $data->{load_voltage}){
Log3 $name, 3, "$name>" . " SID: " . $sid . " Type: " . $hash->{MODEL} . " LOAD_Voltage: " . $data->{load_voltage};
readingsSingleUpdate($hash, "LOAD_Voltage", "$data->{load_voltage}", 1 );
}
if(defined $data->{load_power}){
Log3 $name, 3, "$name>" . " SID: " . $sid . " Type: " . $hash->{MODEL} . " LOAD_Power: " . $data->{load_power};
readingsSingleUpdate($hash, "LOAD_Power", "$data->{load_power}", 1 );
}
if(defined $data->{power_consumed}){
Log3 $name, 3, "$name>" . " SID: " . $sid . " Type: " . $hash->{MODEL} . " POWER_Consumed: " . $data->{power_consumed};
readingsSingleUpdate($hash, "LOAD_Power", "$data->{power_consumed}", 1 );
}
if ($decoded->{'cmd'} eq 'heartbeat'){
readingsSingleUpdate($hash, 'heartbeat', $decoded->{'sid'} , 1 );
}

View File

@@ -1,2 +1,2 @@
UPD 2017-03-22_18:48:03 14910 FHEM/71_XiaomiSmartHome.pm
UPD 2017-03-25_10:48:10 8231 FHEM/71_XiaomiSmartHome_Device.pm
UPD 2017-03-30_08:35:44 14962 FHEM/71_XiaomiSmartHome.pm
UPD 2017-03-30_08:33:08 8937 FHEM/71_XiaomiSmartHome_Device.pm