added readonly attribute

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@3836 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme1968
2013-09-02 11:19:35 +00:00
parent d1a38a88d1
commit 0054bfc3f3

View File

@@ -116,10 +116,10 @@ PCA301_Set($@)
$cmd = ReadingsVal($name,"state","on") eq "off" ? "on" :"off";
}
if( $cmd eq 'off' ) {
if( !$readonly && $cmd eq 'off' ) {
readingsSingleUpdate($hash, "state", "set-$cmd", 1);
PCA301_Send( $hash, 0x05, 0x00 );
} elsif( $cmd eq 'on' ) {
} elsif( !$readonly && $cmd eq 'on' ) {
readingsSingleUpdate($hash, "state", "set-$cmd", 1);
PCA301_Send( $hash, 0x05, 0x01 );
} elsif( $cmd eq 'statusRequest' ) {
@@ -208,11 +208,13 @@ PCA301_Parse($$)
$rhash->{PCA301_lastRcv} = TimeNow();
my $readonly = AttrVal($name, "readonly", "0" );
if( $cmd eq 0x04 ) {
my $state = $data==0x00?"off":"on";
my $power = ($bytes[6]*256 + $bytes[7]) / 10.0;
my $consumption = ($bytes[8]*256 + $bytes[9]) / 100.0;
$state = $power if( AttrVal($rname, "readonly", "0" ) ne "0" );
$state = $power if( !$readonly );
readingsBeginUpdate($rhash);
readingsBulkUpdate($rhash, "power", $power) if( $data != 0x00 || ReadingsVal($rname,"power","") != $power );
readingsBulkUpdate($rhash, "consumption", $consumption) if( ReadingsVal($rname,"consumption","") != $consumption );