From 7329c8ffdeb1e6753e79d7492916f2d16e865f70 Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Mon, 25 Feb 2013 19:52:48 +0000 Subject: [PATCH] use new devStateIcon feature to show device color in room overview git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@2810 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- CHANGED | 4 +++- FHEM/31_HUEDevice.pm | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGED b/CHANGED index 1bd3bdec3..03ea28cc4 100644 --- a/CHANGED +++ b/CHANGED @@ -1,8 +1,10 @@ - SVN + - change: 30_HUEDevice: use new devStateIcon feature to show device color + in room overview - feature: added example Setup SQL and configuration for SQLite - change: modified MySQL Setup SQL to use 512 characters in EVENT column - feature: added new Javascript Frontend based on ExtJS (by Johannes) - - feature: new Modules 30_HUEDevice and 31_HUEBridge for phillips hue and + - feature: new Modules 30_HUEBridge and 31_HUEDevice for phillips hue and smartlink devices (by justme1968) - change: SYSSTAT: allow remote monitoring by ssh - change: SYSSTAT: allow less frequent updates for diskusage diff --git a/FHEM/31_HUEDevice.pm b/FHEM/31_HUEDevice.pm index 78acc0f2c..16966b85e 100644 --- a/FHEM/31_HUEDevice.pm +++ b/FHEM/31_HUEDevice.pm @@ -60,6 +60,9 @@ sub HUEDevice_Define($$) $hash->{fhem}{hue} = -1; $hash->{fhem}{sat} = -1; + + CommandAttr(undef,$name.' devStateIcon {CommandGet("","'.$name.' devStateIcon")}') if( !defined( AttrVal($hash->{NAME}, "devStateIcon", undef) ) ); + AssignIoPort($hash); if(defined($hash->{IODev}->{NAME})) { Log 3, "$name: I/O device is " . $hash->{IODev}->{NAME}; @@ -332,9 +335,20 @@ HUEDevice_Get($@) } } return $ret; + } elsif ( $cmd eq "devStateIcon" ) { + return '
'. + 'off' if( ReadingsVal($name,"state","off") eq "off" ); + + return '
'. + ''.$hash->{STATE}.'' if( AttrVal($hash->{NAME}, "model", "") eq "LWL001" ); + + return '
'; } - return "Unknown argument $cmd, choose one of rgb"; + return "Unknown argument $cmd, choose one of rgb devStateIcon"; } @@ -453,6 +467,7 @@ HUEDevice_GetUpdate($) my $percent = int( $state->{'bri'} * 100 / 254 ); if( $bri != $hash->{fhem}{bri} ) {readingsBulkUpdate($hash,"level", $percent . ' %');} + if( $bri != $hash->{fhem}{bri} ) {readingsBulkUpdate($hash,"pct", $percent);} if( $percent > 0 && $percent < 100 ) { $s = $dim_values{int($percent/7)}; @@ -566,6 +581,8 @@ HUEDevice_GetUpdate($) Get
  • rgb
  • +
  • devStateIcon
    + returns html code that can be used to create an icon that represents the device color in the room overview.

@@ -573,6 +590,8 @@ HUEDevice_GetUpdate($)
  • subType
    dimmer or switch, default is dimmer.
  • +
  • devStateIcon
    + will be initialized to {CommandGet("","<name> devStateIcon")} as default to show device color in room overview.