From e33c30c2e0216ea889aa5ee3da80317fc788322a Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Sun, 27 Jan 2008 17:13:45 +0000 Subject: [PATCH] Automatic reset for the EM1010PC git-svn-id: https://svn.fhem.de/fhem/trunk@152 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/60_EM.pm | 24 ++++++++++++++++++------ fhem/HISTORY | 3 +++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 7d32ae79c..6a7036745 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -380,6 +380,7 @@ and energy_kWh_w (Boris, 06.01.08) - feature: global attr allowfrom, as wished by Holger (8.1.2008) - feature: FHT: multiple commands, softbuffer changes, cmd rename, doc + - feature: EM1010PC: automatic reset - TODO emem -2.5kW / getDevData for emwz -1 diff --git a/fhem/FHEM/60_EM.pm b/fhem/FHEM/60_EM.pm index 4fce00b1f..a9318be2d 100755 --- a/fhem/FHEM/60_EM.pm +++ b/fhem/FHEM/60_EM.pm @@ -11,6 +11,11 @@ sub EmCrcCheck($$); sub EmEsc($); sub EmGetData($$); sub EmMakeMsg($); +sub EM_Set($@); + +# Following one-byte commands are trange, as they cause a timeout: +# 124 127 150 153 155 156 + ##################################### sub @@ -93,7 +98,7 @@ EM_Set($@) " set time [YYYY-MM-DD HH:MM:SS]"; return $u1 if(int(@a) < 2); - my $msg; + my $name = $hash->{DeviceName}; if($a[1] eq "time") { @@ -106,22 +111,29 @@ EM_Set($@) } my @d = split("-", $a[2]); my @t = split(":", $a[3]); - $msg = sprintf("73%02x%02x%02x00%02x%02x%02x", + my $msg = sprintf("73%02x%02x%02x00%02x%02x%02x", $d[2],$d[1],$d[0]-2000+0xd0, $t[0],$t[1],$t[2]); + my $d = EmGetData($name, $msg); + return "Read error" if(!defined($d)); + return b($d,0); } elsif($a[1] eq "reset") { - $msg = "4545"; + my $d = EmGetData($name, "4545"); # Reset + return "Read error" if(!defined($d)); + sleep(5); + EM_Set($hash, ($a[0], "time")); # Set the time + sleep(1); + $d = EmGetData($name, "67"); # "Push the button", we don't want usesr interaction + return "Read error" if(!defined($d)); } else { return "Unknown argument $a[1], choose one of reset,time" } + return undef; - my $d = EmGetData($hash->{DeviceName}, $msg); - return "Read error" if(!defined($d)); - return b($d,0); } ######################### diff --git a/fhem/HISTORY b/fhem/HISTORY index d34bab964..e8c3d10be 100644 --- a/fhem/HISTORY +++ b/fhem/HISTORY @@ -211,3 +211,6 @@ - lime-protection changed, as it is an actuator subcommand. Further actuator commands added. +- Rudi Sun Jan 27 18:12:42 MET 2008 + - em1010PC: sending a "67" after a reset skips the manual interaction: + automatic reset is now possible.