2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-04 05:16:45 +00:00

HUE: use official device icons on autocreate

git-svn-id: https://svn.fhem.de/fhem/trunk@11327 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2016-04-27 10:37:55 +00:00
parent d7e3679582
commit 431413e11f
2 changed files with 72 additions and 20 deletions

View File

@ -165,6 +165,8 @@ sub HUEBridge_Undefine($$)
sub HUEBridge_fillBridgeInfo($$) sub HUEBridge_fillBridgeInfo($$)
{ {
my ($hash,$result) = @_; my ($hash,$result) = @_;
my $name = $hash->{NAME};
$hash->{name} = $result->{name}; $hash->{name} = $result->{name};
$hash->{modelid} = $result->{modelid}; $hash->{modelid} = $result->{modelid};
$hash->{swversion} = $result->{swversion}; $hash->{swversion} = $result->{swversion};
@ -172,6 +174,12 @@ sub HUEBridge_fillBridgeInfo($$)
my @l = split( '\.', $result->{apiversion} ); my @l = split( '\.', $result->{apiversion} );
$hash->{helper}{apiversion} = ($l[0] << 16) + ($l[1] << 8) + $l[2]; $hash->{helper}{apiversion} = ($l[0] << 16) + ($l[1] << 8) + $l[2];
if( !defined($result->{'linkbutton'})
&& !defined($attr{$name}{icon}) ) {
$attr{$name}{icon} = 'hue_filled_bridge_v1' if( $hash->{modelid} && $hash->{modelid} eq 'BSB001' );
$attr{$name}{icon} = 'hue_filled_bridge_v2' if( $hash->{modelid} && $hash->{modelid} eq 'BSB002' );
}
} }
sub HUEBridge_OpenDev($) sub HUEBridge_OpenDev($)
@ -664,6 +672,9 @@ HUEBridge_Autocreate($;$)
$cmdret= CommandAttr(undef,"$devname room HUEDevice"); $cmdret= CommandAttr(undef,"$devname room HUEDevice");
$cmdret= CommandAttr(undef,"$devname IODev $name"); $cmdret= CommandAttr(undef,"$devname IODev $name");
HUEDeviceSetIcon($devname);
$defs{$devname}{helper}{fromAutocreate} = 1 ;
$autocreated++; $autocreated++;
} }
} }

View File

