2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

31_MilightDevice: Support LightScene

git-svn-id: https://svn.fhem.de/fhem/trunk@8073 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
mattwire 2015-02-22 19:26:22 +00:00
parent 5841dcf806
commit 7fb42f6fb4
2 changed files with 21 additions and 10 deletions

View File

@ -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.pm: Support LightScene
- changed: 89_HEATRONIC.pm: calculation of sol_Tcollector changed
- feature: # comments in fhem.cfg are only removed at the line-start
- feature: set command modifyTimeSpec for at, to be used in webCmd

View File

@ -182,6 +182,13 @@ sub MilightDevice_Define($$)
# Event on change reading
$attr{$name}{"event-on-change-reading"} = "state,transitionInProgress" if (!defined($attr{$name}{"event-on-change-reading"}));
# lightScene
if(!defined($attr{$name}{"lightSceneParamsToSave"}))
{
$attr{$name}{"lightSceneParamsToSave"} = "hsv" if (($hash->{LEDTYPE} eq 'RGBW')|| ($hash->{LEDTYPE} eq 'RGB'));
$attr{$name}{"lightSceneParamsToSave"} = "brightness" if ($hash->{LEDTYPE} eq 'White');
}
# IODev
$attr{$name}{IODev} = $hash->{IODev} if (!defined($attr{$name}{IODev}));
@ -488,15 +495,17 @@ sub MilightDevice_Set(@)
}
elsif ($cmd eq 'preset')
{
return "Usage: set $name preset <0..X|+>" if (!defined($args[0]));
my $preset = "+";
# Default to "preset +" if no args defined
if (defined($args[0]))
{
return "Usage: set $name preset <0..X|+>" if ($args[0] !~ /^(\d+|\+)$/);
$preset = $args[0];
}
# Get presets, if not defined default to 1 preset 0,0,100.
my @presets = split(/ /, AttrVal($hash->{NAME}, "presets", MilightDevice_HSVToStr($hash, 0, 0, 100)));
# If preset = "+" then load the next one
my $preset = $args[0];
# Load the next preset (and loop back to the first) if "+" specified.
if ("$preset" eq "+")
{
@ -1266,8 +1275,8 @@ sub MilightDevice_HSVToStr(@)
my ($hash, $h, $s, $v) = @_;
$h=0 if (!defined($h));
$s=0 if (!defined($h));
$v=0 if (!defined($h));
$s=0 if (!defined($s));
$v=0 if (!defined($v));
Log3 ($hash, 5, "MilightDevice_HSVToStr: h:$h,s:$s,v:$v");
return "$h,$s,$v";
@ -1479,6 +1488,7 @@ sub MilightDevice_SetHSV_Readings(@)
readingsBulkUpdate($hash, "saturation", $sat);
readingsBulkUpdate($hash, "hue", $hue);
readingsBulkUpdate($hash, "hsv", MilightDevice_HSVToStr($hash, $hue,$sat,$val));
# Calc RGB values from HSV
my ($r,$g,$b) = Color::hsv2rgb($hue/360.0,$sat/100.0,$val/100.0);