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:
parent
5841dcf806
commit
7fb42f6fb4
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# 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
|
- changed: 89_HEATRONIC.pm: calculation of sol_Tcollector changed
|
||||||
- feature: # comments in fhem.cfg are only removed at the line-start
|
- feature: # comments in fhem.cfg are only removed at the line-start
|
||||||
- feature: set command modifyTimeSpec for at, to be used in webCmd
|
- feature: set command modifyTimeSpec for at, to be used in webCmd
|
||||||
|
@ -177,11 +177,18 @@ sub MilightDevice_Define($$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Define devStateIcon
|
# Define devStateIcon
|
||||||
$attr{$name}{devStateIcon} = '{(MilightDevice_devStateIcon($name),"toggle")}' if(!defined( $attr{$name}{devStateIcon}));
|
$attr{$name}{devStateIcon} = '{(MilightDevice_devStateIcon($name),"toggle")}' if(!defined($attr{$name}{devStateIcon}));
|
||||||
|
|
||||||
# Event on change reading
|
# Event on change reading
|
||||||
$attr{$name}{"event-on-change-reading"} = "state,transitionInProgress" if (!defined($attr{$name}{"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
|
# IODev
|
||||||
$attr{$name}{IODev} = $hash->{IODev} if (!defined($attr{$name}{IODev}));
|
$attr{$name}{IODev} = $hash->{IODev} if (!defined($attr{$name}{IODev}));
|
||||||
|
|
||||||
@ -488,15 +495,17 @@ sub MilightDevice_Set(@)
|
|||||||
}
|
}
|
||||||
elsif ($cmd eq 'preset')
|
elsif ($cmd eq 'preset')
|
||||||
{
|
{
|
||||||
return "Usage: set $name preset <0..X|+>" if (!defined($args[0]));
|
my $preset = "+";
|
||||||
return "Usage: set $name preset <0..X|+>" if ($args[0] !~ /^(\d+|\+)$/);
|
# 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.
|
# 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)));
|
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.
|
# Load the next preset (and loop back to the first) if "+" specified.
|
||||||
if ("$preset" eq "+")
|
if ("$preset" eq "+")
|
||||||
{
|
{
|
||||||
@ -1266,8 +1275,8 @@ sub MilightDevice_HSVToStr(@)
|
|||||||
my ($hash, $h, $s, $v) = @_;
|
my ($hash, $h, $s, $v) = @_;
|
||||||
|
|
||||||
$h=0 if (!defined($h));
|
$h=0 if (!defined($h));
|
||||||
$s=0 if (!defined($h));
|
$s=0 if (!defined($s));
|
||||||
$v=0 if (!defined($h));
|
$v=0 if (!defined($v));
|
||||||
|
|
||||||
Log3 ($hash, 5, "MilightDevice_HSVToStr: h:$h,s:$s,v:$v");
|
Log3 ($hash, 5, "MilightDevice_HSVToStr: h:$h,s:$s,v:$v");
|
||||||
return "$h,$s,$v";
|
return "$h,$s,$v";
|
||||||
@ -1479,6 +1488,7 @@ sub MilightDevice_SetHSV_Readings(@)
|
|||||||
|
|
||||||
readingsBulkUpdate($hash, "saturation", $sat);
|
readingsBulkUpdate($hash, "saturation", $sat);
|
||||||
readingsBulkUpdate($hash, "hue", $hue);
|
readingsBulkUpdate($hash, "hue", $hue);
|
||||||
|
readingsBulkUpdate($hash, "hsv", MilightDevice_HSVToStr($hash, $hue,$sat,$val));
|
||||||
|
|
||||||
# Calc RGB values from HSV
|
# Calc RGB values from HSV
|
||||||
my ($r,$g,$b) = Color::hsv2rgb($hue/360.0,$sat/100.0,$val/100.0);
|
my ($r,$g,$b) = Color::hsv2rgb($hue/360.0,$sat/100.0,$val/100.0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user