From 25fcaa9033a5c6c872fd252e65ed6fe6ad1189d6 Mon Sep 17 00:00:00 2001
From: klausw <>
Date: Mon, 11 Jun 2018 22:00:38 +0000
Subject: [PATCH] 00_Neuron: 1wire sensors integrated, ao repaired
10_NeuronPin: 1wire sensors integrated, more flexibility for new sensors
git-svn-id: https://svn.fhem.de/fhem/trunk@16852 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/00_Neuron.pm | 91 +++++++++++---------
fhem/FHEM/10_NeuronPin.pm | 172 ++++++++++++++++++++++++++++----------
2 files changed, 180 insertions(+), 83 deletions(-)
diff --git a/fhem/FHEM/00_Neuron.pm b/fhem/FHEM/00_Neuron.pm
index cafad0769..06eead262 100644
--- a/fhem/FHEM/00_Neuron.pm
+++ b/fhem/FHEM/00_Neuron.pm
@@ -27,7 +27,7 @@
#{"glob_dev_id": 1, "dev": "wd", "circuit": "1_01", "value": 0, "timeout": 5000, "was_wd_reset": 0, "nv_save": 0},
#{"glob_dev_id": 1, "dev": "neuron","circuit": "1", "ver2": "1.0", "sn": 31, "model": "M503", "board_count": 2},
#{"glob_dev_id": 1, "dev": "uart", "circuit": "1_01", "conf_value": 14, "stopb_modes": ["One", "Two"], "stopb_mode": "One", "speed_modes": ["2400bps", "4800bps", "9600bps", "19200bps", "38400bps", "57600bps", "115200bps"], "parity_modes": ["None", "Odd", "Even"], "parity_mode": "None", "speed_mode": "19200bps"}]#
-#
+#{"vis": "0", "dev": "temp", "circuit": "2620531402000075", "typ": "DS2438", "lost": false, "temp": "24.25", "interval": 15, "vad": "2.52", "humidity": 50.196646084329984, "vdd": "5.34", "time": 1527144341.185264}
#
package main;
@@ -57,14 +57,14 @@ my %setsP = (
sub Neuron_Initialize(@) {
my ($hash) = @_;
- eval "use JSON::XS;";
+ eval "use JSON;";
return "please install JSON::XS" if($@);
eval "use Digest::SHA qw(sha1_hex);";
return "please install Digest::SHA" if($@);
# Provider
$hash->{Clients} = join (':',@clients);
- $hash->{MatchList} = { "NeuronPin" => ".*" };
+ $hash->{MatchList} = { "1:NeuronPin" => ".*" };
$hash->{ReadFn} = "Neuron_Read";
$hash->{ReadyFn} = "Neuron_Ready";
$hash->{WriteFn} = "Neuron_Test";
@@ -78,7 +78,7 @@ sub Neuron_Initialize(@) {
$hash->{NotifyFn} = 'Neuron_Notify';
$hash->{AttrList} = "connection:websockets,polling poll_interval "
."wsFilter:multiple-strict,ai,ao,input,led,relay,wd "
- ."logicalDev:multiple-strict,ai,ao,input,led,relay,wd "
+ ."logicalDev:multiple-strict,ai,ao,input,led,relay,wd,temp "
."$readingFnAttributes";
return undef;
}
@@ -108,21 +108,14 @@ sub Neuron_Set(@) {
my ($hash, $name, $cmd, @args) = @_;
my $sets = $hash->{HELPER}{SETS};
if (index($hash->{HELPER}{SETS}, $cmd) != -1) { # dynamisch erzeugte outputs
- my $circuit = substr($cmd,length($cmd)-4,4);
- my $dev = (split '_', $cmd)[0];
+ my ($dev, $circuit) = (split '_', $cmd, 2);
my $value = (looks_like_number($args[0]) ? $args[0] : $setsP{$args[0]});
-# if ($hash->{HELPER}{WESOCKETS}) {
if ($hash->{HELPER}{wsKey} && DevIo_IsOpen($hash)) {
my $string = Neuron_wsEncode('{"cmd":"set", "dev":"'.$dev.'", "circuit":"'.$circuit.'", "value":"'.$value.'"}');
Neuron_Write($hash,$string);
} else {
Neuron_HTTP($hash,$dev,$circuit,$value);
}
- } elsif ($cmd eq "atest") {
- Log3 $hash, 1, "Testcmd abgesetzt";
- my $testcmd = '{"cmd":"set", "dev":"relay", "circuit":"2_01", "value":"'.$args[0].'"}';
- my $string = Neuron_wsEncode($testcmd);
- Neuron_Write($hash,$string);
} elsif ($cmd eq "postjson") {
my ($dev, $circuit , $value, $state) = @args;
$value = '{"'.$value.'":"'.$state.'"}' if (defined($state));
@@ -136,9 +129,10 @@ sub Neuron_Set(@) {
}
} elsif ($cmd eq "clearreadings") {
fhem("deletereading $hash->{NAME} .*", 1);
- #readingsDelete($hash, ".*");
+ } elsif ($cmd eq "testdispatch") {
+ Neuron_ParseWsResponse($hash, '{"dev":"temp","time":1527316294.23915,"temp":"23.4375","vis":"0.0002441","circuit":"2620531402000075","vad":"2.58","interval":15,"typ":"DS2438","humidity":51.9139754019274,"lost":false,"vdd":"5.34"}');
} else {
- return "Unknown argument $cmd, choose one of clearreadings:noArg websocket:open,close atest postjson " . ($hash->{HELPER}{SETS} ? $hash->{HELPER}{SETS} : '');
+ return "Unknown argument $cmd, choose one of testdispatch clearreadings:noArg websocket:open,close " . ($hash->{HELPER}{SETS} ? $hash->{HELPER}{SETS} : '');
}
return undef;
}
@@ -151,17 +145,17 @@ sub Neuron_Get(@) {
Neuron_ReadingstoSets($hash);
} elsif ($cmd eq "value") {
if (index($hash->{HELPER}{GETS}, $args[0]) != -1) {
- my @line = (split("_", $args[0],2));
+ my ($dev, $circuit) = (split '_', $args[0], 2);
$hash->{HELPER}{CLVAL} = $hash->{CL};
- Neuron_HTTP($hash,$line[0],$line[1]);
+ Neuron_HTTP($hash, $dev, $circuit);
} else {
return "Unknown Port $args[0], choose one of ".$hash->{HELPER}{GETS};
}
} elsif ($cmd eq "conf") {
if (index($hash->{HELPER}{GETS}, $args[0]) != -1) {
- my @line = (split("_", $args[0],2));
+ my ($dev, $circuit) = (split '_', $args[0], 2);
$hash->{HELPER}{CLCONF} = $hash->{CL};
- Neuron_HTTP($hash,$line[0],$line[1]);
+ Neuron_HTTP($hash, $dev, $circuit);
} else {
return "Unknown Port $args[0], choose one of ".$hash->{HELPER}{GETS};
}
@@ -224,8 +218,6 @@ sub Neuron_Poll($) {
}
}
-
-
sub Neuron_Notify(@) {
my ($hash, $nhash) = @_;
my $name = $hash->{NAME};
@@ -303,7 +295,11 @@ sub Neuron_HTTP(@){
#my $url="http://$hash->{HOST}:$hash->{PORT}/json/$dev/$circuit";
my $url="http://$hash->{HOST}:$hash->{PORT}/".(defined($data) ? "json" : "rest")."/$dev/$circuit";
if (defined($data) && index($data, ':') == -1) {
- $data = '{"value":"'.$data.'"}';
+ unless ($dev eq 'ao') {
+ $data = '{"value":"'.$data.'"}';
+ } else {
+ $data = '{"value":'.$data.'}'; # Sonderlösung, da der Analoge Ausgang den Wert nur ohne Hochkommas akzeptiert
+ }
}
Log3($hash, 3,"$hash->{TYPE} ($hash->{NAME}): sending ".($data ? "POST ($data)" : "GET")." request to url $url");
my $param= {
@@ -363,7 +359,7 @@ sub Neuron_callback(@) {
sub Neuron_ParseSingle(@){
my ($hash, $data)=@_;
my $result;
- Log3($hash, 4, "$hash->{TYPE} ($hash->{NAME}) parse data:\n$data");
+ Log3($hash, 4, "$hash->{TYPE} ($hash->{NAME}) parse data:\n".$data);
eval {
$result = JSON->new->utf8(1)->decode($data);
#Log3 ($hash, 1, "$hash->{TYPE} ($hash->{NAME}) single result->status=".ref($result));
@@ -390,10 +386,16 @@ sub Neuron_ParseSingle(@){
} else {
$result = $result;
}
- readingsSingleUpdate($hash,$result->{dev}."_".$result->{circuit},$result->{value},1);
- asyncOutput($hash->{HELPER}{CLVAL}, $result->{value}) if $hash->{HELPER}{CLVAL};
- delete $hash->{HELPER}{CLVAL};
- Dispatch($hash, $result, (%addvals ? \%addvals : undef)) if index(AttrVal($hash->{NAME}, 'logicalDev', 'relay,input,led,ao') , $result->{dev}) != -1;
+
+ if (ref $result eq 'HASH') {
+ readingsSingleUpdate($hash,$result->{dev}."_".$result->{circuit},$result->{value},1);
+ asyncOutput($hash->{HELPER}{CLVAL}, $result->{value}) if $hash->{HELPER}{CLVAL};
+ delete $hash->{HELPER}{CLVAL};
+ Dispatch($hash, $result, (%addvals ? \%addvals : undef)) if index(AttrVal($hash->{NAME}, 'logicalDev', 'relay,input,led,ao,temp') , $result->{dev}) != -1;
+ } else {
+ Log3 ($hash, 3, "$hash->{TYPE} ($hash->{NAME}) http response not JSON: ".$result);
+ }
+
}
delete $hash->{HELPER}{CLSET};
return $result;
@@ -432,7 +434,8 @@ sub Neuron_ParseAll(@){
}
$i++;
} else {
- my $value = $subdev->{value};
+ my $value = $subdev->{temp}; # Temperaturwert nehmen (!wire Geräte haben kein value?)
+ $value = $subdev->{value};
#$value = $rsetsP{$value} if ($subdev->{dev} eq 'input' || $subdev->{dev} eq 'relay' || $subdev->{dev} eq 'led'); # on,off anstelle von 1,0
readingsBulkUpdateIfChanged($hash,$subdev->{dev}."_".$subdev->{circuit},$value) if defined($value);
Dispatch($hash, $subdev, (%addvals ? \%addvals : undef)) if index(AttrVal($hash->{NAME}, 'logicalDev', 'relay,input,led,ao'), $subdev->{dev}) != -1;
@@ -466,18 +469,30 @@ sub Neuron_ParseWsResponse($$){
} else {
#my ($subdevs) = $result->{data};
readingsBeginUpdate($hash);
- foreach (@{$result}){
- (my $subdev)=$_;
- my $value = $subdev->{value};
- #$value = $rsetsP{$value} if ($subdev->{dev} eq 'input' || $subdev->{dev} eq 'relay' || $subdev->{dev} eq 'led'); # on,off anstelle von 1,0
- readingsBulkUpdate($hash,$subdev->{dev}."_".$subdev->{circuit},$value);
- Dispatch($hash, $subdev, undef) if index(AttrVal($hash->{NAME}, 'logicalDev', 'relay,input,led,ao') , $subdev->{dev}) != -1;
-################################
+ if (ref $result eq 'ARRAY') { #[{"circuit": "1_01", "value": 0, ...}]
+ foreach (@{$result}){
+ Neuron_DecodeWsJSON($hash,$_);
+ }
+ } elsif (ref $result eq 'HASH') { #{"circuit": "1_01", "value": 0, ...}
+ Neuron_DecodeWsJSON($hash,$result);
}
readingsEndUpdate($hash,1);
}
return undef
}
+
+sub Neuron_DecodeWsJSON($$){
+ my ($hash, $dev)=@_;
+ eval {
+ readingsBulkUpdate($hash,$dev->{dev}."_".$dev->{circuit},$dev->{value});
+ Dispatch($hash, $dev, undef) if index(AttrVal($hash->{NAME}, 'logicalDev', 'relay,input,led,ao') , $dev->{dev}) != -1;
+ };
+ if ($@) {
+ Log3 ($hash, 3, "$hash->{TYPE} ($hash->{NAME}): error decoding JSON $@\nData:\n$dev");
+ }
+ return undef
+}
+
sub Neuron_ReadingstoSets($){
my ($hash)=@_;
my $sets;
@@ -577,7 +592,7 @@ sub Neuron_Read($) {
Log3 $name, 5, "$hash->{TYPE} ($name) - ReadFn started";
########### 1
- my $buf = DevIo_SimpleRead($hash);
+ $buf = DevIo_SimpleRead($hash);
########### 2
# my $len = sysread($hash->{CD},$buf,10240);
# if( !defined($len) or !$len ) {
@@ -633,9 +648,6 @@ sub Neuron_wsHandshake($) {
# Log3 $name, 4, "$hash->{TYPE} Websocket ($name) - start WS hearbeat timer";
# Neuron_HbTimer($hash);
-
-# Log3 $name, 4, "$hash->{TYPE} Websocket ($name) - start WS initialisation routine";
-# Neuron_WsInit($hash);
return undef;
}
@@ -674,13 +686,10 @@ sub Neuron_wsCheckHandshake($$) {
sub Neuron_wsSetFilter($;$) {
my ($hash,$val) = @_;
-# if ($hash->{HELPER}{WESOCKETS}) {
if ($hash->{HELPER}{wsKey} && DevIo_IsOpen($hash)) {
my $wsFilter = $val || AttrVal($hash->{NAME}, 'wsFilter', 'all');
my $filter = '{"cmd":"filter","devices":["'. join( '","', split(',', $wsFilter ) ) .'"]}';
- #Log3 $hash, 1, "Filter: $filter";
my $string = Neuron_wsEncode($filter);
- #Log3 $hash, 1, "Filter encoded: $string\nMAY NOT WORK";
Neuron_Write($hash,$string);
}
}
diff --git a/fhem/FHEM/10_NeuronPin.pm b/fhem/FHEM/10_NeuronPin.pm
index 9169e074a..f002ce925 100644
--- a/fhem/FHEM/10_NeuronPin.pm
+++ b/fhem/FHEM/10_NeuronPin.pm
@@ -2,6 +2,7 @@
# $Id$
# todo:
# holen von status nach sets nicht wenn ws verbindung
+# ao funktioniert nicht
package main;
@@ -25,13 +26,15 @@ sub NeuronPin_Initialize($) {
$hash->{SetFn} = 'NeuronPin_Set';
$hash->{GetFn} = 'NeuronPin_Get';
$hash->{UndefFn} = 'NeuronPin_Undef';
- $hash->{AttrList} = 'IODev do_not_notify:0,1 showtime:0,1 ' .
- 'poll_interval:1,2,5,10,20,30 restoreOnStartup:on,off,last aomax ' .
+ $hash->{AttrList} = 'IODev do_not_notify:0,1 showtime:0,1 '.
+ 'disable:0,1 disabledForIntervals'.
+ 'poll_interval:1,2,5,10,20,30 restoreOnStartup:on,off,last '.
+ 'aomax skipreadings ownsets autoalias '.
$readingFnAttributes;
$hash->{Match} = ".*";
$hash->{ParseFn} = "NeuronPin_Parse";
# $hash->{DbLog_splitFn} = "NeuronPin_DbLog_splitFn";
- $hash->{AutoCreate} = {"NeuronPin_.*" => { ATTR => "room:Neuron", } };
+ $hash->{AutoCreate} = {"NeuronPin_.*" => { ATTR => "room:Neuron" } };
$hash->{noAutocreatedFilelog} = 1;
}
@@ -40,7 +43,7 @@ sub NeuronPin_Define($$) {
my @a = split('[ \t][ \t]*', $def);
# hier fehlt noch Überprüfung der Attribute
$modules{NeuronPin}{defptr}{$a[2]." ".$a[3]} = $hash;
- return "$hash->{NAME} Pintype not valid" unless ($a[2] =~ /^(input|relay|ai|ao|led)$/ );
+ return "$hash->{NAME} Pintype not valid" unless ($a[2] =~ /^(input|relay|ai|ao|led|temp|wd)$/ );
$hash->{DEV} = $a[2];
#return "$hash->{NAME} Circuit Name not valid" unless ($a[3] =~ /^[1-9]_((0[1-9])|[1-9][0-9])$/ );
$hash->{CIRCUIT} = $a[3];
@@ -69,6 +72,7 @@ sub NeuronPin_Init($$) {
NeuronPin_Set($hash,$hash->{NAME}, (looks_like_number($val) ? dim $val : $val));
}
} else {
+ return if(IsDisabled($hash->{NAME}));
IOWrite($hash, split " ", $hash->{DEF});
}
$hash->{STATE} = ReadingsVal($hash->{NAME},'state','') if ReadingsVal($hash->{NAME},'state','');
@@ -109,22 +113,43 @@ sub NeuronPin_Parse ($$) {
Log3 (undef, 4, "NeuronPin_Parse von $io_hash->{NAME} empfangen:\n" . encode_json $message);
if (my $hash = $modules{NeuronPin}{defptr}{$port}) {
my $value = $message->{value};
- $hash->{RELAY_TYPE} = $message->{relay_type} if $message->{relay_type};
+ # zusätzliche Daten als Internal
+ $hash->{RELAY_TYPE} = $message->{relay_type} if $message->{relay_type};
+ $hash->{TYP} = $message->{typ} if defined $message->{typ};
+ $hash->{GLOB_DEV_ID} = $message->{glob_dev_id} if defined $message->{glob_dev_id};
$value = $rsets{$value} if ($message->{dev} eq 'input' || $message->{dev} eq 'relay' || $message->{dev} eq 'led');
readingsBeginUpdate($hash);
readingsBulkUpdate($hash,"state",$value);
- my @readings = ("mode","unit","range","debounce","counter","counter_mode","alias","pwm_freq","pwm_duty");
- foreach (@readings){
-
- #Log3 (undef, 1, "NeuronPin_Parse1 $_ exists") if exists($message->{$_});
- #Log3 (undef, 1, "NeuronPin_Parse2 $_ defined") if defined($message->{$_});
- #Log3 (undef, 1, "NeuronPin_Parse3 $_ ist $message->{$_}");
-
-
- if (exists($message->{$_})) {
- readingsBulkUpdate($hash,$_,$message->{$_});
- } else {
- readingsDelete($hash, $_);
+ readingsBulkUpdate($hash,"dim",$value) if $message->{dev} eq 'ao';
+
+ # my @readings = ("mode","unit","range","debounce","counter","counter_mode","alias","pwm_freq","pwm_duty","temp","humidity","vdd","vad");
+ # foreach (@readings){
+ # if (exists($message->{$_})) {
+ # readingsBulkUpdate($hash,"Z_".$_,$message->{$_});
+ # } else {
+ # readingsDelete($hash, "Z_".$_);
+ # }
+ # }
+
+ my @skipreadings = split(',', AttrVal($hash->{NAME}, 'skipreadings', "relay_type,typ,dev,circuit,glob_dev_id,value,pending") );
+ foreach (keys %{$hash->{READINGS}}) {
+ #next if substr($_,0,2) eq "Z_";
+ readingsDelete($hash, $_) unless exists($message->{$_}) || $_ eq "state" || $_ eq ".conf" || $_ eq "dim";
+ }
+ foreach my $key (keys %$message){
+ if (ref $message->{$key} eq 'ARRAY') { # alle Arrays überspringen
+ } elsif (grep( /^$key/, @skipreadings )) { # Wer soll nicht als reading angelegt werden
+ readingsDelete($hash, $key);
+ } elsif ($key eq 'alias') { # al_ am Anfang von alias weg
+ my $alias = (split '_', $message->{$key})[1];
+ readingsBulkUpdate($hash,$key,$alias);
+ # autocreate alias attribute
+ if (AttrVal($hash->{NAME}, 'alias', '?') ne $alias && defined AttrVal($hash->{NAME}, 'autoalias', '')) {
+ my $msg = CommandAttr(undef, $hash->{NAME} . " alias $alias");
+ Log3 ($hash, 2, "$hash->{TYPE} ($hash->{NAME}): Error creating alias $msg") if ($msg);
+ }
+ }else {
+ readingsBulkUpdate($hash,$key,$message->{$key});
}
}
delete $message->{value};
@@ -149,6 +174,7 @@ sub NeuronPin_Parse ($$) {
sub NeuronPin_RereadPin($) {
my ($hash) = @_;
+ return if(IsDisabled($hash->{NAME}));
IOWrite( $hash, split(" ", $hash->{DEF}) );
}
@@ -199,23 +225,45 @@ sub NeuronPin_CreateSets($) {
} else {
eval {
delete $hash->{HELPER}{SETS};
- my @stypes = ("modes","range_modes","counter_modes");
- my @stype = ("mode","range_mode","counter_mode");
- foreach my $i (0 .. $#stypes) {
- #if ($result->{$stypes[$i]} && keys %{$result->{$stypes[$i]}} && scalar keys %{$result->{$stypes[$i]}} > 1) {
- if ($result->{$stypes[$i]} && scalar keys @{$result->{$stypes[$i]}} > 1) {
- foreach (@{$result->{$stypes[$i]}}){
- $hash->{HELPER}{SETS}{$stype[$i]}{$_} = 1;
+ foreach my $key (keys %$result){
+ if (ref $result->{$key} eq 'ARRAY') { # wenn Array dann zur set->Dropdonwmenüerzeugung verwenden
+ if ( exists($result->{substr($key,0,-1)}) ) { # z.B. zu "modes":["Simple","PWM"] passt "mode":"Simple"
+ if ($result->{$key} && scalar keys @{$result->{$key}} > 1) { # und mehr als eine Option verfügbar
+ foreach (@{$result->{$key}}){
+ $hash->{HELPER}{SETS}{substr($key,0,-1)}{$_} = 1;
+ }
+ }
+ } elsif (exists($result->{(split "_", $key)[0]})) { # z.B. "range_modes":["10.0","1.0"]
+ if ($result->{$key} && scalar keys @{$result->{$key}} > 1) { # und mehr als eine Option verfügbar
+ foreach (@{$result->{$key}}){
+ $hash->{HELPER}{SETS}{(split "_", $key)[0]}{$_} = 1;
+ }
+ }
+ } else {
+ Log3 ($hash, 5, "NeuronPin_CreateSets unbekanntes Array: $key");
}
}
}
- #foreach ("debounce","counter")
- $hash->{HELPER}{SETS}{debounce} = "free" if $result->{debounce};
- $hash->{HELPER}{SETS}{counter} = "free" if exists($result->{counter});
- $hash->{HELPER}{SETS}{pwm_duty} = "slider,0,0.1,100" if exists($result->{pwm_duty});
- $hash->{HELPER}{SETS}{pwm_freq} = "free" if exists($result->{pwm_freq});
+ # my @stypes = ("modes","range_modes","counter_modes");
+ # my @stype = ("mode","range_mode","counter_mode");
+ # foreach my $i (0 .. $#stypes) {
+ # if ($result->{$stypes[$i]} && scalar keys @{$result->{$stypes[$i]}} > 1) {
+ # foreach (@{$result->{$stypes[$i]}}){
+ # $hash->{HELPER}{SETS}{$stype[$i]}{$_} = 1;
+ # }
+ # }
+ # }
+
+ my @freesets = split(';', AttrVal($hash->{NAME}, 'ownsets', "debounce;counter;interval;pwm_freq;pwm_duty:slider,0,0.1,100") );
+ foreach (@freesets) {
+ my $args = (defined((split ':', $_)[1]) ? (split ':', $_)[1] : "free");
+ my $setname = (split ':', $_)[0];
+ $hash->{HELPER}{SETS}{$setname} = $args if exists($result->{$setname});
+ #$hash->{HELPER}{SETS}{$_} = "free" if exists($result->{$_});
+ }
+ #$hash->{HELPER}{SETS}{pwm_duty} = "slider,0,0.1,100" if exists($result->{pwm_duty});
$hash->{HELPER}{SETS}{alias} = "free";
-
+
if ($hash->{DEV} eq 'led' || $hash->{DEV} eq 'relay') {
$hash->{HELPER}{SETS}{on} = "noArg";
$hash->{HELPER}{SETS}{off} = "noArg";
@@ -224,12 +272,7 @@ sub NeuronPin_CreateSets($) {
$hash->{HELPER}{SETS}{off} = "noArg";
$hash->{HELPER}{SETS}{dim} = "slider,0,0.1," . AttrVal($hash->{NAME},"aomax",'10');
}
- #my $str = join(" ", map { "$_:$hash->{HELPER}{SETS}{$_}" } keys %$hash->{HELPER}{SETS});
-# my $str = join(" ", map { "$_:".( ref($hash->{HELPER}{SETS}{$_}) eq 'HASH' ?
-# join (",", sort keys %{$hash->{HELPER}{SETS}{$_}} ) :
-# "$hash->{HELPER}{SETS}{$_}")
-# } keys %{$hash->{HELPER}{SETS}}
-# );
+
my $str = join(" ", map { "$_".( ref($hash->{HELPER}{SETS}{$_}) eq 'HASH' ?
':' . join (",", sort keys %{$hash->{HELPER}{SETS}{$_}} ) :
($hash->{HELPER}{SETS}{$_} eq "free" ? '' : ':'.$hash->{HELPER}{SETS}{$_}))
@@ -261,6 +304,7 @@ sub NeuronPin_Set($@) {
return undef
} elsif ($cmd eq "dim") {
$arguments[2] = $arg;
+ $hash->{HELPER}{SETREQ} = 1;
} elsif ( $hash->{HELPER}{SETS}{$cmd} eq "noArg") {
$arguments[2] = $sets{$cmd};
if ($hash->{DEV} eq 'ao') {
@@ -271,27 +315,29 @@ sub NeuronPin_Set($@) {
}
}
$hash->{HELPER}{SETREQ} = 1;
-# } elsif (defined($hash->{HELPER}{SETS}{$cmd}{$arg})) {
-# $arguments[2] = $cmd;
-# $arguments[3] = $arg;
+ } elsif ($cmd eq "alias") {
+ $arguments[2] = $cmd;
+ $arguments[3] = "al_".$arg;
} else {
$arguments[2] = $cmd;
$arguments[3] = $arg;
}
#$hash->{HELPER}{SETREQ} = 1;
#my @arguments = (split(" ",$hash->{DEF}),$sets{$cmd});
+ return if(IsDisabled($hash->{NAME}));
IOWrite($hash, @arguments);
-
}
sub NeuronPin_Get($@) {
my ($hash, $name, $cmd, @args) = @_;
if ($cmd && $cmd eq "refresh") {
my @arguments = (split " ", $hash->{DEF});
+ return if(IsDisabled($hash->{NAME}));
IOWrite($hash, @arguments);
} elsif ($cmd && $cmd eq "config") {
my @arguments = (split " ", $hash->{DEF});
$hash->{HELPER}{CL} = $hash->{CL};
+ return if(IsDisabled($hash->{NAME}));
IOWrite($hash, @arguments);
} else {
return 'Unknown argument ' . $cmd . ', choose one of refresh:noArg config:noArg'
@@ -378,7 +424,7 @@ sub NeuronPin_Undef($$) {
-
+
Attributes