diff --git a/fhem/FHEM/10_FRM.pm b/fhem/FHEM/10_FRM.pm
index 5ac6c46d3..67859627e 100755
--- a/fhem/FHEM/10_FRM.pm
+++ b/fhem/FHEM/10_FRM.pm
@@ -75,6 +75,7 @@ sub FRM_Define($$) {
$hash->{DeviceName} = $dev;
my $ret = DevIo_OpenDev($hash, 0, "FRM_DoInit");
+ return $ret if (defined $ret and $ret eq "");
$hash->{STATE}="Initialized";
return $ret;
}
diff --git a/fhem/FHEM/20_FRM_LCD.pm b/fhem/FHEM/20_FRM_LCD.pm
index f95699e61..3bafc42b2 100755
--- a/fhem/FHEM/20_FRM_LCD.pm
+++ b/fhem/FHEM/20_FRM_LCD.pm
@@ -32,7 +32,7 @@ FRM_LCD_Initialize($)
$hash->{AttrFn} = "FRM_LCD_Attr";
$hash->{StateFn} = "FRM_LCD_State";
- $hash->{AttrList} = "IODev model backLight:on,off blink:on,off autoClear:on,off autoBreak:on,off loglevel:0,1,2,3,4,5 $main::readingFnAttributes";
+ $hash->{AttrList} = "restoreOnReconnect:on,off restoreOnStartup:on,off IODev model backLight:on,off blink:on,off autoClear:on,off autoBreak:on,off loglevel:0,1,2,3,4,5 $main::readingFnAttributes";
# autoScroll:on,off direction:leftToRight,rightToLeft do not work reliably
}
@@ -52,21 +52,26 @@ FRM_LCD_Init($)
return "no IODev set" unless defined $hash->{IODev};
return "no FirmataDevice assigned to ".$hash->{IODev}->{NAME} unless defined $hash->{IODev}->{FirmataDevice};
+ my $name = $hash->{NAME};
if (($hash->{type} eq "i2c") and defined $hash->{address}) {
require LiquidCrystal_I2C;
my $lcd = LiquidCrystal_I2C->new($hash->{address},$hash->{sizex},$hash->{sizey});
$lcd->attach($hash->{IODev}->{FirmataDevice});
$lcd->init();
$hash->{lcd} = $lcd;
- my $name = $hash->{NAME};
-# FRM_LCD_Apply_Attribute($name,"backlight");
+ FRM_LCD_Apply_Attribute($name,"backLight");
# FRM_LCD_Apply_Attribute($name,"autoscroll");
# FRM_LCD_Apply_Attribute($name,"direction");
-# FRM_LCD_Apply_Attribute($name,"blink");
- if (! (defined AttrVal($name,"stateFormat",undef))) {
- $main::attr{$name}{"stateFormat"} = "text";
- }
+ FRM_LCD_Apply_Attribute($name,"blink");
}
+ if (! (defined AttrVal($name,"stateFormat",undef))) {
+ $main::attr{$name}{"stateFormat"} = "text";
+ }
+ my $value = ReadingsVal($name,"text",undef);
+ if (defined $value and AttrVal($hash->{NAME},"restoreOnReconnect","on") eq "on") {
+ FRM_LCD_Set($hash,$name,"text",$value);
+ }
+
return undef;
}
@@ -118,8 +123,6 @@ sub FRM_LCD_Apply_Attribute {
last;
};
}
- } else {
- main::Log (3, "no lcd found");
}
}
@@ -131,6 +134,7 @@ sub FRM_LCD_Set(@) {
return "Unknown argument $a[1], choose one of " . join(" ", sort keys %sets)
if(!defined($sets{$command}));
my $lcd = $hash->{lcd};
+ return unless defined $lcd;
COMMAND_HANDLER: {
$command eq "text" and do {
if (AttrVal($hash->{NAME},"autoClear","on") eq "on") {
@@ -195,7 +199,9 @@ sub FRM_LCD_State($$$$)
STATEHANDLER: {
$sname eq "text" and do {
- FRM_LCD_Set($hash,$hash->{NAME},$sname,$sval);
+ if (AttrVal($hash->{NAME},"restoreOnStartup","on") eq "on") {
+ FRM_LCD_Set($hash,$hash->{NAME},$sname,$sval);
+ }
last;
}
}
@@ -212,39 +218,48 @@ FRM_LCD_Undef($$)
=pod
=begin html
-
-
FRM_I2C
+
+FRM_LCD
- represents an integrated curcuit connected to the i2c-pins of an Arduino
- running Firmata
+ drives LiquidCrystal Displays (LCD) that are connected to Firmata (via I2C).
+ Supported are Displays that use a PCF8574T as I2C Bridge (as found on eBay when searching for
+ 'LCD' and 'I2C'). Tested is the 1602 type (16 characters, 2 Lines), the 2004 type (and other cheap chinise-made
+ I2C-LCDs for Arduino) ship with the same library, so they should work as well.
+ See http://arduino.cc/en/Tutorial/LiquidCrystal for details about
+ how to hook up the LCD to the arduino.
+
Requires a defined FRM-device to work.
this FRM-device has to be configures for i2c by setting attr 'i2c-config' on the FRM-device
- it reads out the ic-internal storage in intervals of 'sampling-interval' as set on the FRM-device
-
-
+
+
Define
- define <name> FRM_I2C <i2c-address> <register> <bytes-to-read>
- Specifies the FRM_I2C device.
+ define <name> FRM_LCD i2c <size-x> <size-y> <i2c-address>
+ Specifies the FRM_LCD device.
+ - size-x is the number of characters per line
+ - size-y is the numbers of rows.
- i2c-address is the (device-specific) address of the ic on the i2c-bus
- - register is the (device-internal) address to start reading bytes from.
- - bytes-to-read is the number of bytes read from the ic
-
+
Set
- N/A
+ set <name> text <text to be displayed>
Get
-
+
Attributes
+ - backLight <on|off>
+ - autoClear <on|off>
+ - autoBreak <on|off>
+ - restoreOnStartup <on|off>
+ - restoreOnReconnect <on|off>
- IODev
Specify which FRM to use. (Optional, only required if there is more
than one FRM-device defined.)
diff --git a/fhem/FHEM/20_FRM_OUT.pm b/fhem/FHEM/20_FRM_OUT.pm
index 9562c1ac4..9d9bc968b 100755
--- a/fhem/FHEM/20_FRM_OUT.pm
+++ b/fhem/FHEM/20_FRM_OUT.pm
@@ -19,7 +19,7 @@ FRM_OUT_Initialize($)
$hash->{UndefFn} = "FRM_OUT_Undef";
$hash->{StateFn} = "FRM_OUT_State";
- $hash->{AttrList} = "IODev loglevel:0,1,2,3,4,5 $main::readingFnAttributes";
+ $hash->{AttrList} = "restoreOnReconnect:on,off restoreOnStartup:on,off IODev loglevel:0,1,2,3,4,5 $main::readingFnAttributes";
}
sub
@@ -32,17 +32,18 @@ FRM_OUT_Init($$)
if (! (defined AttrVal($name,"stateFormat",undef))) {
$main::attr{$name}{"stateFormat"} = "value";
}
+ my $value = ReadingsVal($name,"value",undef);
+ if (defined $value and AttrVal($hash->{NAME},"restoreOnReconnect","on") eq "on") {
+ FRM_OUT_Set($hash,$name,$value);
+ }
main::readingsSingleUpdate($hash,"state","Initialized",1);
return undef;
}
sub
-FRM_OUT_Set($@)
+FRM_OUT_Set($$$)
{
- my ($hash, @a) = @_;
- my $name = $hash->{NAME};
- shift @a;
- my $cmd = $a[0];
+ my ($hash, $name, $cmd, @a) = @_;
my $value;
if ($cmd eq "on") {
$value=PIN_HIGH;
@@ -50,7 +51,7 @@ FRM_OUT_Set($@)
$value=PIN_LOW;
} else {
my $list = "on off";
- return SetExtensions($hash, $list, $name, @a);
+ return SetExtensions($hash, $list, $name, $cmd, @a);
}
my $iodev = $hash->{IODev};
main::readingsSingleUpdate($hash,"value",$cmd, 1);
@@ -69,7 +70,9 @@ sub FRM_OUT_State($$$$)
STATEHANDLER: {
$sname eq "value" and do {
- FRM_OUT_Set($hash,$hash->{NAME},$sval);
+ if (AttrVal($hash->{NAME},"restoreOnStartup","on") eq "on") {
+ FRM_OUT_Set($hash,$hash->{NAME},$sval);
+ }
last;
}
}
@@ -114,6 +117,8 @@ FRM_OUT_Undef($$)
Attributes
+ - restoreOnStartup <on|off>
+ - restoreOnReconnect <on|off>
- IODev
Specify which FRM to use. (Optional, only required if there is more
than one FRM-device defined.)
diff --git a/fhem/FHEM/20_FRM_PWM.pm b/fhem/FHEM/20_FRM_PWM.pm
index a5b7e31f1..16406eec0 100755
--- a/fhem/FHEM/20_FRM_PWM.pm
+++ b/fhem/FHEM/20_FRM_PWM.pm
@@ -23,7 +23,7 @@ FRM_PWM_Initialize($)
$hash->{UndefFn} = "FRM_PWM_Undef";
$hash->{StateFn} = "FRM_PWM_State";
- $hash->{AttrList} = "IODev loglevel:0,1,2,3,4,5 $main::readingFnAttributes";
+ $hash->{AttrList} = "restoreOnReconnect:on,off restoreOnStartup:on,off IODev loglevel:0,1,2,3,4,5 $main::readingFnAttributes";
}
sub
@@ -38,6 +38,10 @@ FRM_PWM_Init($$)
if (! (defined AttrVal($name,"stateFormat",undef))) {
$main::attr{$name}{"stateFormat"} = "value";
}
+ my $value = ReadingsVal($name,"value",undef);
+ if (defined $value and AttrVal($hash->{NAME},"restoreOnReconnect","on") eq "on") {
+ FRM_OUT_Set($hash,$value);
+ }
main::readingsSingleUpdate($hash,"state","Initialized",1);
return undef;
}
@@ -68,7 +72,9 @@ sub FRM_PWM_State($$$$)
STATEHANDLER: {
$sname eq "value" and do {
- FRM_PWM_Set($hash,$hash->{NAME},$sval);
+ if (AttrVal($hash->{NAME},"restoreOnStartup","on") eq "on") {
+ FRM_PWM_Set($hash,$hash->{NAME},$sval);
+ }
last;
}
}
@@ -116,6 +122,8 @@ FRM_PWM_Undef($$)
Attributes
+ - restoreOnStartup <on|off>
+ - restoreOnReconnect <on|off>
- IODev
Specify which FRM to use. (Optional, only required if there is more
than one FRM-device defined.)