diff --git a/fhem/FHEM/24_TPLinkHS110.pm b/fhem/FHEM/24_TPLinkHS110.pm index 66ccdb7fc..23bfdca57 100644 --- a/fhem/FHEM/24_TPLinkHS110.pm +++ b/fhem/FHEM/24_TPLinkHS110.pm @@ -1,7 +1,7 @@ ################################################################ # $Id$ # -# Release 2019-05-31 SendCommand2 +# Release 2020-01-19 # # Copyright notice # @@ -175,7 +175,7 @@ sub TPLinkHS110_Get($$) { my $errmsg; my $data; - my $command = '{"system":{"get_sysinfo":{}}}'; + my $command = '{"system":{"get_sysinfo":{}},"time":{"get_time":{}}}'; ($errmsg, $data) = TPLinkHS110_SendCommand($hash, $command); if (defined($errmsg)) { Log3 $hash, 1, "TPLinkHS110: $name Get failed - " . $errmsg; # JV @@ -206,6 +206,17 @@ sub TPLinkHS110_Get($$) { } $key = $hwMap{$hw_ver}{'system'}{'get_sysinfo'}{$key}{'name'} } + + # next_action + if ($key eq "next_action") { + if ($sysinfoValue->{'type'} eq "1" ) { + # e.g. 12:34 on + $sysinfoValue = sprintf("%02i:%02i %s",int($sysinfoValue->{'schd_sec'} / 60 / 60),int($sysinfoValue->{'schd_sec'} / 60 % 60),($sysinfoValue->{'action'} eq "1" ? ' on' : " off" )); + } else { + $sysinfoValue = "-None-"; + } + } + readingsBulkUpdate($hash, $key, $sysinfoValue); } if ($json->{'system'}->{'get_sysinfo'}->{'relay_state'} == 0) { @@ -214,6 +225,17 @@ sub TPLinkHS110_Get($$) { if ($json->{'system'}->{'get_sysinfo'}->{'relay_state'} == 1) { readingsBulkUpdate($hash, "state", "on"); } + + # Get Time + my $remotetime = $json->{'time'}->{'get_time'}->{'year'}."-"; + $remotetime .= $json->{'time'}->{'get_time'}->{'month'}."-"; + $remotetime .= $json->{'time'}->{'get_time'}->{'mday'}. " "; + $remotetime .= $json->{'time'}->{'get_time'}->{'hour'}.":"; + $remotetime .= $json->{'time'}->{'get_time'}->{'min'}.":"; + $remotetime .= $json->{'time'}->{'get_time'}->{'sec'}; + + readingsBulkUpdate($hash, "time", $remotetime); + # If the device is a HS110, get realtime data: # if ( 1 == 0 ) { if ($json->{'system'}->{'get_sysinfo'}->{'model'} eq "HS110(EU)" or $json->{'system'}->{'get_sysinfo'}->{'model'} eq "HS110(UK)") { @@ -239,7 +261,7 @@ sub TPLinkHS110_Get($$) { return; } else { - Log3 $hash, 2, "TPLinkHS110: $name Realtime data updated"; + Log3 $hash, 3, "TPLinkHS110: $name Realtime data updated"; } my %emeterReadings = (); @@ -264,7 +286,6 @@ sub TPLinkHS110_Get($$) { Log3 $hash, 3, "TPLinkHS110: $name Device is an HS110. Got extra realtime data: $emeterReadings{'power'} Watt, $emeterReadings{'voltage'} Volt, $emeterReadings{'current'} Ampere"; - # Get Daily Stats $command = '{"emeter":{"get_daystat":{"month":' . $mon . ',"year":' . $year . '}}}'; ($errmsg, $data) = TPLinkHS110_SendCommand($hash, $command); @@ -302,7 +323,7 @@ sub TPLinkHS110_Get($$) { if ($hw_ver eq "1.0") {readingsBulkUpdate($hash, "monthly_total", $total);} if ($hw_ver eq "2.0") {readingsBulkUpdate($hash, "monthly_total", $total * 0.001);} if ($count) {readingsBulkUpdate($hash, "daily_average", $total / $count)}; - Log3 $hash, 2, "TPLinkHS110: $name Daystat updated"; + Log3 $hash, 3, "TPLinkHS110: $name Daystat updated"; } else { Log3 $hash, 1, "TPLinkHS110: $name Error updating daystat. Success: " . $success . ", json: " . $json;