test: modul zu integration von homebridge geräten in fhem

Begonnen von justme1968, 12 März 2021, 22:45:59

Vorheriges Thema - Nächstes Thema

justme1968

zeig mal bitte ein jsonlist2 vom device und die ausgabe von set <name> ?
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

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

HansDampfHH

jsonlist

{
  "Arg":"homekitDevice_58bf147f0fc53cd584c1bf47fb30a7c3748f1b76b61e9358da196b19d",
  "Results": [
  {
    "Name":"homekitDevice_58bf147f0fc53cd584c1bf47fb30a7c3748f1b76b61e9358da196b19d",
    "PossibleSets":"Active: RotationSpeed:slider,0,0.5,100,1 LockPhysicalControls:0,1 SwingMode: RotationDirection:0,1 ",
    "PossibleAttrs":"alias comment:textField-long eventMap:textField-long group room suppressReading userattr userReadings:textField-long verbose:0,1,2,3,4,5  disable disabledForIntervals #readingList #setExtensionsEvent:1,0 setList IODev event-aggregator event-min-interval event-on-change-reading event-on-update-reading oldreadings stateFormat:textField-long timestamp-on-change-reading DbLogExclude DbLogInclude DbLogValueFn:textField-long alarmDevice:Actor,Sensor alarmSettings alexaName alexaProactiveEvents:1,0 alexaRoom batteryChange cmdIcon devStateIcon devStateIcon:textField-long devStateStyle genericDeviceType:security,ignore,switch,outlet,light,blind,thermometer,thermostat,contact,garage,window,lock,scene homebridgeMapping:textField-long icon room_map setList sortby structexclude webCmd webCmdLabel:textField-long widgetOverride",
    "Internals": {
      "CFGFN": "",
      "DEF": "58bf147f0fc53cd584c1bf47fb30a7c3748f1b76b61e9358da196b19d",
      "FUUID": "61df25a7-f33f-1920-8946-b20ac6e876ee5bb1",
      "IODev": "Homebridge",
      "NAME": "homekitDevice_58bf147f0fc53cd584c1bf47fb30a7c3748f1b76b61e9358da196b19d",
      "NR": "29057",
      "STATE": "???",
      "TYPE": "homekitDevice",
      "type": "Fanv2 [Active,CurrentFanState,RotationSpeed,LockPhysicalControls,SwingMode,RotationDirection]",
      "uniqueId": "58bf147f0fc53cd584c1bf47fb30a7c3748f1b76b61e9358da196b19d"
    },
    "Readings": {
      "Active": { "Value":"0", "Time":"2022-01-12 20:02:00" },
      "CurrentFanState": { "Value":"0", "Time":"2022-01-12 20:02:00" },
      "IODev": { "Value":"Homebridge", "Time":"2022-01-12 20:01:59" },
      "LockPhysicalControls": { "Value":"0", "Time":"2022-01-12 20:02:00" },
      "RotationDirection": { "Value":"1", "Time":"2022-01-12 20:02:00" },
      "RotationSpeed": { "Value":"0", "Time":"2022-01-12 20:02:00" },
      "SwingMode": { "Value":"0", "Time":"2022-01-12 20:02:00" }
    },
    "Attributes": {
      "DbLogExclude": ".*",
      "IODev": "Homebridge",
      "alias": "Xiaomi Fan 2",
      "room": "Steuerung"
    }
  }  ],
  "totalResultsReturned":1
}



set Active 1

2022.01.12 20:04:50 4: Homebridge: posting data to http://192.168.148.46:8581/api/accessories/58bf147f0fc53cd584c1bf47fb30a7c3748f1b76b61e9358da196b19d: {"characteristicType": "Active", "value": "1" }
2022.01.12 20:04:50 5: Homebridge: HttpAnswer: HTTP/1.1 200 OK
Content-Security-Policy: default-src 'self';script-src 'self' 'unsafe-inline' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data: https://raw.githubusercontent.com https://user-images.githubusercontent.com;connect-src 'self' https://openweathermap.org https://api.openweathermap.org wss://192.168.148.46:8581 ws://192.168.148.46:8581
X-DNS-Prefetch-Control: off
Expect-CT: max-age=0
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: no-referrer
X-XSS-Protection: 0
vary: Origin
content-type: application/json; charset=utf-8
content-length: 2472
Date: Wed, 12 Jan 2022 19:04:50 GMT
Connection: close


set Active 0

