SphtKr / homebridge-zway

Homebridge plugin for (better) HomeKit support of RaZBerry and Z-Way Server
ISC License
85 stars 37 forks source link

Danfoss thermostats not detected correctly #27

Closed MSchmidt closed 8 years ago

MSchmidt commented 8 years ago

I just made the switch from the legacy plugin to this one. Unfortunately my thermostats are not detected correctly:

[2016-04-13 14:58:14] Initializing platform accessory 'Flurheizung'...
  ZWayServer Got typeKey thermostat.thermostat_set_point for vdev ZWayVDev_zway_2-0-67-1 +55ms
  ZWayServer { deviceType: 'thermostat', probeTitle: undefined, probeType: 'thermostat_set_point' } +1ms
  ZWayServer WARN: Only the InformationService was successfully configured for ZWayVDev_zway_2-0-67-1! No device services available! +8ms

Response from /ZAutomation/api/v1/devices:

{  
  "data":{  
    "structureChanged":true,
    "updateTime":1460549486,
    "devices":[  
      {  
        "creationTime":1448406190,
        "deviceType":"buttonControl",
        "h":1320850420,
        "hasHistory":true,
        "id":"ZWayVDev_zway_Remote_3-0-0-B",
        "location":0,
        "metrics":{  
          "icon":"",
          "title":"Button Danfoss 0-0",
          "level":"",
          "change":"downstop"
        },
        "permanently_hidden":false,
        "probeType":"",
        "tags":[  

        ],
        "visibility":true,
        "updateTime":1460542651
      },
      {  
        "creationTime":1448406190,
        "deviceType":"buttonControl",
        "h":-2086613195,
        "hasHistory":true,
        "id":"ZWayVDev_zway_Remote_4-0-0-B",
        "location":0,
        "metrics":{  
          "icon":"",
          "title":"Button Danfoss 0-0",
          "level":"",
          "change":"downstop"
        },
        "permanently_hidden":false,
        "probeType":"",
        "tags":[  

        ],
        "visibility":true,
        "updateTime":1460542651
      },
      {  
        "creationTime":1448406191,
        "creatorId":8,
        "deviceType":"battery",
        "h":-592588977,
        "hasHistory":false,
        "id":"BatteryPolling_8",
        "location":0,
        "metrics":{  
          "probeTitle":"Battery",
          "scaleTitle":"%",
          "title":"Battery digest 8",
          "level":66
        },
        "permanently_hidden":false,
        "probeType":"",
        "tags":[  

        ],
        "visibility":true,
        "updateTime":1460549368
      },
      {  
        "creationTime":1448406192,
        "creatorId":1,
        "deviceType":"thermostat",
        "h":1303340796,
        "hasHistory":true,
        "id":"ZWayVDev_zway_2-0-67-1",
        "location":2,
        "metrics":{  
          "scaleTitle":"°C",
          "level":18,
          "min":5,
          "max":40,
          "icon":"thermostat",
          "title":"Flurheizung"
        },
        "permanently_hidden":false,
        "probeType":"thermostat_set_point",
        "tags":[  

        ],
        "visibility":true,
        "updateTime":1460549271
      },
      {  
        "creationTime":1448406192,
        "creatorId":1,
        "deviceType":"battery",
        "h":-927793024,
        "hasHistory":false,
        "id":"ZWayVDev_zway_2-0-128",
        "location":0,
        "metrics":{  
          "probeTitle":"Battery",
          "scaleTitle":"%",
          "level":66,
          "icon":"battery",
          "title":"Battery 2-0 Danfoss"
        },
        "permanently_hidden":false,
        "probeType":"",
        "tags":[  

        ],
        "visibility":true,
        "updateTime":1460549271
      },
      {  
        "creationTime":1448406192,
        "creatorId":1,
        "deviceType":"thermostat",
        "h":-1248816165,
        "hasHistory":true,
        "id":"ZWayVDev_zway_3-0-67-1",
        "location":1,
        "metrics":{  
          "scaleTitle":"°C",
          "level":21,
          "min":5,
          "max":40,
          "icon":"thermostat",
          "title":"Büroheizung"
        },
        "permanently_hidden":false,
        "probeType":"thermostat_set_point",
        "tags":[  

        ],
        "visibility":true,
        "updateTime":1460542945
      },
      {  
        "creationTime":1448406192,
        "creatorId":1,
        "deviceType":"battery",
        "h":-40289343,
        "hasHistory":false,
        "id":"ZWayVDev_zway_3-0-128",
        "location":0,
        "metrics":{  
          "probeTitle":"Battery",
          "scaleTitle":"%",
          "level":69,
          "icon":"battery",
          "title":"Battery 3-0 Danfoss"
        },
        "permanently_hidden":false,
        "probeType":"",
        "tags":[  

        ],
        "visibility":true,
        "updateTime":1460542656
      },
      {  
        "creationTime":1448406192,
        "creatorId":1,
        "deviceType":"thermostat",
        "h":493994170,
        "hasHistory":true,
        "id":"ZWayVDev_zway_4-0-67-1",
        "location":3,
        "metrics":{  
          "scaleTitle":"°C",
          "level":16,
          "min":5,
          "max":40,
          "icon":"thermostat",
          "title":"Wohnheizung"
        },
        "permanently_hidden":false,
        "probeType":"thermostat_set_point",
        "tags":[  

        ],
        "visibility":true,
        "updateTime":1460549368
      },
      {  
        "creationTime":1448406192,
        "creatorId":1,
        "deviceType":"battery",
        "h":847214338,
        "hasHistory":false,
        "id":"ZWayVDev_zway_4-0-128",
        "location":0,
        "metrics":{  
          "probeTitle":"Battery",
          "scaleTitle":"%",
          "level":74,
          "icon":"battery",
          "title":"Battery 4-0 Danfoss"
        },
        "permanently_hidden":false,
        "probeType":"",
        "tags":[  

        ],
        "visibility":true,
        "updateTime":1460549368
      }
    ]
  },
  "code":200,
  "message":"200 OK",
  "error":null
}
SphtKr commented 8 years ago

