Falscher Status durch HomeMaticHomeKitGarageDoorService vs HomeMaticCacheManager
Hallo Thomas,

ich habe einen GDS eingerichtet mit einem HmIP-SWDM-B2 als CLOSE Sensor und einem HmIP-WGC Garagentaster. Funktion OK, Anzeige nicht. Tor immer geschlossen.
Während dem Öffnen zeigt HomeKit zwar "Wird geöffnet" an, danach aber wieder "Geschlossen"

Mein Setup:
v0.1.231
"services":
                [ { "type": "HM-THKL-GARAGEDOOR", "service": "HomeMaticHomeKitGarageDoorService" } ] ,
 "special":
                [ {                                           
		"name" : "Garage",                          
    		"type" : "HM-THKL-GARAGEDOOR",              
    		"parameter" : {                          
        	"address_sensor_close": "**HmIP-RF.0015599393F1CA**:1.STATE",
        	"state_sensor_close": 0,                             
        	"address_actor_open": "HmIP-RF.00131A499B8D11:3.STATE",  
        	"message_actor_open": {"on":true,"off":false},           
        	"delay_actor_open" :1                                    
                 			}
                 }      
       
Datenpunkte:
<channel name="Garagentor 1" ise_id="3077" index="1" visible="true" operate="true">
<datapoint name="**HmIP-RF.0015599393F1CA:1.STATE**" type="STATE" ise_id="3078" value="0" valuetype="16" valueunit="""" timestamp="1590507755" operations="5"/>


Als Grund konnte ich Cache Eintrag für den CLOSE Sensor ausmachen. Dieser wird wie es aussieht nur beim Start der Homebridge gesetzt und später immer wieder verwendet.


**_Tor geschlossen >> State 0 >> OK_**
5/26/2020, 5:33:06 PM] [HomeMatic Produktiv] [GDS] One sensor mode. Fetching value for Close Sensor **HmIP-RF.0015599393F1CA:1.STATE**
[5/26/2020, 5:33:06 PM] [HomeMatic Produktiv] [Generic] transformDatapoint HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:33:06 PM] [HomeMatic Produktiv] [Cache] remove :HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:33:06 PM] [HomeMatic Produktiv] [Core] getValue (HmIP-RF) HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:33:06 PM] [HomeMatic Produktiv] [Core] check cache HmIP-RF.0015599393F1CA:1.STATE
**[5/26/2020, 5:33:06 PM] [HomeMatic Produktiv] [Cache] hit on HmIP-RF.0015599393F1CA:1.STATE 0**

[5/26/2020, 5:33:37 PM] [HomeMatic Produktiv] [GDS] garage door requery sensors ...
[5/26/2020, 5:33:37 PM] [HomeMatic Produktiv] [Generic] transformDatapoint HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:33:37 PM] [HomeMatic Produktiv] [Cache] remove :HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:33:37 PM] [HomeMatic Produktiv] [Core] getValue (HmIP-RF) HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:33:37 PM] [HomeMatic Produktiv] [Core] check cache HmIP-RF.0015599393F1CA:1.STATE
**[5/26/2020, 5:33:37 PM] [HomeMatic Produktiv] [Cache] hit on HmIP-RF.0015599393F1CA:1.STATE 0**
[5/26/2020, 5:33:37 PM] [HomeMatic Produktiv] [GDS] result for close sensor 0

**_Tor  geöffnet >> State 0 aus cache >> Falsch_**
[5/26/2020, 5:35:47 PM] [HomeMatic Produktiv] [Generic] transformDatapoint HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:35:47 PM] [HomeMatic Produktiv] [Cache] remove :HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:35:47 PM] [HomeMatic Produktiv] [Core] getValue (HmIP-RF) HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:35:47 PM] [HomeMatic Produktiv] [Core] check cache HmIP-RF.0015599393F1CA:1.STATE
**[5/26/2020, 5:35:47 PM] [HomeMatic Produktiv] [Cache] hit on HmIP-RF.0015599393F1CA:1.STATE 0**
[5/26/2020, 5:35:47 PM] [HomeMatic Produktiv] [GDS] get close value result is 0
[5/26/2020, 5:35:47 PM] [HomeMatic Produktiv] [GDS] values match close state


Ab hier ohne Cache durch Änderung der HomeMaticCacheManager.js
Rückgabewert immer undefined

HomeMaticCacheManager.prototype.getValue = function (address) {
  let cv = this.cache[address]
  if (cv) {
    this.log.debug('[Cache] hit on %s %s', address, cv)
    // return cv  
    **return undefined**
  } else {
    this.log.debug('[Cache] fail on %s', address)
    return undefined
 }


**_Zustand: Tor geschlossen >> Cache leer >> failed >> State 0 >> OK_**
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [GDS] One sensor mode. Fetching value for Close Sensor HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [Generic] transformDatapoint HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [Cache] remove :HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [Core] getValue (HmIP-RF) HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [Core] check cache HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [Cache] fail on HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [Core] cache failed for  HmIP-RF.0015599393F1CA:1.STATE will transfer request to rega
**[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [Core] rega result for HmIP-RF.0015599393F1CA:1.STATE is 0**
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [Cache] write 0 for HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [GDS] get close value result is 0
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [GDS] values match close state
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [Generic] transformDatapoint STATE
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [Generic] cache .STATE (0)
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [Generic] datapointEvent STATE with 0 channel HmIP-RF.0015599393F1CA:1
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [GDS] garage event CH:HmIP-RF.0015599393F1CA:1|DP:STATE|NV:0|TCS:false
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [GDS] One Sensor Mode Close is 0
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [GDS] is sensor Close Event
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] Check 0 (string) will match StateSensorClose 0 (number) - true
[5/26/2020, 5:38:20 PM] [HomeMatic Produktiv] [GDS] Close sensor hm value is 0 set targetDoorState 1
[5/26/2020, 5:38:21 PM] [HomeMatic Produktiv] [GDS] timer fired close sensor hm value is 0 set new current state 1


**_Zustand Tor geöffnet >> cache failed erzwungen >> rega >> State 1 >> Korrekt._**
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [GDS] garage door requery sensors ...
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [Generic] transformDatapoint HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [Cache] remove :HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [Core] getValue (HmIP-RF) HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [Core] check cache HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [Cache] **hit on HmIP-RF.0015599393F1CA:1.STATE 0**
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [Core] cache failed for  HmIP-RF.0015599393F1CA:1.STATE will transfer request to rega
**[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [Core] rega result for HmIP-RF.0015599393F1CA:1.STATE is 1**
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [Cache] write 1 for HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [GDS] result for close sensor 1
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [Generic] transformDatapoint STATE
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [Generic] cache .STATE (1)
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [Generic] datapointEvent STATE with 1 channel HmIP-RF.0015599393F1CA:1
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [GDS] garage event CH:HmIP-RF.0015599393F1CA:1|DP:STATE|NV:1|TCS:false
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [GDS] One Sensor Mode Close is 0
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [GDS] is sensor Close Event
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] Check 1 (string) will match StateSensorClose 0 (number) - false
[5/26/2020, 5:39:35 PM] [HomeMatic Produktiv] [GDS] Close sensor hm value is 1 set targetDoorState 0
[5/26/2020, 5:39:36 PM] [HomeMatic Produktiv] [GDS] timer fired close sensor hm value is 1 set new current state 0


**_Tor geschlossen >> cache failed erzwungen >> rega >> State 0 >> Korrekt._**
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [GDS] garage door requery sensors ...
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [Generic] transformDatapoint HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [Cache] remove :HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [Core] getValue (HmIP-RF) HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [Core] check cache HmIP-RF.0015599393F1CA:1.STATE
**[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [Cache] hit on HmIP-RF.0015599393F1CA:1.STATE 1**
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [Core] cache failed for  HmIP-RF.0015599393F1CA:1.STATE will transfer request to rega
**[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [Core] rega result for HmIP-RF.0015599393F1CA:1.STATE is 0**
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [Cache] write 0 for HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [GDS] result for close sensor 0
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [Generic] transformDatapoint STATE
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [Generic] cache .STATE (0)
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [Generic] datapointEvent STATE with 0 channel HmIP-RF.0015599393F1CA:1
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [GDS] garage event CH:HmIP-RF.0015599393F1CA:1|DP:STATE|NV:0|TCS:false
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [GDS] One Sensor Mode Close is 0
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [GDS] is sensor Close Event
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] Check 0 (string) will match StateSensorClose 0 (number) - true
[5/26/2020, 5:40:17 PM] [HomeMatic Produktiv] [GDS] Close sensor hm value is 0 set targetDoorState 1
[5/26/2020, 5:40:18 PM] [HomeMatic Produktiv] [GDS] timer fired close sensor hm value is 0 set new current state 1


**_Tor geöffnet >> cache failed erzwungen >> rega >> State 1 >> Korrekt._**
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [GDS] garage door requery sensors ...
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [Generic] transformDatapoint HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [Cache] remove :HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [Core] getValue (HmIP-RF) HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [Core] check cache HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [Cache] hit on HmIP-RF.0015599393F1CA:1.STATE 0
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [Core] cache failed for  HmIP-RF.0015599393F1CA:1.STATE will transfer request to rega
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [Core] rega result for HmIP-RF.0015599393F1CA:1.STATE is 1
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [Cache] write 1 for HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [GDS] result for close sensor 1
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [Generic] transformDatapoint STATE
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [Generic] cache .STATE (1)
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [Generic] datapointEvent STATE with 1 channel HmIP-RF.0015599393F1CA:1
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [GDS] garage event CH:HmIP-RF.0015599393F1CA:1|DP:STATE|NV:1|TCS:false
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [GDS] One Sensor Mode Close is 0
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [GDS] is sensor Close Event
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] Check 1 (string) will match StateSensorClose 0 (number) - false
[5/26/2020, 5:41:32 PM] [HomeMatic Produktiv] [GDS] Close sensor hm value is 1 set targetDoorState 0
[5/26/2020, 5:41:33 PM] [HomeMatic Produktiv] [GDS] timer fired close sensor hm value is 1 set new current state 0


**_Tor geschlossen >> cache failed erzwungen >> rega >> State 0 >> Korrekt_**
[[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [GDS] garage door requery sensors ...
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [Generic] transformDatapoint HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [Cache] remove :HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [Core] getValue (HmIP-RF) HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [Core] check cache HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [Cache] hit on HmIP-RF.0015599393F1CA:1.STATE 1
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [Core] cache failed for  HmIP-RF.0015599393F1CA:1.STATE will transfer request to rega
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [Core] rega result for HmIP-RF.0015599393F1CA:1.STATE is 0
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [Cache] write 0 for HmIP-RF.0015599393F1CA:1.STATE
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [GDS] result for close sensor 0
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [Generic] transformDatapoint STATE
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [Generic] cache .STATE (0)
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [Generic] datapointEvent STATE with 0 channel HmIP-RF.0015599393F1CA:1
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [GDS] garage event CH:HmIP-RF.0015599393F1CA:1|DP:STATE|NV:0|TCS:false
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [GDS] One Sensor Mode Close is 0
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [GDS] is sensor Close Event
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] Check 0 (string) will match StateSensorClose 0 (number) - true
[5/26/2020, 5:42:44 PM] [HomeMatic Produktiv] [GDS] Close sensor hm value is 0 set targetDoorState 1
[5/26/2020, 5:42:45 PM] [HomeMatic Produktiv] [GDS] timer fired close sensor hm value is 0 set new current state 1


Ohne Cache also alles korrekt.
Den Cache abzuklemmen ist ja nur ein Quick&Dirty Workaround.
Könnte man ggf drüber nachdenken den Cache für bestimmte Sensoren über die Config zu deaktivieren? xxxx_sensor_cache=false oder sowas ?
Für sicherheitsrelevante Sensoren macht das sicher Sinn.

Gruß
Norbert