2022.01.12 20:07:36 4: Homebridge: posting data to http://192.168.148.46:8581/api/accessories/58bf147f0fc53cd584c1bf47fb30a7c3748f1b76b61e9358da196b19d: {"characteristicType": "Active", "value": "Active" }
2022.01.12 20:07:36 5: Homebridge: HttpAnswer: HTTP/1.1 200 OK
Content-Security-Policy: default-src 'self';script-src 'self' 'unsafe-inline' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data: https://raw.githubusercontent.com https://user-images.githubusercontent.com;connect-src 'self' https://openweathermap.org https://api.openweathermap.org wss://192.168.148.46:8581 ws://192.168.148.46:8581
X-DNS-Prefetch-Control: off
Expect-CT: max-age=0
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: no-referrer
X-XSS-Protection: 0
vary: Origin
content-type: application/json; charset=utf-8
content-length: 2472
Date: Wed, 12 Jan 2022 19:07:36 GMT
Connection: close
FHEM Docker, CUL868, Zigbee, CCU2, Jeelink

justme1968

ok. mir fällt auf das bei Active und bei SwingMode keine möglichen paramter in der set liste stehen.

kannst du mal bitte die log ausgaben mit verbose 5 im homebridge device zeigen.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

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

HansDampfHH

Okay, ich hoffe das passt so, erst Active 1 und dann Active 0:

2022.01.13 19:36:47 4: Homebridge: posting data to http://192.168.148.46:8581/api/accessories/58bf147f0fc53cd584c1bf47fb30a7c: {"characteristicType": "Active", "value": "1" }
2022.01.13 19:36:47 5: Homebridge: HttpAnswer: HTTP/1.1 200 OK
Content-Security-Policy: default-src 'self';script-src 'self' 'unsafe-inline' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data: https://raw.githubusercontent.com https://user-images.githubusercontent.com;connect-src 'self' https://openweathermap.org https://api.openweathermap.org wss://192.168.148.46:8581 ws://192.168.148.46:8581
X-DNS-Prefetch-Control: off
Expect-CT: max-age=0
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: no-referrer
X-XSS-Protection: 0
vary: Origin
content-type: application/json; charset=utf-8
content-length: 2472
Date: Thu, 13 Jan 2022 18:36:47 GMT
Connection: close
2022.01.13 19:36:47 4: Homebridge: Got Cookie:
2022.01.13 19:36:47 4: Homebridge: received {"aid":2,"iid":2,"uuid":"000000B7-0000-1000-8000-0026BB765291","type":"Fanv2","humanType":"Fanv2","serviceName":"Xiaomi Fan 2","serviceCharacteristics":[{"aid":2,"iid":4,"uuid":"000000B0-0000-1000-8000-0026BB765291","type":"Active","serviceType":"Fanv2","serviceName":"Xiaomi Fan 2","description":"Active","value":0,"format":"uint8","perms":["ev","pr","pw"],"maxValue":1,"minValue":0,"minStep":1,"canRead":true,"canWrite":true,"ev":true},{"aid":2,"iid":5,"uuid":"000000AF-0000-1000-8000-0026BB765291","type":"CurrentFanState","serviceType":"Fanv2","serviceName":"Xiaomi Fan 2","description":"Current Fan State","value":0,"format":"uint8","perms":["ev","pr"],"maxValue":2,"minValue":0,"minStep":1,"canRead":true,"canWrite":false,"ev":true},{"aid":2,"iid":6,"uuid":"00000029-0000-1000-8000-0026BB765291","type":"RotationSpeed","serviceType":"Fanv2","serviceName":"Xiaomi Fan 2","description":"Rotation Speed","value":0,"format":"float","perms":["ev","pr","pw"],"unit":"percentage","maxValue":100,"minValue":0,"minStep":1,"canRead":true,"canWrite":true,"ev":true},{"aid":2,"iid":7,"uuid":"000000A7-0000-1000-8000-0026BB765291","type":"LockPhysicalControls","serviceType":"Fanv2","serviceName":"Xiaomi Fan 2","description":"Lock Physical Controls","value":0,"format":"uint8","perms":["ev","pr","pw"],"maxValue":1,"minValue":0,"minStep":1,"canRead":true,"canWrite":true,"ev":true},{"aid":2,"iid":8,"uuid":"000000B6-0000-1000-8000-0026BB765291","type":"SwingMode","serviceType":"Fanv2","serviceName":"Xiaomi Fan 2","description":"Swing Mode","value":0,"format":"uint8","perms":["ev","pr","pw"],"maxValue":1,"minValue":0,"minStep":1,"canRead":true,"canWrite":true,"ev":true},{"aid":2,"iid":9,"uuid":"00000028-0000-1000-8000-0026BB765291","type":"RotationDirection","serviceType":"Fanv2","serviceName":"Xiaomi Fan 2","description":"Rotation Direction","value":1,"format":"int","perms":["ev","pr","pw"],"maxValue":1,"minValue":0,"minStep":1,"canRead":true,"canWrite":true,"ev":true}],"accessoryInformation":{"Manufacturer":"Xiaomi","Model":"dmaker.fan.p18","Name":"Xiaomi Fan 2","Serial Number":"250630064","Firmware Revision":"1.5.7"},"values":{"Active":0,"CurrentFanState":0,"RotationSpeed":0,"LockPhysicalControls":0,"SwingMode":0,"RotationDirection":1},"instance":{"name":"homebridge","username":"0E:62:CC:81:57:82","ipAddress":"192.168.148.46","port":52198,"services":[],"connectionFailedCount":0},"uniqueId":"58bf147f0fc53cd584c1bf47fb30a7c"}


