From 400e586d2876d5e7ef10b45effb02df6afa91bbb Mon Sep 17 00:00:00 2001 From: risiko79 Date: Sat, 30 May 2015 17:03:51 +0000 Subject: [PATCH] 30_pilight_*: fix restore (StateFn) git-svn-id: https://svn.fhem.de/fhem/trunk@8663 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/10_pilight_ctrl.pm | 18 ++++++++++++++++-- fhem/FHEM/30_pilight_dimmer.pm | 23 ++++++++++++++++------- fhem/FHEM/30_pilight_switch.pm | 18 ++++++++++++++++-- fhem/FHEM/30_pilight_temp.pm | 19 ++++++++++++++++--- 5 files changed, 65 insertions(+), 14 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 99f597ff2..9e7ef189b 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - bugfix: 30_pilight_*: restore (StateFn) - feature: 30_pilight_dimmer: new attributes dimlevel_on, dimlevel_off dimmers without direct dimlevel support (switch combined with screen) - bugfix: 73_km200: Bugfix for sorting and comparison method diff --git a/fhem/FHEM/10_pilight_ctrl.pm b/fhem/FHEM/10_pilight_ctrl.pm index 81fed1d80..4ada45bfc 100644 --- a/fhem/FHEM/10_pilight_ctrl.pm +++ b/fhem/FHEM/10_pilight_ctrl.pm @@ -1,5 +1,5 @@ ############################################## -# $Id: 10_pilight_ctrl.pm 1.03 2015-05-20 Risiko $ +# $Id: 10_pilight_ctrl.pm 1.04 2015-05-30 Risiko $ # # Usage # @@ -26,7 +26,8 @@ # V 1.00 2015-05-09 - NEW: white list for defined submodules activating by ignoreProtocol * # V 1.01 2015-05-09 - NEW: add quigg_gt* protocol (e.q quigg_gt7000) # V 1.02 2015-05-16 - NEW: battery state for temperature sensors -# V 1.03 2015-05-20 - NEW: handle screen messages (up,down) +# V 1.03 2015-05-20 - NEW: handle screen messages (up,down) +# V 1.04 2015-05-30 - FIX: StateFn ############################################## package main; @@ -70,6 +71,7 @@ sub pilight_ctrl_Initialize($) $hash->{UndefFn} = "pilight_ctrl_Undef"; $hash->{SetFn} = "pilight_ctrl_Set"; $hash->{NotifyFn}= "pilight_ctrl_Notify"; + $hash->{StateFn} = "pilight_ctrl_State"; $hash->{AttrList}= "ignoreProtocol brands ContactAsSwitch ".$readingFnAttributes; $hash->{Clients} = ":pilight_switch:pilight_dimmer:pilight_temp:"; @@ -114,6 +116,18 @@ sub pilight_ctrl_Define($$) return pilight_ctrl_TryConnect($hash); } +##################################### +sub pilight_ctrl_State($$$$) +{ + my ($hash, $time, $name, $val) = @_; + my $me = $hash->{NAME}; + # gespeicherten Readings löschen + if ($name eq "state" || $name eq "rcv_raw") { + setReadingsVal($hash, $name, undef, TimeNow()); + } + return undef; +} + sub pilight_ctrl_Close($) { my $hash = shift; diff --git a/fhem/FHEM/30_pilight_dimmer.pm b/fhem/FHEM/30_pilight_dimmer.pm index 09512c730..7504a80b1 100644 --- a/fhem/FHEM/30_pilight_dimmer.pm +++ b/fhem/FHEM/30_pilight_dimmer.pm @@ -1,5 +1,5 @@ ############################################## -# $Id: 30_pilight_dimmer.pm 0.53 2015-05-30 Risiko $ +# $Id: 30_pilight_dimmer.pm 0.54 2015-05-30 Risiko $ # # Usage # @@ -13,6 +13,7 @@ # V 0.51 2015-05-21 - CHG: modifications for dimers without dimlevel # V 0.52 2015-05-25 - CHG: attributes dimlevel_on, dimlevel_off # V 0.53 2015-05-30 - FIX: set dimlevel 0 +# V 0.54 2015-05-30 - FIX: StateFn ############################################## package main; @@ -23,10 +24,6 @@ use Time::HiRes qw(gettimeofday); use JSON; use Switch; #libswitch-perl -sub pilight_dimmer_Parse($$); -sub pilight_dimmer_Define($$); -sub pilight_dimmer_Fingerprint($$); - sub pilight_dimmer_Initialize($) { my ($hash) = @_; @@ -35,6 +32,7 @@ sub pilight_dimmer_Initialize($) $hash->{Match} = "^PISWITCH|^PIDIMMER|^PISCREEN"; $hash->{ParseFn} = "pilight_dimmer_Parse"; $hash->{SetFn} = "pilight_dimmer_Set"; + $hash->{StateFn} = "pilight_dimmer_State"; $hash->{AttrList} = "dimlevel_max dimlevel_step dimlevel_max_device dimlevel_on dimlevel_off ".$readingFnAttributes; } @@ -56,6 +54,7 @@ sub pilight_dimmer_Define($$) my $unit = $a[4]; $hash->{STATE} = "defined"; + $hash->{PROTOCOL} = lc($protocol); $hash->{ID} = $id; $hash->{UNIT} = $unit; @@ -64,7 +63,7 @@ sub pilight_dimmer_Define($$) $hash->{helper}{OWN_DIM} = 1; $hash->{helper}{OWN_DIM} = 0 if ($hash->{PROTOCOL} =~ /screen/); - $hash->{helper}{ISSCREEN} = 1 if ($hash->{PROTOCOL} =~ /screen/ or $hash->{PROTOCOL2} =~ /screen/); + $hash->{helper}{ISSCREEN} = 1 if ($hash->{PROTOCOL} =~ /screen/ or (defined($hash->{PROTOCOL2}) and $hash->{PROTOCOL2}) =~ /screen/); #$attr{$me}{verbose} = 5; @@ -78,7 +77,6 @@ sub pilight_dimmer_Parse($$) { my ($mhash, $rmsg, $rawdata) = @_; my $backend = $mhash->{NAME}; - my $dimlevel = undef; Log3 $backend, 4, "pilight_dimmer_Parse: RCV -> $rmsg"; @@ -265,6 +263,17 @@ sub pilight_dimmer_Set($$) return undef; } +##################################### +sub pilight_dimmer_State($$$$) +{ + my ($hash, $time, $name, $val) = @_; + my $me = $hash->{NAME}; + + #$hash->{STATE} wird nur ersetzt, wenn $hash->{STATE} == ??? fhem.pl Z: 2469 + #machen wir es also selbst + $hash->{STATE} = $val if ($name eq "state"); + return undef; +} 1; diff --git a/fhem/FHEM/30_pilight_switch.pm b/fhem/FHEM/30_pilight_switch.pm index 98ce8f1d1..0ce8d890f 100644 --- a/fhem/FHEM/30_pilight_switch.pm +++ b/fhem/FHEM/30_pilight_switch.pm @@ -1,5 +1,5 @@ ############################################## -# $Id: 30_pilight_switch.pm 0.12 2015-05-18 Risiko $ +# $Id: 30_pilight_switch.pm 0.13 2015-05-30 Risiko $ # # Usage # @@ -10,6 +10,7 @@ # V 0.10 2015-02-22 - initial beta version # V 0.11 2015-03-29 - FIX: $readingFnAttributes # V 0.12 2015-05-18 - FIX: add version information +# V 0.13 2015-05-30 - FIX: StateFn ############################################## package main; @@ -21,7 +22,7 @@ use JSON; sub pilight_switch_Parse($$); sub pilight_switch_Define($$); -sub pilight_switch_Fingerprint($$); + sub pilight_switch_Initialize($) { @@ -31,6 +32,7 @@ sub pilight_switch_Initialize($) $hash->{Match} = "^PISWITCH"; $hash->{ParseFn} = "pilight_switch_Parse"; $hash->{SetFn} = "pilight_switch_Set"; + $hash->{StateFn} = "pilight_switch_State"; $hash->{AttrList} = $readingFnAttributes; } @@ -63,6 +65,18 @@ sub pilight_switch_Define($$) return undef; } +##################################### +sub pilight_switch_State($$$$) +{ + my ($hash, $time, $name, $val) = @_; + my $me = $hash->{NAME}; + + #$hash->{STATE} wird nur ersetzt, wenn $hash->{STATE} == ??? fhem.pl Z: 2469 + #machen wir es also selbst + $hash->{STATE} = $val if ($name eq "state"); + return undef; +} + ########################################### sub pilight_switch_Parse($$) { diff --git a/fhem/FHEM/30_pilight_temp.pm b/fhem/FHEM/30_pilight_temp.pm index 8c83c2ecf..b38924f6a 100644 --- a/fhem/FHEM/30_pilight_temp.pm +++ b/fhem/FHEM/30_pilight_temp.pm @@ -1,5 +1,5 @@ ############################################## -# $Id: 30_pilight_temp.pm 0.13 2015-05-17 Risiko $ +# $Id: 30_pilight_temp.pm 0.14 2015-05-30 Risiko $ # # Usage # @@ -11,7 +11,8 @@ # V 0.11 2015-03-29 - FIX: $readingFnAttributes # V 0.12 2015-05-16 - NEW: reading battery # V 0.12 2015-05-16 - NEW: attribut corrTemp, a factor to modify temperatur -# V 0.13 2015-05-17 - NEW: attribut corrHumidity, a factor to modify humidity +# V 0.13 2015-05-17 - NEW: attribut corrHumidity, a factor to modify humidity +# V 0.14 2015-05-30 - FIX: StateFn ############################################## package main; @@ -23,7 +24,6 @@ use JSON; sub pilight_temp_Parse($$); sub pilight_temp_Define($$); -sub pilight_temp_Fingerprint($$); sub pilight_temp_Initialize($) { @@ -32,6 +32,7 @@ sub pilight_temp_Initialize($) $hash->{DefFn} = "pilight_temp_Define"; $hash->{Match} = "^PITEMP"; $hash->{ParseFn} = "pilight_temp_Parse"; + $hash->{StateFn} = "pilight_temp_State"; $hash->{AttrList} = "corrTemp corrHumidity ".$readingFnAttributes; } @@ -62,6 +63,18 @@ sub pilight_temp_Define($$) return undef; } +##################################### +sub pilight_temp_State($$$$) +{ + my ($hash, $time, $name, $val) = @_; + my $me = $hash->{NAME}; + + #$hash->{STATE} wird nur ersetzt, wenn $hash->{STATE} == ??? fhem.pl Z: 2469 + #machen wir es also selbst + $hash->{STATE} = $val if ($name eq "state"); + return undef; +} + ########################################### sub pilight_temp_Parse($$) {