ilcato / homebridge-Fibaro-HC2

Homebridge plugin for Fibaro Home Center 2 (and Home Center Lite ...)
Apache License 2.0
66 stars 27 forks source link

Crash when updating thermostat value #97

Closed 0ff closed 6 years ago

0ff commented 6 years ago

Sometimes (i.e. I can't reproduce it), updating a value crashes Homebridge. Seems like the context (this) is missing, any Ideas?

EDIT: I'm running 2.0.8

==> /var/log/homebridge.log <==
[2018-3-26 09:29:59] [FibaroHC2] Setting value to device:  114  parameter: Target Heating Cooling State

==> /var/log/homebridge.err <==
/root/homebridge/node_modules/homebridge-fibaro-hc2/dist/index.js:202
            let setFunction = this.setFunctions.setFunctionsMapping.get(characteristic.UUID);
                                                ^

TypeError: Cannot read property 'setFunctionsMapping' of undefined
    at FibaroHC2.setCharacteristicValue (/root/homebridge/node_modules/homebridge-fibaro-hc2/dist/index.js:202:49)
    at Characteristic.characteristic.on (/root/homebridge/node_modules/homebridge-fibaro-hc2/dist/index.js:186:18)
    at emitMany (events.js:147:13)
    at Characteristic.emit (events.js:224:7)
    at Characteristic.setValue (/root/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:319:10)
    at Bridge.<anonymous> (/root/homebridge/node_modules/hap-nodejs/lib/Accessory.js:867:22)
    at Array.forEach (<anonymous>)
    at Bridge.Accessory._handleSetCharacteristics (/root/homebridge/node_modules/hap-nodejs/lib/Accessory.js:807:8)
    at emitMany (events.js:147:13)
    at HAPServer.emit (events.js:224:7)
    at HAPServer._handleCharacteristics (/root/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:972:10)
    at HAPServer.<anonymous> (/root/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:209:39)
    at emitNone (events.js:106:13)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1056:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
ilcato commented 6 years ago

Are all other devices working right?

0ff commented 6 years ago

Yes, and in fact the very same action works most of the time (which, I know, is weird). Maybe it has to do with how the change is triggered or something? If you can think of anything, please let me know and I'll try helping you debug it.

[2018-3-26 14:56:49] [FibaroHC2] Updating value for device:  106  parameter: Current Heating Cooling State, value: 18.00
[2018-3-26 14:56:49] [FibaroHC2] Updating value for device:  106  parameter: Target Heating Cooling State, value: 18.00
[2018-3-26 14:56:49] [FibaroHC2] Updating value for device:  106  parameter: Current Temperature, value: 18.00
[2018-3-26 14:56:49] [FibaroHC2] Updating value for device:  106  parameter: Target Temperature, value: 18.00
[2018-3-26 14:56:49] [FibaroHC2] Updating value for device:  106  parameter: Temperature Display Units, value: 18.00
[2018-3-26 14:56:49] [FibaroHC2] Updating value for device:  137  parameter: On, value: false
[2018-3-26 15:08:39] [FibaroHC2] Setting value to device:  106  parameter: Target Heating Cooling State
[2018-3-26 15:08:39] [FibaroHC2] Setting value to device:  137  parameter: On
[2018-3-26 15:08:39] [FibaroHC2] Setting value to device:  106  parameter: Target Temperature
[2018-3-26 15:08:39] [FibaroHC2] Command:  turnOn, to: 137
[2018-3-26 15:08:39] [FibaroHC2] Command:  setTargetLevel, value: 20, to: 106
[2018-3-26 15:08:39] [FibaroHC2] Command:  setTime, value: 1522080519, to: 106
[2018-3-26 15:08:41] [FibaroHC2] Updating value for device:  137  parameter: On, value: true
[2018-3-26 15:09:49] [FibaroHC2] Updating value for device:  106  parameter: Current Heating Cooling State, value: 20.00
[2018-3-26 15:09:49] [FibaroHC2] Updating value for device:  106  parameter: Target Heating Cooling State, value: 20.00
[2018-3-26 15:09:49] [FibaroHC2] Updating value for device:  106  parameter: Current Temperature, value: 20.00
[2018-3-26 15:09:49] [FibaroHC2] Updating value for device:  106  parameter: Target Temperature, value: 20.00
[2018-3-26 15:09:49] [FibaroHC2] Updating value for device:  106  parameter: Temperature Display Units, value: 20.00
ilcato commented 6 years ago

Can you look for a "didFinishLaunching" entry in your log? Is there such a log entry before the error log?

0ff commented 6 years ago

Yes, it's there:

[2018-3-26 10:49:20] [FibaroHC2] didFinishLaunching. 
[2018-3-26 10:49:20] [homebridge-libratone.Libratone] Fetching Libratone devices.
[2018-3-26 10:49:20] Homebridge is running on port 51826.
[2018-3-26 10:49:20] [homebridge-libratone.Libratone] Device is now reachable!
[2018-3-26 10:49:20] [FibaroHC2] Loading accessories 
[2018-3-26 10:49:20] [FibaroHC2] Added/changed accessory:  ...
....
[2018-3-26 10:49:21] [homebridge-libratone.Libratone] Device was already restored from state
[2018-3-26 11:24:50] [FibaroHC2] Updating value for device:  200  parameter: Current Temperature, value: 21.37
[2018-3-26 11:36:56] [FibaroHC2] Updating value for device:  200  parameter: Current Temperature, value: 23.37
[2018-3-26 11:41:52] [FibaroHC2] Updating value for device:  200  parameter: Current Temperature, value: 21.50
[2018-3-26 11:51:45] [FibaroHC2] Updating value for device:  200  parameter: Current Temperature, value: 20.43
[2018-3-26 12:30:55] [FibaroHC2] Updating value for device:  200  parameter: Current Temperature, value: 21.37
[2018-3-26 14:56:47] [FibaroHC2] Setting value to device:  137  parameter: On
[2018-3-26 14:56:47] [FibaroHC2] Setting value to device:  106  parameter: Target Heating Cooling State
[2018-3-26 14:56:47] [FibaroHC2] Setting value to device:  106  parameter: Target Temperature
[2018-3-26 14:56:47] [FibaroHC2] Command:  turnOff, to: 137
[2018-3-26 14:56:47] [FibaroHC2] Command:  setTargetLevel, value: 18, to: 106
[2018-3-26 14:56:47] [FibaroHC2] Command:  setTime, value: 1522079807, to: 106
[2018-3-26 14:56:49] [FibaroHC2] Updating value for device:  106  parameter: Current Heating Cooling State, value: 18.00
[2018-3-26 14:56:49] [FibaroHC2] Updating value for device:  106  parameter: Target Heating Cooling State, value: 18.00
[2018-3-26 14:56:49] [FibaroHC2] Updating value for device:  106  parameter: Current Temperature, value: 18.00
[2018-3-26 14:56:49] [FibaroHC2] Updating value for device:  106  parameter: Target Temperature, value: 18.00
[2018-3-26 14:56:49] [FibaroHC2] Updating value for device:  106  parameter: Temperature Display Units, value: 18.00
[2018-3-26 14:56:49] [FibaroHC2] Updating value for device:  137  parameter: On, value: false
[2018-3-26 15:08:39] [FibaroHC2] Setting value to device:  106  parameter: Target Heating Cooling State
[2018-3-26 15:08:39] [FibaroHC2] Setting value to device:  137  parameter: On
[2018-3-26 15:08:39] [FibaroHC2] Setting value to device:  106  parameter: Target Temperature
[2018-3-26 15:08:39] [FibaroHC2] Command:  turnOn, to: 137
[2018-3-26 15:08:39] [FibaroHC2] Command:  setTargetLevel, value: 20, to: 106
[2018-3-26 15:08:39] [FibaroHC2] Command:  setTime, value: 1522080519, to: 106
[2018-3-26 15:08:41] [FibaroHC2] Updating value for device:  137  parameter: On, value: true
[2018-3-26 15:09:49] [FibaroHC2] Updating value for device:  106  parameter: Current Heating Cooling State, value: 20.00
[2018-3-26 15:09:49] [FibaroHC2] Updating value for device:  106  parameter: Target Heating Cooling State, value: 20.00
[2018-3-26 15:09:49] [FibaroHC2] Updating value for device:  106  parameter: Current Temperature, value: 20.00
[2018-3-26 15:09:49] [FibaroHC2] Updating value for device:  106  parameter: Target Temperature, value: 20.00
[2018-3-26 15:09:49] [FibaroHC2] Updating value for device:  106  parameter: Temperature Display Units, value: 20.00
ilcato commented 6 years ago

This is after the crash. Is there a "didFinishLaunching" before [2018-3-26 09:29:59] ?

0ff commented 6 years ago

You're right, sorry! Here's the one before the crash:

[2018-3-26 09:00:15] [FibaroHC2] didFinishLaunching. 

Also, here's somehting very interesting:

[2018-3-26 09:00:15] [FibaroHC2] Error getting data from Home Center:  null

Maybe it has to do with that?

ilcato commented 6 years ago

Yes, the plugin was not able, for some reason, to retrive the device list from Home Center on startup.

ilcato commented 6 years ago

I added a control and exit Homebridge automatically in this case. Will be available in the next release.