2022.01.13 19:40:40 4: Homebridge: posting data to http://192.168.148.46:8581/api/accessories/58bf147f0fc53cd584c1bf47fb30a7c: {"characteristicType": "Active", "value": "Active" }
2022.01.13 19:40:40 5: Homebridge: HttpAnswer: HTTP/1.1 200 OK
Content-Security-Policy: default-src 'self';script-src 'self' 'unsafe-inline' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data: https://raw.githubusercontent.com https://user-images.githubusercontent.com;connect-src 'self' https://openweathermap.org https://api.openweathermap.org wss://192.168.148.46:8581 ws://192.168.148.46:8581
X-DNS-Prefetch-Control: off
Expect-CT: max-age=0
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: no-referrer
X-XSS-Protection: 0
vary: Origin
content-type: application/json; charset=utf-8
content-length: 2472
Date: Thu, 13 Jan 2022 18:40:40 GMT
Connection: close
2022.01.13 19:40:40 4: Homebridge: Got Cookie:
2022.01.13 19:40:40 4: Homebridge: received {"aid":2,"iid":2,"uuid":"000000B7-0000-1000-8000-0026BB765291","type":"Fanv2","humanType":"Fanv2","serviceName":"Xiaomi Fan 2","serviceCharacteristics":[{"aid":2,"iid":4,"uuid":"000000B0-0000-1000-8000-0026BB765291","type":"Active","serviceType":"Fanv2","serviceName":"Xiaomi Fan 2","description":"Active","value":0,"format":"uint8","perms":["ev","pr","pw"],"maxValue":1,"minValue":0,"minStep":1,"canRead":true,"canWrite":true,"ev":true},{"aid":2,"iid":5,"uuid":"000000AF-0000-1000-8000-0026BB765291","type":"CurrentFanState","serviceType":"Fanv2","serviceName":"Xiaomi Fan 2","description":"Current Fan State","value":0,"format":"uint8","perms":["ev","pr"],"maxValue":2,"minValue":0,"minStep":1,"canRead":true,"canWrite":false,"ev":true},{"aid":2,"iid":6,"uuid":"00000029-0000-1000-8000-0026BB765291","type":"RotationSpeed","serviceType":"Fanv2","serviceName":"Xiaomi Fan 2","description":"Rotation Speed","value":0,"format":"float","perms":["ev","pr","pw"],"unit":"percentage","maxValue":100,"minValue":0,"minStep":1,"canRead":true,"canWrite":true,"ev":true},{"aid":2,"iid":7,"uuid":"000000A7-0000-1000-8000-0026BB765291","type":"LockPhysicalControls","serviceType":"Fanv2","serviceName":"Xiaomi Fan 2","description":"Lock Physical Controls","value":0,"format":"uint8","perms":["ev","pr","pw"],"maxValue":1,"minValue":0,"minStep":1,"canRead":true,"canWrite":true,"ev":true},{"aid":2,"iid":8,"uuid":"000000B6-0000-1000-8000-0026BB765291","type":"SwingMode","serviceType":"Fanv2","serviceName":"Xiaomi Fan 2","description":"Swing Mode","value":0,"format":"uint8","perms":["ev","pr","pw"],"maxValue":1,"minValue":0,"minStep":1,"canRead":true,"canWrite":true,"ev":true},{"aid":2,"iid":9,"uuid":"00000028-0000-1000-8000-0026BB765291","type":"RotationDirection","serviceType":"Fanv2","serviceName":"Xiaomi Fan 2","description":"Rotation Direction","value":1,"format":"int","perms":["ev","pr","pw"],"maxValue":1,"minValue":0,"minStep":1,"canRead":true,"canWrite":true,"ev":true}],"accessoryInformation":{"Manufacturer":"Xiaomi","Model":"dmaker.fan.p18","Name":"Xiaomi Fan 2","Serial Number":"250630064","Firmware Revision":"1.5.7"},"values":{"Active":0,"CurrentFanState":0,"RotationSpeed":0,"LockPhysicalControls":0,"SwingMode":0,"RotationDirection":1},"instance":{"name":"homebridge","username":"0E:62:CC:81:57:82","ipAddress":"192.168.148.46","port":52198,"services":[],"connectionFailedCount":0},"uniqueId":"58bf147f0fc53cd584c1bf47fb30a7c"}
FHEM Docker, CUL868, Zigbee, CCU2, Jeelink

