skrollme / homebridge-eveatmo

Homebridge plugin which adds a Netatmo weatherstation as HomeKit device and tries to act like Elgato Eve Room/Weather
Apache License 2.0
69 stars 7 forks source link

TypeError: Cannot read property 'time' of undefined #11

Closed DJay-X closed 6 years ago

DJay-X commented 6 years ago

Homebridge crashed after update to 0.3.3

/usr/local/lib/node_modules/homebridge-eveatmo/node_modules/fakegato-history/fakegato-history.js:688
numToHex(swap32(this.history[this.memoryAddress].time - this.refTime - EPOCH_OFFSET), 8),
^
TypeError: Cannot read property 'time' of undefined
at FakeGatoHistory.getCurrentS2R2 (/usr/local/lib/node_modules/homebridge-eveatmo/node_modules/fakegato-history/fakegato-history.js:688:56)
at S2R2Characteristic.emit (events.js:160:13)
at S2R2Characteristic.Characteristic.getValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:162:10)
at Bridge.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:756:20)
at Array.forEach (<anonymous>)
at Bridge.Accessory._handleGetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:720:8)
at HAPServer.emit (events.js:160:13)
at HAPServer._handleCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:926:10)
at HAPServer.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:209:39)
at IncomingMessage.emit (events.js:160:13)
at endReadableNT (_stream_readable.js:1101:12)
at process._tickCallback (internal/process/next_tick.js:152:19)
homebridge.service: main process exited, code=exited, status=1/FAILURE
Unit homebridge.service entered failed state.
homebridge.service holdoff time over, scheduling restart.
Stopping Node.js HomeKit Server...
skrollme commented 6 years ago

Strange, I also installed 0.3.3 immediately and I had no problems. Maybe fakegato tries to access a memory-address in its persistence which does not exists after the just increased storage space. Please try deleting the persistence files (usually located in ./homebridge/) and try restarting again.

DJay-X commented 6 years ago

Thanks. Now I noticed in the log, that this is coming up and then stuck. Maybe something on netatmos site? I use the plugin homebridge-netatmo just only for the heating thermostat and homebridge-eveatmo for the weather sensors. Everything run smooth the last days.

Feb 28 09:23:27 raspberrypi homebridge[2438]: [2018-2-28 09:23:27] [eveatmo platform] WARN - Netatmo: Error: getStationsDataError error: Status code502 Feb 28 09:24:16 raspberrypi homebridge[2438]: [2018-2-28 09:24:16] [netatmo platform] ERROR - Netatmo: Error: Authenticate error: Status code504

skrollme commented 6 years ago

I noticed this morning that there were API-Problems, so I paused homebridge for a while. I just started it again and it seemed to work. Maybe there were some Netatmo-AP hickups.

skrollme commented 6 years ago

Problem is, that homebridge fails completely if Netatmo has API-problems because of the error-handling in the underlying netatmo-api-module in homebridge-eveatmo. I already wrote to the author of the library but did not get an answer so far. I will take a look for an other approach on this.

DJay-X commented 6 years ago

@skrollme Sorry to open this issue again. But the API Problem on the side of netatmo was only a coincidence.

I still get the following error which definitely depends on fakegate-history and eveatmo.

Mär 01 09:44:15 raspberrypi homebridge[519]: [2018-3-1 09:44:15] [eveatmo platform] Loading new data from API for: weatherstation Mär 01 09:45:17 raspberrypi homebridge[519]: /usr/local/lib/node_modules/homebridge-eveatmo/node_modules/fakegato-history/fakegato-history.js:688 Mär 01 09:45:17 raspberrypi homebridge[519]: numToHex(swap32(this.history[this.memoryAddress].time - this.refTime - EPOCH_OFFSET), 8), Mär 01 09:45:17 raspberrypi homebridge[519]: ^ Mär 01 09:45:17 raspberrypi homebridge[519]: TypeError: Cannot read property 'time' of null Mär 01 09:45:17 raspberrypi homebridge[519]: at FakeGatoHistory.getCurrentS2R2 (/usr/local/lib/node_modules/homebridge-eveatmo/node_modules/fakegato-history/fakegato-history.js:688:56) Mär 01 09:45:17 raspberrypi homebridge[519]: at S2R2Characteristic.emit (events.js:160:13) Mär 01 09:45:17 raspberrypi homebridge[519]: at S2R2Characteristic.Characteristic.getValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:162:10) Mär 01 09:45:17 raspberrypi homebridge[519]: at Bridge.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:756:20) Mär 01 09:45:17 raspberrypi homebridge[519]: at Array.forEach (<anonymous>) Mär 01 09:45:17 raspberrypi homebridge[519]: at Bridge.Accessory._handleGetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:720:8) Mär 01 09:45:17 raspberrypi homebridge[519]: at HAPServer.emit (events.js:160:13) Mär 01 09:45:17 raspberrypi homebridge[519]: at HAPServer._handleCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:926:10) Mär 01 09:45:17 raspberrypi homebridge[519]: at HAPServer.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:209:39) Mär 01 09:45:17 raspberrypi homebridge[519]: at IncomingMessage.emit (events.js:160:13) Mär 01 09:45:17 raspberrypi homebridge[519]: at endReadableNT (_stream_readable.js:1101:12) Mär 01 09:45:17 raspberrypi homebridge[519]: at process._tickCallback (internal/process/next_tick.js:152:19) Mär 01 09:45:17 raspberrypi systemd[1]: homebridge.service: main process exited, code=exited, status=1/FAILURE Mär 01 09:45:17 raspberrypi systemd[1]: Unit homebridge.service entered failed state. Mär 01 09:45:28 raspberrypi systemd[1]: homebridge.service holdoff time over, scheduling restart. Mär 01 09:45:28 raspberrypi systemd[1]: Stopping Node.js HomeKit Server...

DJay-X commented 6 years ago

I have now deleted all the xxxx_persist. json files in .homebridge folder and this provided the solution for now. Homebridge no longer crashes when a netatmo device is selected in the Eve App.