From 2c49fceb67138cf260d88fd0b937ee91dadfb43b Mon Sep 17 00:00:00 2001
From: mattwire <>
Date: Sat, 19 Dec 2015 23:00:15 +0000
Subject: [PATCH] 31_MilightDevice: Add restoreAtStart attribute so group
devices (slot 'A') do not restore state by default at startup
git-svn-id: https://svn.fhem.de/fhem/trunk@10209 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/CHANGED | 1 +
fhem/FHEM/31_MilightDevice.pm | 33 ++++++++++++++++-----------------
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/fhem/CHANGED b/fhem/CHANGED
index b1c54d6b1..01ad20428 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: 31_MilightDevice: Add restoreAtStart attribute so group devices (slot 'A') do not restore state by default at startup
- bugfix: 30_MilightBridge/31_MilightDevice: Fix startup restore. Fix crash on invalid hostname.
- feature: 30_pilight_xyz: possibility to change IO-Device (IODEV)
- bugfix: YAMAHA_AVR: fixing not correctly volume smoothing
diff --git a/fhem/FHEM/31_MilightDevice.pm b/fhem/FHEM/31_MilightDevice.pm
index d1b168ba4..0115e9169 100644
--- a/fhem/FHEM/31_MilightDevice.pm
+++ b/fhem/FHEM/31_MilightDevice.pm
@@ -85,7 +85,10 @@ sub MilightDevice_Initialize($)
$hash->{GetFn} = "MilightDevice_Get";
$hash->{AttrFn} = "MilightDevice_Attr";
$hash->{NotifyFn} = "MilightDevice_Notify";
- $hash->{AttrList} = "IODev dimStep defaultBrightness defaultRampOn defaultRampOff presets dimOffWhite:1,0 updateGroupDevices:1,0 colorCast gamma lightSceneParamsToSave ".$readingFnAttributes;
+ $hash->{AttrList} = "IODev dimStep defaultBrightness defaultRampOn " .
+ "defaultRampOff presets dimOffWhite:1,0 updateGroupDevices:1,0 " .
+ "restoreAtStart:1,0 colorCast gamma lightSceneParamsToSave " .
+ $readingFnAttributes;
FHEM_colorpickerInit();
}
@@ -204,6 +207,13 @@ sub MilightDevice_Define($$)
# IODev
$attr{$name}{IODev} = $hash->{IODev} if (!defined($attr{$name}{IODev}));
+
+ # restoreAtStart
+ if($slot eq 'A') {
+ $attr{$name}{"restoreAtStart"} = 0 if (!defined($attr{$name}{"restoreAtStart"}));
+ } else {
+ $attr{$name}{"restoreAtStart"} = 1 if (!defined($attr{$name}{"restoreAtStart"}));
+ }
return undef;
}
@@ -725,23 +735,7 @@ sub MilightDevice_Attr(@)
sub MilightDevice_Notify(@)
{
my ($hash,$dev) = @_;
- #my $events = deviceEvents($dev, 1);
- #my ($hue, $sat, $val);
-
return MilightDevice_Restore($hash);
-
- #return if($dev->{NAME} ne "global");
- #Log3 ($hash, 5, "$hash->{NAME}_Notify: Triggered by $dev->{NAME}");
- #return if(!grep(m/^INITIALIZED|REREADCFG|DEFINED$/, @{$dev->{CHANGED}}));
-
- # Restore previous state (as defined in statefile)
- # wait for global: INITIALIZED after start up
- #if (@{$events}[0] eq 'INITIALIZED')
- #{
- # MilightDevice_Restore($hash);
- #}
-
- return undef;
}
#####################################
@@ -754,6 +748,7 @@ sub MilightDevice_Restore(@)
return if ($hash->{INIT});
if ($init_done)
{
+ return if (AttrVal($hash->{NAME}, "restoreAtStart", 0) == 0);
Log3 ($hash, 4, "$hash->{NAME}_Restore: Restoring saved HSV values");
$hash->{INIT} = 1;
# Initialize device
@@ -2356,6 +2351,10 @@ sub MilightDevice_roundfunc($) {
updateGroupDevices
Update the state of single devices switched with slot 'A'.
+