HansDampfHH

Ist schon etwas her, aber ich hake noch mal nach...der Sommer ist ja bald da ;-)
Konntest du was mit den Log-Ausgabe anfangen?
FHEM Docker, CUL868, Zigbee, CCU2, Jeelink

HansDampfHH

#80
Hm, ist ja doch schlagartig warm geworden und der Fan steht hier nun.
Meinst du, du kannst mir noch mal einen  Rat geben woher dieses "Setting" kommt?
Warum fehlen bei Active und SwingMode die Werte? Setzen kann ich sie mit setList zumindest nicht.


"PossibleSets":"Active: RotationSpeed:slider,0,0.5,100,1 LockPhysicalControls:0,1 SwingMode: RotationDirection:0,1 ",
FHEM Docker, CUL868, Zigbee, CCU2, Jeelink

mcp

Ich ,,hampel" mit dem Modul auch rum ;)

Für einige meiner Probleme mit dem Modul muss ich als Workaround einen reconnect machen, nachdem man 1x etwas gesetzt hat, was danach nicht mehr geht. Ist zwar nicht schön aber so funktioniert es wenigstens ein bisschen besser :)

Ich würde mich über eine Weiterentwicklung von homebridge2fhem sehr freuen.
Maintainer: 98_vitoconnect.pm
Raspberry Pi 4B, 4 GB RAM, 32 GB SD Karte
Raspbian Bullseye 32-bit, FHEM up2date

justme1968

sorry für das lange schweigen. ich knabbere gerade an einer möglichkeit wie man auch nicht-homebridge (d.h. native homekit) geräte aus homekit in fhem verwenden kann und ich glaube ich habe inzwischen auch dafür eine prinzipielle lösung und ich kann aktuell einen luftbefeuchter für den es kein fhem modul und keine weitere schnittstelle gibt über diesen weg aus fhem heraus ansprechen.

bis das ganze sinnvoll für andere zu verwenden ist wird es noch etwas dauern. aber es wird vermutlich dieses jahr noch etwas :).
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

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

mcp

hmm ok, bringt dann aber nichts für Geräte, die HomeKit nicht nativ können.

Das andere Projekt (homebridge2fhem) ist dann also so gesehen tot?

Eigentlich müsste ich jede Minute einen Reconnect machen, weil manchmal einfach nichts aktualisiert wird, jedoch muss ich dann mehrfach am Tag FHEM neu starten, weil sich dein Modul dann irgendwann sporadisch nicht mehr verbinden will und permanent im disconnected Mode bleibt.
Maintainer: 98_vitoconnect.pm
Raspberry Pi 4B, 4 GB RAM, 32 GB SD Karte
Raspbian Bullseye 32-bit, FHEM up2date

Lee181

#84
Hallo zusammen!

