2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-09 07:44:19 +00:00

HUE: added Meta support

git-svn-id: https://svn.fhem.de/fhem/trunk@19091 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2019-04-02 07:33:20 +00:00
parent 66936e2cb0
commit c36da0646d
2 changed files with 116 additions and 10 deletions

View File

@ -9,6 +9,9 @@ package main;
use strict;
use warnings;
use FHEM::Meta;
use POSIX;
use JSON;
use Data::Dumper;
@ -36,6 +39,8 @@ sub HUEBridge_Initialize($)
$hash->{AttrList} = "key disable:1 disabledForIntervals createGroupReadings:1,0 httpUtils:1,0 noshutdown:1,0 pollDevices:1,2,0 queryAfterSet:1,0 $readingFnAttributes";
#$hash->{isDiscoverable} = { ssdp => {'hue-bridgeid' => '/.*/'}, upnp => {} };
return FHEM::Meta::InitMod( __FILE__, $hash );
}
sub
@ -212,6 +217,8 @@ HUEBridge_Define($$)
my @args = split("[ \t]+", $def);
return $@ unless ( FHEM::Meta::SetInternals($hash) );
return "Usage: define <name> HUEBridge [<host>] [interval]" if(@args < 2);
my ($name, $type, $host, $interval) = @args;
@ -971,7 +978,7 @@ HUEBridge_Get($@)
foreach my $key ( sort {$a<=>$b} keys %{$result} ) {
$ret .= sprintf( "%2i: %-20s %-12s", $key, $result->{$key}{name},$result->{$key}{status} );
$ret .= sprintf( "%s", $result->{$key}{localtime} ) if( $arg && $arg eq 'detail' );
$ret .= "\n";
}
if( $arg && $arg eq 'detail' ) {
@ -2036,4 +2043,49 @@ HUEBridge_Attr($$$)
</ul><br>
=end html
=for :application/json;q=META.json 30_HUEBridge.pm
{
"abstract": "module for the phillips hue bridge",
"x_lang": {
"de": {
"abstract": "Modul für die Philips HUE Bridge"
}
},
"resources": {
"x_wiki": {
"web": "https://wiki.fhem.de/wiki/Hue"
}
},
"keywords": [
"fhem-mod",
"fhem-mod-device",
"HUE"
],
"release_status": "stable",
"x_fhem_maintainer": [
"justme1968"
],
"x_fhem_maintainer_github": [
"justme-1968"
],
"prereqs": {
"runtime": {
"requires": {
"FHEM": 5.00918799,
"perl": 5.014,
"Meta": 0,
"JSON": 0,
"Data::Dumper": 0,
"IO::Socket::INET": 0
},
"recommends": {
},
"suggests": {
"HUEDevice": 0
}
}
}
}
=end :application/json;q=META.json
=cut

View File

@ -10,6 +10,8 @@ package main;
use strict;
use warnings;
use FHEM::Meta;
use Color;
use POSIX;
@ -185,6 +187,8 @@ sub HUEDevice_Initialize($)
eval "use Data::Dumper";
$HUEDevice_hasDataDumper = 0 if($@);
return FHEM::Meta::InitMod( __FILE__, $hash );
}
sub
@ -262,6 +266,8 @@ sub HUEDevice_Define($$)
my @args = split("[ \t]+", $def);
return $@ unless ( FHEM::Meta::SetInternals($hash) );
$hash->{helper}->{devtype} = "";
if( $args[2] eq "group" ) {
$hash->{helper}->{devtype} = "G";
@ -1243,7 +1249,7 @@ HUEDevice_Parse($$)
}
my $lastupdated;
my $lastupdated_local;
my $lastupdated_local;
if( my $state = $result->{state} ) {
$lastupdated = $state->{lastupdated};
@ -1258,15 +1264,15 @@ HUEDevice_Parse($$)
my $sec = SVG_time_to_sec($lastupdated);
$lastupdated = FmtDateTime($sec);
if( my $offset_bridge = $iohash->{helper}{offsetUTC} ) {
$offset = $offset_bridge;
Log3 $name, 4, "$name: use offsetUTC $offset from bridge";
}else{
#we do not have received the offsetUTC from the bridge, use the system offsetUTC until we received it
my @t = localtime(time);
$offset = timegm(@t) - timelocal(@t);
Log3 $name, 4, "$name: use offsetUTC $offset from system";
$offset = timegm(@t) - timelocal(@t);
Log3 $name, 4, "$name: use offsetUTC $offset from system";
}
#add offset to UTC for displaying in fhem
@ -1277,7 +1283,7 @@ HUEDevice_Parse($$)
}
$hash->{lastupdated} = ReadingsVal( $name, '.lastupdated', undef ) if( !$hash->{lastupdated} );
$hash->{lastupdated_local} = ReadingsVal( $name, '.lastupdated_local', undef ) if( !$hash->{lastupdated_local} );
$hash->{lastupdated_local} = ReadingsVal( $name, '.lastupdated_local', undef ) if( !$hash->{lastupdated_local} );
return undef if( $hash->{lastupdated} && $hash->{lastupdated} eq $lastupdated );
Log3 $name, 4, "$name: lastupdated: $lastupdated, hash->{lastupdated}: $hash->{lastupdated}, lastupdated_local: $lastupdated_local, offsetUTC: $offset";
@ -1331,9 +1337,9 @@ HUEDevice_Parse($$)
if( $lastupdated_local ) {
$hash->{'.updateTimestamp'} = $lastupdated_local;
$hash->{CHANGETIME}[$i] = $lastupdated_local;
readingsBulkUpdate($hash, '.lastupdated_local', $lastupdated_local, 0);
readingsBulkUpdate($hash, '.lastupdated_local', $lastupdated_local, 0);
}
if( $lastupdated ) {
readingsBulkUpdate($hash, '.lastupdated', $lastupdated, 0);
}
@ -1552,8 +1558,8 @@ HUEDevice_Attr($$$;$)
=pod
=item cloudfree
=item openapi
=item summary devices connected to a phillips hue bridge or a osram lightify gateway
=item summary_DE Geräte an einer Philips HUE Bridge oder einem Osram LIGHTIFY Gateway
=item summary Devices connected to a Phillips HUE bridge, an LIGHTIFY or TRADFRI gateway
=item summary_DE Ger&auml;te an einer Philips HUE Bridge, einem LIGHTIFY oder Tradfri Gateway
=begin html
<a name="HUEDevice"></a>
@ -1725,4 +1731,52 @@ absent:{&lt;json&gt;}</code></li>
</ul><br>
=end html
=for :application/json;q=META.json 31_HUEDevice.pm
{
"abstract": "devices connected to a Phillips HUE bridge, an Osram LIGHTIFY gateway or a IKEA TRADFRI gateway",
"x_lang": {
"de": {
"abstract": "Geräte an einer Philips HUE Bridge, einem Osram LIGHTIFY Gateway oder einem IKEA Tradfri Gateway"
}
},
"resources": {
"x_wiki": {
"web": "https://wiki.fhem.de/wiki/Hue"
}
},
"keywords": [
"fhem-mod",
"fhem-mod-device",
"HUE"
],
"release_status": "stable",
"x_fhem_maintainer": [
"justme1968"
],
"x_fhem_maintainer_github": [
"justme-1968"
],
"prereqs": {
"runtime": {
"requires": {
"FHEM": 5.00918799,
"perl": 5.014,
"Meta": 0,
"Color": 0,
"SetExtensions": 0,
"JSON": 0,
"Time::Local": 0
},
"recommends": {
},
"suggests": {
"HUEBridge": 0,
"tradfri": 0,
"LIGHTIFY": 0
}
}
}
}
=end :application/json;q=META.json
=cut