philips hue modul

Begonnen von justme1968, 11 Februar 2013, 13:55:14

Vorheriges Thema - Nächstes Thema

Lippie

Zitat von: justme1968 am 01 August 2019, 11:44:01
@Lippie: kannst du mir bitte einen normalen diff dafür machen ?

Hi,

wollt nochmal rein fragen, wie ich unterstützen kann, um meine Änderungsvorschläge aufgenommen zu bekommen.
Soll ich im FHEM-GIT-Repo einen Pull-Request erstellen?

Gruß
Sebastian

justme1968

wie oben geschrieben: einen ganz normalen altmodischen diff.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

Lippie

Hi,

anbei die diffs:

https://github.com/mhop/fhem-mirror/compare/master...Lippie81:patch-2?diff=split

https://github.com/mhop/fhem-mirror/compare/master...Lippie81:patch-3

Hoffe, das passt so für Dich.
Beim HUEDevice hats ein paar Einrückungen verschoben, aber sieht man im diff ja sehr schnell.

Gruß
Sebastian

justme1968

kein GitHub diff. ganz wirklich altmodisch. die ausgabe des kommandozeilen tools diff (mal ienstem mit -u) die dann mit dem patch tool angewendet werden kann.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

Lippie

Zitat von: justme1968 am 07 November 2019, 20:50:42
kein GitHub diff. ganz wirklich altmodisch. die ausgabe des kommandozeilen tools diff (mal ienstem mit -u) die dann mit dem patch tool angewendet werden kann.

Hi,

ich hoffe, dass ist das, was du haben wolltest:

fc 30_HUEBridge_GITHUB.pm 30_HUEBridge.pm

Vergleichen der Dateien 30_HUEBridge_GITHUB.pm und 30_HUEBRIDGE.PM

***** 30_HUEBridge_GITHUB.pm

# $Id$

***** 30_HUEBRIDGE.PM

# $Id: 30_HUEBridge.pm 19854 2019-07-19 13:04:29Z justme1968 $

*****

***** 30_HUEBridge_GITHUB.pm

    } elsif( $type =~ m/^groups\/(\d*)\/action$/ ) {
***** 30_HUEBRIDGE.PM

    } elsif( $type =~ m/^lights\/(\d*)\/bridgeupdatestate$/ ) {
      if( $queryAfterSet ) {
        my $chash = $param->{chash};
        if( $chash->{helper}->{update_timeout} ) {
          RemoveInternalTimer($chash);
          InternalTimer(gettimeofday()+1, "HUEDevice_GetUpdate", $chash, 0);
        } else {
          RemoveInternalTimer($chash);
          HUEDevice_GetUpdate( $chash );
        }
      }
    } elsif( $type =~ m/^groups\/(\d*)\/action$/ ) {
*****

***** 30_HUEBridge_GITHUB.pm
      available (indicated by updatestate with a value of 2. The version and release date is shown in the reading swupdate.<br>

      A notify of the form <code>define HUEUpdate notify bridge:swupdate.* {...}
</code>
***** 30_HUEBRIDGE.PM
      available (indicated by updatestate with a value of 2. The version and release date is shown in the reading swupdate.<br>
      A notify of the form <code>define HUEUpdate notify bridge:swupdate.* {...}
</code>
*****


fc 31_HUEDevice_GITHUB.pm 31_HUEDevice.pm

Vergleichen der Dateien 31_HUEDevice_GITHUB.pm und 31_HUEDEVICE.PM

***** 31_HUEDevice_GITHUB.pm

# $Id$

***** 31_HUEDEVICE.PM

# $Id: 31_HUEDevice.pm 19961 2019-08-07 13:30:18Z justme1968 $ edit by SL

*****

***** 31_HUEDevice_GITHUB.pm
    }
  }
***** 31_HUEDEVICE.PM
    }

  if($cmd eq "pct" && $value == 0 ) {
    $cmd = "off";
    $value = $value2;
  }
  if($cmd eq "bridgeupdatestate" ) {
    if($value eq "on" && !defined($value2)){
                $value = 100;
        }elsif($value eq "off"){
                $value = 0;
        }elsif($value eq "on" && defined($value2)){
                $value = $value2;
        }
  }