Vielen Dank erstmal an @justme1968 für dieses Modul! Es war für mich ein wenig ein Gamechanger, da ich nach einem Weg gesucht habe, den aktuellen Status (An/Aus/Play/Pause) von meinem AppleTV in FHEM auswerten zu können.
Da ich kein Modul gefunden habe, das einen AppleTV direkt anspricht, habe ich es gelöst über die Installation eines Homebridge-Plugins (https://github.com/maxileith/homebridge-appletv-enhanced) und dem Modul von justme1968 aus diesem Thread.

Damit das funktioniert, musste ich folgende Änderungen vornehmen:

- in der Datei 39_homebridge.pm habe ich geändert bzw. auskommentiert:

Zeile 297
ORIGINAL
        next if( $accessory->{type} eq 'Television' );
NEU
#        next if( $accessory->{type} eq 'Television' );
Somit wird der AppleTV schonmal (nach einem reconnect des FHEM-Moduls) erkannt!

- Weiterhin habe ich in der Datei 39_homekitDevice.pm noch folgendes eingefügt bzw. geändert:

ORIGINAL:
my $readings = {             On => 'state',
             CurrentTemperature => 'temperature',
        CurrentRelativeHumidity => 'humidity',
                 MotionDetected => 'motion',
                CurrentPosition => '',
                 TargetPosition => 'pct',
                  PositionState => 'motor',
              OccupancyDetected => 'presence',
               CurrentDoorState => 'state',
             ContactSensorState => 'state',
               StatusLowBattery => 'battery',
              TargetTemperature => 'desired',
              TargetTemperature => 'desired',
      TargetHeatingCoolingState => 'mode',
     CurrentHeatingCoolingState => '',
               };

my $values = {
                           On => { 0 => 'off',
                                   1 => 'on', },
               MotionDetected => { 0 => 'nomotion',
                                   1 => 'motion', },
                PositionState => { 0 => 'down',
                                   1 => 'up',
                                   2 => 'stopped', },
            OccupancyDetected => { 0 => 'absent',
                                   1 => 'present', },
             CurrentDoorState => { 0 => 'open',
                                   1 => 'closed', },
           ContactSensorState => { 0 => 'closed',
                                   1 => 'open', },
             StatusLowBattery => { 0 => 'ok',
                                   1 => 'low', },
    TargetHeatingCoolingState => { 0 => 'off',
                                   1 => 'heat',
                                   2 => 'cool',
                                   3 => 'auto', },
      TemperatureDisplayUnits => { 0 => 'celsius',
                                   1 => 'fahrenheit', },
             };

NEU:
my $readings = {             On => 'state',

# für AppleTV eingefügt
             Active => 'state',

             CurrentTemperature => 'temperature',
        CurrentRelativeHumidity => 'humidity',
                 MotionDetected => 'state',
                CurrentPosition => '',
                 TargetPosition => 'pct',
                  PositionState => 'motor',
              OccupancyDetected => 'presence',
               CurrentDoorState => 'state',
             ContactSensorState => 'state',
               StatusLowBattery => 'battery',
              TargetTemperature => 'desired',
              TargetTemperature => 'desired',
      TargetHeatingCoolingState => 'mode',
     CurrentHeatingCoolingState => '',
               };

my $values = {
                           On => { 0 => 'off',
                                   1 => 'on', },


# für AppleTV eingefügt
                      Active  => { 0 => 'off',
                                   1 => 'on', },
# für AppleTV geändert
               MotionDetected => { 0 => 'off',
                                   1 => 'on', },


                PositionState => { 0 => 'down',
                                   1 => 'up',
                                   2 => 'stopped', },
            OccupancyDetected => { 0 => 'absent',
                                   1 => 'present', },
             CurrentDoorState => { 0 => 'open',
                                   1 => 'closed', },
           ContactSensorState => { 0 => 'closed',
                                   1 => 'open', },
             StatusLowBattery => { 0 => 'ok',
                                   1 => 'low', },
    TargetHeatingCoolingState => { 0 => 'off',
                                   1 => 'heat',
                                   2 => 'cool',
                                   3 => 'auto', },
      TemperatureDisplayUnits => { 0 => 'celsius',
                                   1 => 'fahrenheit', },
             };

Einerseits gibt es jetzt das Basis-Device des AppleTVs, das ich jetzt von FHEM an- und ausschalten kann (Remote-Knöpfe drücken ebenso); das Auslesen des aktuellen Apps (über "ActiveIdentifier") geht auch.
Andererseits werte ich einen über das Homebridge-Plugin bereitgestellten Motion-Sensor aus, ob der AppleTV gerade etwas abspielt oder pausiert.
Das ganze wird dann von diversen DOIFS verwurstet, die dann beim Anschalten des AppleTVs z.B. den Beamer einschalten, das Licht ausmachen (bzw. rückwärts). Und wenn ich auf Pause drücke, geht das Licht leicht gedimmt wieder an bzw. aus.

Soweit so gut... Vielleicht kann ja jemand damit etwas anfangen, daher wollte ich es hier teilen.

ABER: Auch ich laufe leider immer wieder in diesen "disconnected"-Fehler rein. Ich habe es zwar halbgar gelöst, indem ich alle drei Stunden einen automatischen reconnect des Devices mache.

Nur passiert es sporadisch immer wieder, dass nach einem reconnect auch der Status der einzelnen Devices in FHEM sich ohne Zutun kurz ändert (der Status des AppleTVs geht kurzzeitig auf "on" und dann wieder auf "off") und in der Folge nachts im leeren Wohnzimmer das Licht angeht (weil ein DOIF das Licht hochfährt, wenn der AppleTV auf "off" geht).

Gibt es dafür vielleicht eine Lösung?
Ist der Autor an dem Modul noch dran oder ist es verwaist?
Kennt jemand vielleicht einen Weg, mit dem ich direkt von FHEM aus den AppleTV auswerten kann?