Hmm! Well, I see the problem. Have you upgraded Z-Way to 2.2.1 or 2.2.2? I haven't done that yet, I wonder if one of those changes the output, because I have Danfoss thermostats (the radiator-attached ones) and that's now how they show up.

MSchmidt commented 8 years ago

Correct - Z-Way 2.2.2 (latest stable) + Danfoss LC-13. Pretty sure the same you use. My guess is that just 2.2.2 changed the API. I was on 2.2.1 with the legacy plugin before and it worked. I've updated Z-Way and switched to homebridge-zway at the same time and immediately blamed homebridge-zway. Probably wrongly so :)

2.2.2 changelog mentions this:

API changes:
[...]
- Setting probeType refactored (moved completely in to ZWave module).
SphtKr commented 8 years ago

Well, the plugin needs updating now, but yeah they changed something. Pretty easy fix and I'm used to it by now. :-)

SphtKr commented 8 years ago

Okay, I've added a new branch, and it's basically a one line fix (or it should be). The branch is here:

https://github.com/SphtKr/homebridge-zway/tree/z-way-2-2-2-fixes

and if you look at the commit (7eac7029ac5136a8193404645d875918a54f5d8a), you can see the one added line. If you can either download a zip of that branch and put it in place of your plugin in node_modules, or just replace index.js or just insert the one line manually, I think you'll be fixed. If you can't try it that way, I can publish the module as an alpha release that you can npm install.

MSchmidt commented 8 years ago

With that commit the thermostats show up in HomeKit but battery and actual thermostat are somehow mangled and when trying to change the temperature the following error appears:

/usr/local/lib/node_modules/homebridge-zway/index.js:386
        return !!this.interlock.value;
                               ^

TypeError: Cannot read property 'value' of undefined
    at Object.ZWayServerAccessory.isInterlockOn (/usr/local/lib/node_modules/homebridge-zway/index.js:386:32)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge-zway/index.js:604:25)
    at emitThree (events.js:97:13)
    at emit (events.js:175:7)
    at Characteristic.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:155:10)
    at Bridge.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:709:22)
    at Array.forEach (native)
    at Bridge.Accessory._handleSetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:654:8)
    at emitThree (events.js:97:13)
    at HAPServer.emit (events.js:175:7)
SphtKr commented 8 years ago

Oh...whoops! That's an unrelated bug. I'll knock that out soon.

SphtKr commented 8 years ago

Okay, try the code in 2e82e6e3d1bbf9354296b318adbb63702fee1393 ... that should at least fix your crash on setting temperature. Can you give me a screenshot about what your seeing with the battery characteristics? That could be a result of moving from the legacy version of the plugin.

MSchmidt commented 8 years ago

Sweet! I've patched those 2 lines and removed the accessory and persist folders to start with a fresh homebridge. All working fine now. Thanks for the quick fixes.

SphtKr commented 8 years ago

Fixed in 3977f25b6ec1292cb7550475087b1a464a0f0cb8.