@ -22,31 +22,50 @@ use SetExtensions;
use vars qw(%FW_webArgs); # all arguments specified in the GET use vars qw(%FW_webArgs); # all arguments specified in the GET
my %hueModels = ( my %hueModels = (
LCT001 => {name => 'Hue Bulb' ,type => 'Extended Color light' ,subType => 'extcolordimmer',}, LCT001 => {name => 'Hue Bulb' ,type => 'Extended Color light' ,subType => 'extcolordimmer',
LCT002 => {name => 'Hue Spot BR30' ,type => 'Extended Color light' ,subType => 'extcolordimmer',}, icon => 'hue_filled_white_and_color_e27_b22', },
LCT003 => {name => 'Hue Spot GU10' ,type => 'Extended Color light' ,subType => 'extcolordimmer',}, LCT002 => {name => 'Hue Spot BR30' ,type => 'Extended Color light' ,subType => 'extcolordimmer',
LCT007 => {name => 'Hue Bulb V2' ,type => 'Extended Color light' ,subType => 'extcolordimmer',}, icon => 'hue_filled_br30.svg', },
LLC001 => {name => 'Living Colors G2' ,type => 'Color Light' ,subType => 'colordimmer',}, LCT003 => {name => 'Hue Spot GU10' ,type => 'Extended Color light' ,subType => 'extcolordimmer',
LLC005 => {name => 'Living Colors Bloom' ,type => 'Color Light' ,subType => 'colordimmer',}, icon => 'hue_filled_gu10_par16', },
LLC006 => {name => 'Living Colors Gen3 Iris' ,type => 'Color Light' ,subType => 'colordimmer',}, LCT007 => {name => 'Hue Bulb V2' ,type => 'Extended Color light' ,subType => 'extcolordimmer',
LLC007 => {name => 'Living Colors Gen3 Bloom' ,type => 'Color Light' ,subType => 'colordimmer',}, icon => 'hue_filled_white_and_color_e27_b22', },
LLC010 => {name => 'Hue Living Colors Iris' ,type => 'Color Light' ,subType => 'colordimmer',}, LLC001 => {name => 'Living Colors G2' ,type => 'Color Light' ,subType => 'colordimmer',
LLC011 => {name => 'Hue Living Colors Bloom' ,type => 'Color Light' ,subType => 'colordimmer',}, icon => 'hue_filled_iris', },
LLC012 => {name => 'Hue Living Colors Bloom' ,type => 'Color Light' ,subType => 'colordimmer',}, LLC005 => {name => 'Living Colors Bloom' ,type => 'Color Light' ,subType => 'colordimmer',
LLC013 => {name => 'Disney Living Colors' ,type => 'Color Light' ,subType => 'colordimmer',}, icon => 'hue_filled_bloom', },
LLC014 => {name => 'Living Colors Aura' ,type => 'Color Light' ,subType => 'colordimmer',}, LLC006 => {name => 'Living Colors Gen3 Iris' ,type => 'Color Light' ,subType => 'colordimmer',
LLC020 => {name => 'Hue Go' ,type => 'Color Light' ,subType => 'colordimmer',}, icon => 'hue_filled_iris', },
LLC007 => {name => 'Living Colors Gen3 Bloom' ,type => 'Color Light' ,subType => 'colordimmer',
icon => 'hue_filled_bloom', },
LLC010 => {name => 'Hue Living Colors Iris' ,type => 'Color Light' ,subType => 'colordimmer',
icon => 'hue_filled_iris', },
LLC011 => {name => 'Hue Living Colors Bloom' ,type => 'Color Light' ,subType => 'colordimmer',
icon => 'hue_filled_bloom', },
LLC012 => {name => 'Hue Living Colors Bloom' ,type => 'Color Light' ,subType => 'colordimmer',
icon => 'hue_filled_bloom', },
LLC013 => {name => 'Disney Living Colors' ,type => 'Color Light' ,subType => 'colordimmer',
icon => 'hue_filled_storylight', },
LLC014 => {name => 'Living Colors Aura' ,type => 'Color Light' ,subType => 'colordimmer',
icon => 'hue_filled_aura', },
LLC020 => {name => 'Hue Go' ,type => 'Color Light' ,subType => 'colordimmer',
icon => 'hue_filled_go', },
LLM001 => {name => 'Color Light Module' ,type => 'Extended Color Light' ,subType => 'extcolordimmer',}, LLM001 => {name => 'Color Light Module' ,type => 'Extended Color Light' ,subType => 'extcolordimmer',},
LLM010 => {name => 'Color Temperature Module' ,type => 'Extended Temperature Light' ,subType => 'ctdimmer',}, LLM010 => {name => 'Color Temperature Module' ,type => 'Extended Temperature Light' ,subType => 'ctdimmer',},
LLM011 => {name => 'Color Temperature Module' ,type => 'Extended Temperature Light' ,subType => 'ctdimmer',}, LLM011 => {name => 'Color Temperature Module' ,type => 'Extended Temperature Light' ,subType => 'ctdimmer',},
LLM012 => {name => 'Color Temperature Module' ,type => 'Extended Temperature Light' ,subType => 'ctdimmer',}, LLM012 => {name => 'Color Temperature Module' ,type => 'Extended Temperature Light' ,subType => 'ctdimmer',},
LST001 => {name => 'Hue LightStrips' ,type => 'Color Light' ,subType => 'colordimmer',}, LST001 => {name => 'Hue LightStrips' ,type => 'Color Light' ,subType => 'colordimmer',
LST002 => {name => 'Hue LightStrips Plus' ,type => 'Color Light' ,subType => 'colordimmer',}, icon => 'hue_filled_lightstrip', },
LST002 => {name => 'Hue LightStrips Plus' ,type => 'Color Light' ,subType => 'colordimmer',
icon => 'hue_filled_lightstrip', },
LWB001 => {name => 'Living Whites Bulb' ,type => 'Dimmable light' ,subType => 'dimmer',}, LWB001 => {name => 'Living Whites Bulb' ,type => 'Dimmable light' ,subType => 'dimmer',},
LWB003 => {name => 'Living Whites Bulb' ,type => 'Dimmable light' ,subType => 'dimmer',}, LWB003 => {name => 'Living Whites Bulb' ,type => 'Dimmable light' ,subType => 'dimmer',},
LWB004 => {name => 'Hue Lux' ,type => 'Dimmable light' ,subType => 'dimmer',}, LWB004 => {name => 'Hue Lux' ,type => 'Dimmable light' ,subType => 'dimmer',
LWB006 => {name => 'Hue White' ,type => 'Dimmable light' ,subType => 'dimmer',}, icon => 'hue_filled_white_and_color_e27_b22', },
LWB007 => {name => 'Hue Lux' ,type => 'Dimmable light' ,subType => 'dimmer',}, LWB006 => {name => 'Hue White' ,type => 'Dimmable light' ,subType => 'dimmer',
icon => 'hue_filled_white_and_color_e27_b22', },
LWB007 => {name => 'Hue Lux' ,type => 'Dimmable light' ,subType => 'dimmer',
icon => 'hue_filled_white_and_color_e27_b22', },
LWL001 => {name => 'LivingWhites Outlet' ,type => 'Dimmable plug-in unit' ,subType => 'dimmer',}, LWL001 => {name => 'LivingWhites Outlet' ,type => 'Dimmable plug-in unit' ,subType => 'dimmer',},
'FLS-H3' => {name => 'dresden elektronik FLS-H lp' ,type => 'Color Temperature Light' ,subType => 'ctdimmer',}, 'FLS-H3' => {name => 'dresden elektronik FLS-H lp' ,type => 'Color Temperature Light' ,subType => 'ctdimmer',},
@ -124,8 +143,8 @@ HUEDevice_devStateIcon($)
my $s = $dim_values{int($percent/7)}; my $s = $dim_values{int($percent/7)};
$s="on" if( $percent eq "100" ); $s="on" if( $percent eq "100" );
return ".*:$s:toggle" if( $attr{$name}{subType} eq "dimmer" );
return ".*:$s:toggle" if( AttrVal($name, "model", "") eq "LWL001" ); return ".*:$s:toggle" if( AttrVal($name, "model", "") eq "LWL001" );
return ".*:$s:toggle" if( AttrVal($name, "subtype", "") eq "dimmer" );
#return ".*:$s:toggle" if( AttrVal($name, "model", "") eq "LWB001" ); #return ".*:$s:toggle" if( AttrVal($name, "model", "") eq "LWB001" );
#return ".*:$s:toggle" if( AttrVal($name, "model", "") eq "LWB003" ); #return ".*:$s:toggle" if( AttrVal($name, "model", "") eq "LWB003" );
@ -878,6 +897,25 @@ HUEDevice_GetUpdate($)
HUEDevice_Parse($hash,$result); HUEDevice_Parse($hash,$result);
} }
sub
HUEDeviceSetIcon($;$)
{
my ($hash,$force) = @_;
$hash = $defs{$hash} if( ref($hash) ne 'HASH' );
return undef if( !$hash );
my $name = $hash->{NAME};
return undef if( !$hash->{modelid} );
my $model = $hueModels{$hash->{modelid}};
return undef if( !$model );
my $icon = $model->{icon};
return undef if( !$icon );
$attr{$name}{icon} = $icon if( $force || !defined($attr{$name}{icon}) );
}
sub sub
HUEDevice_Parse($$) HUEDevice_Parse($$)
{ {
@ -954,6 +992,9 @@ HUEDevice_Parse($$)
} }
HUEDeviceSetIcon($hash) if( $hash->{helper}{fromAutocreate} );
delete $hash->{helper}{fromAutocreate};
} elsif( $hash->{type} ) { } elsif( $hash->{type} ) {
if( $hash->{type} eq "Extended color light" ) { if( $hash->{type} eq "Extended color light" ) {
$attr{$name}{subType} = 'extcolordimmer'; $attr{$name}{subType} = 'extcolordimmer';