diff --git a/fhem/CHANGED b/fhem/CHANGED index 4baaa5d9b..0c0641e50 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. + - feature: 72_TA_CMI_JSON: added set fixwertImpuls and setList - feature: 72_TA_CMI_JSON: added set fixwertAnalog fixwertDigital - change: 70_ZoneMinder: made Crypt dependency for v 1.30 optional - change: 48_BlinkCamera: Change to new Blink login API / add resetUniqueID diff --git a/fhem/FHEM/72_TA_CMI_JSON.pm b/fhem/FHEM/72_TA_CMI_JSON.pm index 695ad6ca4..619e473c6 100755 --- a/fhem/FHEM/72_TA_CMI_JSON.pm +++ b/fhem/FHEM/72_TA_CMI_JSON.pm @@ -51,7 +51,11 @@ sub TA_CMI_JSON_Initialize { # $hash->{FW_detailFn} = "TA_CMI_JSON::DetailFn"; # $hash->{FW_directNotify} = "TA_CMI_JSON::DirectNotify"; - $hash->{AttrList} = "username password outputStatesInterval interval readingNamesInputs readingNamesOutputs readingNamesDL-Bus readingNamesLoggingAnalog readingNamesLoggingDigital includePrettyReadings:0,1 includeUnitReadings:0,1 prettyOutputStates:0,1 " . $readingFnAttributes; + $hash->{AttrList} = "username password outputStatesInterval interval readingNamesInputs:textField-long ". + "readingNamesOutputs:textField-long readingNamesDL-Bus:textField-long ". + "readingNamesLoggingAnalog:textField-long readingNamesLoggingDigital:textField-long ". + "includePrettyReadings:0,1 includeUnitReadings:0,1 prettyOutputStates:0,1 setList:textField-long ". + $readingFnAttributes; Log3 '', 3, "TA_CMI_JSON - Initialize done ..."; } @@ -115,6 +119,12 @@ my %outputStates = ( 7 => 'Manual-On' ); +my %fixwertTypes = ( + 'fixwertAnalog' => 'D1', + 'fixwertDigital' => '11', + 'fixwertImpuls' => '1f' +); + ## Import der FHEM Funktionen BEGIN { GP_Import(qw( @@ -372,29 +382,60 @@ sub extractReadings($$$$) { return undef; } -sub Set($$$@) { +sub Set { my ( $hash, $name, $opt, @arg) = @_; Log3 $name, 5, "TA_CMI_JSON ($name) - Set: $name $opt ".join(' ', @arg); - if ($opt eq 'fixwertAnalog' || $opt eq 'fixwertDigital') { - + my ($sets, $cmdList) = getCmdHash(AttrVal($name, 'setList', '')); + + if ($opt eq 'fixwertAnalog' || $opt eq 'fixwertDigital' || $opt eq 'fixwertImpuls') { my $index = $arg[0]; my $value = $arg[1]; - my $type; - if ($opt eq 'fixwertAnalog') { - $type = 'D1'; - } else { - $type = '1f'; - } + my $type = $fixwertTypes{$opt}; FixwertChangeRequest($hash, $index, $value, $type); return undef; + } else { + + my $command = $sets->{$opt}; + + if (defined $command) { +# Log3 $name, 5, "TA_CMI_JSON ($name) - command: $command"; + my ($cmd, $index, $value) = split(' ', $command); + +# Log3 $name, 5, "TA_CMI_JSON ($name) - cmd: $cmd"; +# Log3 $name, 5, "TA_CMI_JSON ($name) - index: $index"; +# Log3 $name, 5, "TA_CMI_JSON ($name) - value: $value"; +# Log3 $name, 5, "TA_CMI_JSON ($name) - arg: ".join(' ', @arg); + + unshift @arg, $value if (defined $value); + unshift @arg, $index if (defined $index); + +# Log3 $name, 5, "TA_CMI_JSON ($name) - arg2: ".join(' ', @arg); + return Set($hash, $name, $cmd, @arg); + } } - return 'fixwertAnalog fixwertDigital'; + return "Unknown argument $opt, choose one of fixwertAnalog fixwertDigital fixwertImpuls $cmdList"; +} + +# credits for this method go to MQTT2_DEVICE +sub getCmdHash($) +{ + my ($list) = @_; + my (%h, @cmd); + map { + my ($k,$v) = split(" ",$_,2); + push @cmd, $k; + $k =~ s/:.*//; # potential arguments + $h{$k} = $v; + } + grep /./, + split("\n", $list); + return (\%h, join(" ",@cmd)); } sub FixwertChangeRequest($$$$) { @@ -584,10 +625,13 @@ sub ParseOutputStateResponse($$$) { Set
fixwertAnalog
set cmiNode fixwertAnalog <index> <value>
set cmiNode fixwertAnalog 3 64.0
set cmiNode fixwertAnalog <index> <value>
set cmiNode fixwertAnalog 3 64.0
will set Fixwert 3 to 64.0fixwertDigital
set cmiNode fixwertDigital <index> <value>
set cmiNode fixwertDigital 2 1
set cmiNode fixwertDigital <index> <value>
set cmiNode fixwertDigital 2 1
will set Fixwert 2 to On/Yes.fixwertImpuls
set cmiNode fixwertImpuls <index> <value>
set cmiNode fixwertImpuls 3 1
will send an On-impulse to Fixwert 3.interval
outputStatesInterval
prettyOutputStates [0:1]
setList
Light_on:noArg fixwertImpuls 3 1
Water_Temperature fixwertAnalog 7
set cmiNode Water_Temperature 55.0
.
+ username
password
interval
outputStatesInterval
prettyOutputStates [0:1]
setList
Licht_ein:noArg fixwertImpuls 3 1
Wasser_Temperatur fixwertAnalog 7
set cmiNode Wasser_Temperatur 55.0
verwendet werden.
+ username
password