seydx / homebridge-fritz-platform

AiO Homebridge dynamic platform plugin for AVM hardware like Fritz!Box, Fritz!Repeater etc.
MIT License
225 stars 32 forks source link

Error while adding a non-motion presence sensor #7

Closed flobernd closed 5 years ago

flobernd commented 6 years ago

Hi there,

I just played around with your plugin and tried to add a presence sensor without the "type": "motion" property (works fine with it) and got the following error:

/usr/lib/node_modules/homebridge-fritz-platform/src/accessory.js:2266
    const totallength = accessory.context.fakegatoService.history.length - 1;
                                                          ^

TypeError: Cannot read property 'history' of undefined
    at Fritz_Box.getMotionLastActivation (/usr/lib/node_modules/homebridge-fritz-platform/src/accessory.js:2266:59)
    at Fritz_Box.getService (/usr/lib/node_modules/homebridge-fritz-platform/src/accessory.js:683:63)
    at new Fritz_Box (/usr/lib/node_modules/homebridge-fritz-platform/src/accessory.js:66:85)
    at FritzPlatform.configureAccessory (/usr/lib/node_modules/homebridge-fritz-platform/src/platform.js:501:7)
    at Timeout._onTimeout (/usr/lib/node_modules/homebridge-fritz-platform/src/platform.js:503:34)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)

You might want to add a check before accessing the fakegatoService property (which is not available for occupancy sensors I guess).

Best regards

seydx commented 5 years ago

V3 is out, presence now only as occupancy sensor and without fakegato