diff --git a/fhem/FHEM/20_FRM_OUT.pm b/fhem/FHEM/20_FRM_OUT.pm
index ac7c5aaa5..fc7e82e3a 100755
--- a/fhem/FHEM/20_FRM_OUT.pm
+++ b/fhem/FHEM/20_FRM_OUT.pm
@@ -114,21 +114,25 @@ FRM_OUT_Set($$$)
my ($hash, $name, $cmd, @a) = @_;
my $value;
my $invert = AttrVal($hash->{NAME},"activeLow", "no");
- if ($cmd eq "on") {
- $value = $invert eq "yes" ? PIN_LOW : PIN_HIGH;
- } elsif ($cmd eq "off") {
- $value = $invert eq "yes" ? PIN_HIGH : PIN_LOW;
- } else {
- my $list = "on off";
- return SetExtensions($hash, $list, $name, $cmd, @a);
- }
- eval {
- FRM_Client_FirmataDevice($hash)->digital_write($hash->{PIN},$value);
- if (AttrVal($hash->{NAME}, "valueMode", "send") ne "receive") {
- main::readingsSingleUpdate($hash,"value",$cmd, 1);
+ if (defined ($cmd)) {
+ if ($cmd eq "on") {
+ $value = $invert eq "yes" ? PIN_LOW : PIN_HIGH;
+ } elsif ($cmd eq "off") {
+ $value = $invert eq "yes" ? PIN_HIGH : PIN_LOW;
+ } else {
+ my $list = "on off";
+ return SetExtensions($hash, $list, $name, $cmd, @a);
}
- };
- return $@;
+ eval {
+ FRM_Client_FirmataDevice($hash)->digital_write($hash->{PIN},$value);
+ if (AttrVal($hash->{NAME}, "valueMode", "send") ne "receive") {
+ main::readingsSingleUpdate($hash,"value",$cmd, 1);
+ }
+ };
+ return $@;
+ } else {
+ return "no command specified";
+ }
}
sub FRM_OUT_State($$$$)
@@ -195,6 +199,8 @@ FRM_OUT_Attr($$$$) {
o create reading "value" in FRM_OUT_Init if missing
02.01.2018 jensb
o new attribute "valueMode" to control how "value" reading is updated
+ 14.01.2018 jensb
+ o fix "uninitialised" when calling FRM_OUT_Set without command
=cut
@@ -207,18 +213,20 @@ FRM_OUT_Attr($$$$) {
FRM_OUT
- represents a pin of an Arduino running Firmata
- configured for digital output.
- Requires a defined FRM-device to work.
+ This module represents a pin of a Firmata device
+ that should be configured as a digital output.
+
+ Requires a defined FRM device to work. The pin must be listed in
+ the internal reading "output_pins"
+ of the FRM device (after connecting to the Firmata device) to be used as digital output.
Define
define <name> FRM_OUT <pin>
Defines the FRM_OUT device. <pin>> is the arduino-pin to use.
-
+
-
Set
@@ -226,12 +234,14 @@ FRM_OUT_Attr($$$$) {
+
+
Get
+
Attributes
@@ -254,17 +264,27 @@ FRM_OUT_Attr($$$$) {
- receive - after receiving
- bidirectional - after sending and receiving
- If you have custom code in your Firmata device that can change the state of an output
- you can enable receive or bidirectional mode. For this to work the default Firmata application code must
- also be modified in function setPinModeCallback: add || mode == OUTPUT
- to the if condition for portConfigInputs[pin / 8] |= (1 << (pin & 7)); to enable
- reporting the output state as if the pin is an input.
eventMap
readingFnAttributes
-
+
+
+
+ Notes
+
+ - attribute stateFormat
+ In most cases it is a good idea to assign "value" to the attribute stateFormat. This will show the state
+ of the pin in the web interface.
+
+ - attribute valueMode
+ For modes "receive<" and "bidirectional" to work the default Firmata application code must
+ be modified in function "setPinModeCallback
":
+ add " || mode == OUTPUT" to the if condition for "portConfigInputs[pin / 8] |= (1 << (pin & 7));
" to enable
+ reporting the output state (as if the pin were an input). This is of interest if you have custom code in your Firmata device that can change
+ the state of an output or you want a feedback from the Firmata device after the output state was changed.
+
-
+
=end html
=cut