Skip to content
Permalink
Browse files

Revert changes from LightScene.

Add hsv reading and automatically set lightSceneParamsToSave to MilightDevice
  • Loading branch information
mattwire committed Feb 20, 2015
1 parent 24dd8c5 commit 07f96f813893ffbb6fcfc88bf851c89dcc72268c
Showing with 13 additions and 18 deletions.
  1. +1 −10 31_LightScene.pm
  2. +12 −8 31_MilightDevice.pm
@@ -1,5 +1,5 @@

# $Id$
# $Id: 31_LightScene.pm 7868 2015-02-04 12:39:49Z justme1968 $

package main;

@@ -513,15 +513,6 @@ LightScene_SaveDevice($$)
}
} elsif( $type eq 'TRX_LIGHT' ) {
$state = Value($d);
} elsif( $type eq 'MilightDevice' ) {
my $subtype = AttrVal($d,"subType","");
if( Value($d) eq "off" ) {
$state = Value($d);
} elsif( $subtype eq 'ctdimmer' ) {
$state = "brightness ". ReadingsVal($d,'brightness','0') ." : ct ". ReadingsVal($d,'ct','1');
} elsif( $subtype eq 'colordimmer' ) {
$state = "hsv ". ReadingsVal($d,'hue','0') .",". ReadingsVal($d,'saturation','0') .",". ReadingsVal($d,'brightness','0');
}
} else {
$state = Value($d);
}
@@ -177,15 +177,18 @@ sub MilightDevice_Define($$)
}

# 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
$attr{$name}{"event-on-change-reading"} = "state,transitionInProgress" if (!defined($attr{$name}{"event-on-change-reading"}));

# subtype
$attr{$name}{"subType"} = "colordimmer" if (($hash->{LEDTYPE} eq 'RGBW')|| ($hash->{LEDTYPE} eq 'RGB'));
$attr{$name}{"subType"} = "ctdimmer" if ($hash->{LEDTYPE} eq 'White');


# 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}));

@@ -1272,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";
@@ -1485,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);

0 comments on commit 07f96f8

Please sign in to comment.
You can’t perform that action at this time.