From 13a4ee0113d425858ba877ac3ee787ce422a7725 Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Thu, 20 Jan 2022 10:50:34 +0000 Subject: [PATCH] 30_HUEBridge.pm: new attribute createEventTimestampReading git-svn-id: https://svn.fhem.de/fhem/trunk@25513 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/30_HUEBridge.pm | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/fhem/FHEM/30_HUEBridge.pm b/fhem/FHEM/30_HUEBridge.pm index 133329a2d..2cbcdcc2b 100644 --- a/fhem/FHEM/30_HUEBridge.pm +++ b/fhem/FHEM/30_HUEBridge.pm @@ -47,7 +47,7 @@ sub HUEBridge_Initialize($) $hash->{GetFn} = "HUEBridge_Get"; $hash->{AttrFn} = "HUEBridge_Attr"; $hash->{UndefFn} = "HUEBridge_Undefine"; - $hash->{AttrList} = "key disable:1 disabledForIntervals createGroupReadings:1,0 httpUtils:1,0 noshutdown:1,0 pollDevices:1,2,0 queryAfterSet:1,0 $readingFnAttributes"; + $hash->{AttrList} = "key disable:1 disabledForIntervals createEventTimestampReading:1,0 createGroupReadings:1,0 httpUtils:1,0 noshutdown:1,0 pollDevices:1,2,0 queryAfterSet:1,0 $readingFnAttributes"; #$hash->{isDiscoverable} = { ssdp => {'hue-bridgeid' => '/.*/'}, upnp => {} }; @@ -74,6 +74,10 @@ HUEBridge_Read($) } elsif( $hash->{websocket} ) { $hash->{buf} .= $buf; + if( defined(my $create = AttrVal($name,'createEventTimestampReading',undef )) ) { + readingsSingleUpdate($hash, 'event', 'timestamp', $create ) if( defined($create) ); + } + do { my $fin = (ord(substr($hash->{buf},0,1)) & 0x80)?1:0; my $op = (ord(substr($hash->{buf},0,1)) & 0x0F); @@ -2248,8 +2252,14 @@ HUEBridge_dispatch($$$;$) return undef; } elsif( defined($type) && $type eq 'event' ) { - $hash->{EventStream} = 'connected'; - Log3 $name, 4, "name: EventStream: $hash->{EventStream}"; + if( $hash->{EventStream} && $hash->{EventStream} ne 'connected' ) { + $hash->{EventStream} = 'connected'; + Log3 $name, 4, "name: EventStream: $hash->{EventStream}"; + } + + if( defined(my $create = AttrVal($name,'createEventTimestampReading',undef )) ) { + readingsSingleUpdate($hash, 'event', 'timestamp', $create ) if( defined($create) ); + } if( $hash->{INTERVAL} && $hash->{INTERVAL} < 60 ) { $hash->{INTERVAL} = 60; @@ -2895,6 +2905,11 @@ __END__ 1 -> the bridge will poll all lights in one go instead of each light polling itself independently
2 -> the bridge will poll all devices in one go instead of each device polling itself independently
default is 2. will be deleted if v2 api is detected and eventstream connects. +
  • createEventTimestampReading
    + timestamp reading for every event received
  • + 0 -> update reading without fhem event + 1 -> update reading with fhem event + undef -> don't create reading
  • createGroupReadings
    create 'artificial' readings for group devices.
  • 0 -> create readings only for group devices where createGroupReadings ist set to 1