diff --git a/fhem/FHEM/98_EDIPLUG.pm b/fhem/FHEM/98_EDIPLUG.pm index 5223cfdfe..57c6771a0 100644 --- a/fhem/FHEM/98_EDIPLUG.pm +++ b/fhem/FHEM/98_EDIPLUG.pm @@ -1,6 +1,6 @@ ################################################################ # -# $Id: $ +# $Id:$ # # (c) 2014 Copyright: Wzut based on 98_EDIPLUG.pm tre (ternst) # All rights reserved @@ -26,6 +26,7 @@ # 2014-12-08 add schedule and list (Wzut) # 2014-12-09 add dellist (Wzut) # 2015-02-21 first svn version (Wzut) +# 2015-02-22 add attr read-only, fix attr interval, update command.ref # ################################################################ @@ -90,7 +91,7 @@ sub EDIPLUG_Initialize($) $hash->{SetFn} = "EDIPLUG_Set"; $hash->{GetFn} = "EDIPLUG_Get"; $hash->{AttrFn} = "EDIPLUG_Attr"; - $hash->{AttrList} = "interval timeout disable:0,1 model:SP1101W,SP2101W,unknow interval user password ".$readingFnAttributes; + $hash->{AttrList} = "interval timeout disable:0,1 model:SP1101W,SP2101W,unknow read-only:0,1 user password ".$readingFnAttributes; } @@ -199,7 +200,7 @@ sub EDIPLUG_Read($$$) readingsBeginUpdate($hash); - # EDIPLUGs geben ein nichtgueltigen Zeichensatz zurueck ( UTF8 instead utf-8 ) + # EDIPLUGs geben ein nicht gueltigen Zeichensatz zurueck ( UTF8 instead utf-8 ) $buffer =~s/UTF8/utf-8/g; my $xmlres = XMLin($buffer); @@ -244,8 +245,8 @@ sub EDIPLUG_Read($$$) readingsBulkUpdate($hash, "power_day", $xmlres->{CMD}->{NOW_POWER}->{'Device.System.Power.NowEnergy.Day'}." kW/h"); readingsBulkUpdate($hash, "power_week", $xmlres->{CMD}->{NOW_POWER}->{'Device.System.Power.NowEnergy.Week'}." kW/h"); readingsBulkUpdate($hash, "power_month", $xmlres->{CMD}->{NOW_POWER}->{'Device.System.Power.NowEnergy.Month'}." kW/h"); - - $state = $hash->{POWER}." / ".$hash->{helper}{power}. " W / ".$hash->{helper}{current}." A"; + + $state = ($hash->{POWER} ne "OFF") ? $hash->{POWER}." / ".$hash->{helper}{power}. " W / ".$hash->{helper}{current}." A" : $hash->{POWER}; } @@ -360,15 +361,17 @@ sub EDIPLUG_Attr(@) sub EDIPLUG_Set($@) { my ($hash, $name , @a) = @_; - - return "set $name needs at least one argument" if(int(@a) < 1); - my $cmd = $a[0]; + + return "set $name needs at least one argument" if(int(@a) < 1); + return ($cmd eq "?") ? undef : "no set commands are allowed on a read-only device !" if ($attr{$name}{'read-only'} eq "1"); + my $list = "on off list addlist delete:0,1,2,3,4,5,6 dellist day clear_error"; - + return SetExtensions($hash, $list, $name, @a) if( $cmd eq "?" ); return SetExtensions($hash, $list, $name, @a) if( !grep( $_ =~ /^$cmd($|:)/, split( ' ', $list))); + $hash->{timeout} = AttrVal($name, "timeout", 2); my $oldcmd = $hash->{LASTCMD}; $hash->{LASTCMD}=""; @@ -599,37 +602,36 @@ requires XML:Simple -> sudo apt-get install libxml-simple-perl
- Set + Set + Get Attributes +
  • interval => polling interval (default 60)
  • +
  • timeout => max. time to wait in seconds (default 2)
  • +
  • read-only => only read (Get) from device (default 0)
  • +
  • user => username (default admin)
  • +
  • password => password (default 1234)
  • +
    Readings