*****

***** 31_HUEDevice_GITHUB.pm

  } elsif($cmd eq "pct") {
***** 31_HUEDEVICE.PM

  } elsif($cmd eq 'bridgeupdatestate') {
    if ( $value == 0 ) {
                $obj->{'on'}  = JSON::false;
                $obj->{'bri'}  = int(0);
        }else{
                my $bri;
                if( $value > 50 ) {
                  $bri = 2.57 * ($value-50) + 128;
                } else {
                  $bri = 2.59 * ($value-50) + 128;
                }
                $bri = 0 if( $bri < 0 );
                $bri = 254 if( $bri > 254 );
                $obj->{'on'}  = JSON::true;
                $obj->{'bri'}  = int($bri);
        }
    $obj->{'transitiontime'} = $value * 10 if( defined($value) );
  } elsif($cmd eq "pct") {
*****

***** 31_HUEDevice_GITHUB.pm
    $joined =~ s/on-till\s+[^\s]+//g; #bad workaround for: https://forum.fhem.de/index.php/topic,61636.msg728557.html#msg728557

    my @cmds = split(":", $joined);
***** 31_HUEDEVICE.PM
    $joined =~ s/on-till\s+[^\s]+//g; #bad workaround for: https://forum.fhem.de/index.php/topic,61636.msg728557.html#msg728557
    my @cmds = split(":", $joined);
*****

***** 31_HUEDevice_GITHUB.pm
      $result = HUEDevice_ReadFromServer($hash,"$hash->{ID}/action",\%obj);
    } else {
***** 31_HUEDEVICE.PM
      $result = HUEDevice_ReadFromServer($hash,"$hash->{ID}/action",\%obj);
    } elsif ( $cmd eq "bridgeupdatestate" ) {
      $result = HUEDevice_ReadFromServer($hash,"$hash->{ID}/bridgeupdatestate",\%obj);
    } else {
*****

***** 31_HUEDevice_GITHUB.pm

  my $list = "off:noArg on:noArg toggle:noArg statusRequest:noArg";
  $list .= " pct:colorpicker,BRI,0,1,100 bri:colorpicker,BRI,0,1,254" if( $subtype =~ m/dimmer/ );
***** 31_HUEDEVICE.PM

  my $list = "off:noArg on:noArg toggle:noArg statusRequest:noArg bridgeupdatestate";
  $list .= " pct:colorpicker,BRI,0,1,100 bri:colorpicker,BRI,0,1,254" if( $subtype =~ m/dimmer/ );
*****

***** 31_HUEDevice_GITHUB.pm
                $list .= " scene:". join(",", sort grep { defined } map { if( !containsOneOfMyLights($scenes->{$_}{lights}) ) {



***** 31_HUEDEVICE.PM
                $list .= " scene:". join(",", sort grep { defined } map { if( !containsOneOfMyLights($scenes->{$_}{lights}) ) {


*****


Beste Grüße
Sebastian

FunkOdyssey

@justme1968: Hast du Lust, diese Änderung auch aufzunehmen?
https://forum.fhem.de/index.php/topic,105281.msg993260.html#msg993260

Sorry fürs Crossposting, aber ich wusste nicht, ob du das mitbekommst.

justme1968

#1671
@Lippie: sorry. nicht ganz. bitte nimm diff wie oben geschrieben. nicht fc.

ps: bitte nicht falsch verstehen. ich hätte nicht gedacht das es so viele interpretationsmöglichkeiten von ,bitte mach ein diff' gibt. wer findet noch welche?
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

FunkOdyssey

Ich stelle beim Starten einige Hinweise im Log fest.
Ist das normal, dass beim Starten von FHEM zuerst eine Meldung erscheint, dass kein IO-Device zugeordnet ist und dann danach die Zuordnung protokolliert wird?

2019.11.17 12:05:20.605 1:  zigbee_lampe: no I/O device
...
2019.11.17 12:05:22.111 3:  zigbee_lampe: I/O device is deCONZ

justme1968

#1673
aus irgendeinem grund ist on deinem
config file das io device nach den lampen definiert.

hast du etwas von hand editiert?

oder hast du nachträglich mal das io device geändert?
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

FunkOdyssey

Danke für deinen Tipp. Darauf hätte ich kommen können. Sorry.

Ich nehme keine direkten Änderungen in der fhem.cfg vor.
Bis jetzt gerade. Ich habe die Bridge weiter nach oben verschoben.

Jetzt habe ich im fhem.log nur noch:
2019.11.17 17:29:17.823 3:  zigbee_lampe: I/O device is deCONZ

Dies scheint normal zu sein.

Lippie

Zitat von: justme1968 am 17 November 2019, 10:38:03
@Lippie: sorry. nicht ganz. bitte nimm diff wie oben geschrieben. nicht fc.

Hi, nächster Versuch:

--- 30_HUEBridge_GITHUB.pm 2019-11-07 07:21:01.315747932 +0100
+++ 30_HUEBridge.pm 2019-11-17 18:49:15.404672388 +0100
@@ -1832,6 +1832,17 @@
         }
       }

+    } elsif( $type =~ m/^lights\/(\d*)\/bridgeupdatestate$/ ) {
+      if( $queryAfterSet ) {
+        my $chash = $param->{chash};
+        if( $chash->{helper}->{update_timeout} ) {
+          RemoveInternalTimer($chash);
+          InternalTimer(gettimeofday()+1, "HUEDevice_GetUpdate", $chash, 0);
+        } else {
+          RemoveInternalTimer($chash);
+          HUEDevice_GetUpdate( $chash );
+        }
+      }
     } elsif( $type =~ m/^groups\/(\d*)\/action$/ ) {
       my $chash = $param->{chash};
       if( $chash->{helper}->{update_timeout} ) {


und:

--- 31_HUEDevice_GITHUB.pm 2019-11-07 07:15:04.734109647 +0100
+++ 31_HUEDevice.pm 2019-11-07 07:15:04.822709439 +0100
@@ -1,5 +1,5 @@

-# $Id$
+# $Id: 31_HUEDevice.pm 19961 2019-08-07 13:30:18Z justme1968 $ edit by SL

# "Hue Personal Wireless Lighting" is a trademark owned by Koninklijke Philips Electronics N.V.,
# see www.meethue.com for more information.
@@ -448,6 +448,19 @@
       $cmd = "off";
       $value = $value2;
     }
+
+  if($cmd eq "pct" && $value == 0 ) {
+    $cmd = "off";
+    $value = $value2;
+  }
+  if($cmd eq "bridgeupdatestate" ) {
+    if($value eq "on" && !defined($value2)){
+ $value = 100;
+ }elsif($value eq "off"){
+ $value = 0;
+ }elsif($value eq "on" && defined($value2)){
+ $value = $value2;
+ }
   }

   if($cmd eq 'on') {
@@ -461,6 +474,23 @@
     $obj->{'on'}  = JSON::false;
     $obj->{'transitiontime'} = $value * 10 if( defined($value) );

+  } elsif($cmd eq 'bridgeupdatestate') {
+    if ( $value == 0 ) {
+ $obj->{'on'}  = JSON::false;
+ $obj->{'bri'}  = int(0);
+ }else{
+ my $bri;
+ if( $value > 50 ) {
+   $bri = 2.57 * ($value-50) + 128;
+ } else {
+   $bri = 2.59 * ($value-50) + 128;
+ }
+ $bri = 0 if( $bri < 0 );
+ $bri = 254 if( $bri > 254 );
+ $obj->{'on'}  = JSON::true;
+ $obj->{'bri'}  = int($bri);
+ }
+    $obj->{'transitiontime'} = $value * 10 if( defined($value) );
   } elsif($cmd eq "pct") {
     if( $subtype  eq 'blind' ) {
       $obj->{'pct'}  = int($value);
@@ -876,6 +906,8 @@
     if( $hash->{helper}->{devtype} eq 'G' ) {
       $hash->{helper}->{update} = 1;
       $result = HUEDevice_ReadFromServer($hash,"$hash->{ID}/action",\%obj);
+    } elsif ( $cmd eq "bridgeupdatestate" ) {
+      $result = HUEDevice_ReadFromServer($hash,"$hash->{ID}/bridgeupdatestate",\%obj);
     } else {
       $result = HUEDevice_ReadFromServer($hash,"$hash->{ID}/state",\%obj);
     }
@@ -904,7 +936,7 @@

   my $subtype = AttrVal($name, "subType", "extcolordimmer");

-  my $list = "off:noArg on:noArg toggle:noArg statusRequest:noArg";
+  my $list = "off:noArg on:noArg toggle:noArg statusRequest:noArg bridgeupdatestate";
   $list .= " pct:colorpicker,BRI,0,1,100 bri:colorpicker,BRI,0,1,254" if( $subtype =~ m/dimmer/ );
   $list .= " rgb:colorpicker,RGB" if( $subtype =~ m/color/ );
   $list .= " color:colorpicker,CT,2000,1,6500 ct:colorpicker,CT,154,1,500" if( $subtype =~ m/ct|ext/ );


Ich arbeite sonst in notepad++ mit compare. Das zeigt die Unterschiede auch in Farbe an  ;)
Ich hoffe, damit die erwartete Ausgabevariante getroffen zu haben. Wenn nicht, schreib mir bitte die Parameter, mit denen du arbeitest.

VG
Sebastian

justme1968

ok. so passt es. fast.

ich habe noch ein paar fragen:

- zeig mal bitte ein list von einem solchen HUEDevice
  kann man an irgendetwas erkennen das es zu einer ha bridge gehört?

- zeig mal ein list von einer ha bridge HUEBridge
  kann man an irgendetwas erkennen das es eine ha bridge ist?

- laut doku ist der erlaubte bereich für bri 1-254 du setzt aber im off fall bri auf 0. das
  müsste einen fehler produzieren. wenn nicht jetzt dann irgendwann mal. ich glaube es wäre
  besser mit bri und 1-254 zu arbeiten. ohne hin und her rechnen.

- können wir deinen vorschlag zur syntax ändern?
  ich würde lieber so etwas machen:
    set <device> habridgestate : on : bri 254
    set <device> habridgestate : off
  d.h. ein kommando das im namen habridge hat und dann das verketten von kommandos
  das im modul sowieso eingebaut ist. der code würde dann ein ganz normales json $obj
  erzeugen wie es für das absetzen eines kommandos sonst auch verwendet wird und
  zusätzlich im json noch $obj->{habridgestate} setzen.

  im bridge modul wird dann anhand des vorhanden seins von habridgestate entschieden ob
  .../state oder .../bridgeupdatestate aufgerufen wird.


hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

justme1968

ich habe mal eine version eingecheckt. schau mal ob das funktioniert.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

Lippie

Hi,

Du hast Recht, der Wertebereich liegt zwischen 1 und 254. Die HABridge übernimmt tatsächlich auch die 0, weshalb ich bisher noch keine Probleme bekommen habe.

Da die Möglichkeiten (on,off,bri-wert) nicht all zu groß sind, habe ich alles zusammengefasst und entsprechend ausgewertet.
Du kannst die Syntax auch abändern, ich habe ja auch noch keine Hilfe dazu verfasst. Wichtig ist nur, dass man mit einem Befehl on/off und bri ändern kann.

Hier meine lists:

Internals:
   DEF        192.168.2.66:8081
   FUUID      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   FVERSION   30_HUEBridge.pm:0.198540/2019-07-19
   INTERVAL   60
   NAME       HABridge
   NOTIFYDEV  global
   NR         271
   NTFY_ORDER 50-HABridge
   STATE      connected
   TYPE       HUEBridge
   apiversion 1.19.0
   host       192.168.2.66:8081
   mac        84:39:BE:62:24:23
   manufacturer Royal Philips Electronics
   modelName  Philips hue bridge 2015
   modelid    BSB002
   name       HA-Bridge
   swversion  1705121051
   updatestate 0
   zigbeechannel 6
   READINGS:
     2019-11-26 07:03:15   state           connected
   helper:
     apiversion 70400
     count      0
     last_config_timestamp 1574748195
     offsetUTC  3600
     updatestate 0
     groups:
       1:
         name       hgrp-0000000160
         type       LightGroup
         action:
           alert      none
           bri        0
           colormode  xy
           ct         153
           effect     none
           hue        0
           sat        0
           xy:
             0.3146
             0.3303
         lights:
           7
           5
         state:
       2:
         name       hgrp-0000016370
         type       LightGroup
         action:
           alert      none
           bri        0
           colormode  xy
           ct         153
           effect     none
           hue        0
           sat        0
           xy:
             0.3146
             0.3303
         lights:
           1
           10
           7
           5
           6
           8
           13
           12
           4
           9
           11
         state:
       3:
         name       hgrp-0000004256
         type       LightGroup
         action:
           alert      none
           bri        0
           colormode  xy
           ct         153
           effect     none
           hue        0
           sat        0
           xy:
             0.3146
             0.3303
         lights:
           12
           7
           5
         state:
     lights:
       1:
         manufacturername Philips
         modelid    LWB007
         name       Stehlampe Wohnen
         swversion  66012040
         type       Dimmable light
         uniqueid   00:17:88:5E:D3:01-01
         state:
           alert      none
           bri        254
       10:
         manufacturername Philips
         modelid    LWB007
         name       Licht Flur
         swversion  66012040
         type       Dimmable light
         uniqueid   00:17:88:5E:D3:0A-0A
         state:
           alert      none
           bri        0
       100:
         manufacturername Philips
         modelid    LWB007
         name       Licht Gaeste
         swversion  66012040
         type       Dimmable light
         uniqueid   00:17:88:5E:D3:64-00
         state:
           alert      none
           bri        100
     scenes:
Attributes:
   httpUtils  1
   key        yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
   pollDevices 1
   queryAfterSet 0
   room       HUEDevice
   verbose    2


Internals:
   CHANGED   
   DEF        13  IODev=HABridge
   FUUID      xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   FVERSION   31_HUEDevice.pm:0.199610/2019-08-07
   ID         13
   INTERVAL   
   IODev      HABridge
   NAME       HUEDevice13
   NR         288
   STATE      off
   TYPE       HUEDevice
   manufacturername Philips
   modelid    LWB007
   name       Licht Wohnen klein
   swversion  66012040
   type       Dimmable light
   uniqueid   00:17:88:5E:D3:0D-0D
   READINGS:
     2019-11-14 20:37:22   SyncConter      0
     2019-11-17 22:49:18   alert           none
     2019-11-17 22:49:18   bri             0
     2019-02-12 22:21:04   colormode       xy
     2019-11-17 22:49:18   onoff           0
     2019-11-17 22:49:18   pct             0
     2019-11-17 22:49:18   reachable       1
     2019-02-12 22:21:04   rgb             000000
     2019-11-17 22:49:18   state           off
     2019-02-12 22:21:04   xy              0,0
   helper:
     alert      none
     bri        0
     colormode 
     ct         -1
     devtype   
     effect     
     hue        -1
     on         0
     pct        0
     reachable  1
     rgb       
     sat        -1
     update_timeout 1
     xy         
Attributes:
   IODev      HABridge
   alias      kleine Lampe Wohnzimmer
   cmdIcon    on:general_an off:general_aus statusRequest:refresh
   color-icons 2
   devStateIcon {(HUEDevice_devStateIcon($name),"toggle")}
   group      Licht
   icon       hue_filled_white_and_color_e27_b22
   model      LWB001
   room       HUEDevice
   subType    dimmer
   verbose    2
   webCmd     pct:on:off:statusRequest


VG
Sebastian

justme1968

leider schaut es aus als ob man am device nicht wirklich erkennt ob es eine habridge ist.das ist doof.

bitte probier mal aus ob meine änderungen von gestern funktionieren.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968