LASER-Yi / homebridge-mi-acpartner

XiaoMi AC Partner plugins for HomeBridge(https://github.com/nfarina/homebridge).
MIT License
263 stars 36 forks source link

连续发送红外信号时Homebridge崩溃 #57

Open HarryChen55 opened 6 years ago

HarryChen55 commented 6 years ago

用switchRepeat连续发送红外信号时Homebridge会崩溃。

具体过程如下:

1、Homebridge正常启动,日志显示无任何异常,Mi-Acpartner及所有accessories也正常加载完成;

2、在iOS Home App点击打开switchRepeat开关,红外信号正常发送出去,但是日志显示 Oct 20 22:36:36 HC-Pi homebridge[637]: [10/20/2018, 10:36:36 PM] [XiaoMiAcPartner] [switchRepeat]Failed! TypeError: callback is not a function Oct 20 22:36:36 HC-Pi homebridge[637]: (node:637) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: callback is not a function 此时Homebridge还可以正常工作,其他配件也完全正常;

3、再点击switchRepeat开关,红外信号还是正常发送,Homebridge也正常工作,但日志再次显示 Oct 20 22:36:46 HC-Pi homebridge[637]: [10/20/2018, 10:36:46 PM] [XiaoMiAcPartner] [switchRepeat]Failed! TypeError: callback is not a function Oct 20 22:36:46 HC-Pi homebridge[637]: (node:637) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: callback is not a function

4、重复点击switchRepeat开关4次(包括前两次),红外信号正常,Homebridge也正常,点击第5次的时候Homebridge崩溃,日志显示 Oct 20 22:37:00 HC-Pi homebridge[637]: [10/20/2018, 10:37:00 PM] [XiaoMiAcPartner] [switchRepeat]Failed! TypeError: callback is not a function Oct 20 22:37:00 HC-Pi homebridge[637]: (node:637) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): TypeError: callback is not a function Oct 20 22:37:01 HC-Pi homebridge[637]: /usr/lib/node_modules/homebridge-mi-acpartner/accessories/baseSwitch.js:53 Oct 20 22:37:01 HC-Pi homebridge[637]: this.setSwitchState(value, callback); Oct 20 22:37:01 HC-Pi homebridge[637]: ^ Oct 20 22:37:01 HC-Pi homebridge[637]: ReferenceError: value is not defined Oct 20 22:37:01 HC-Pi homebridge[637]: at platform.syncLock._enterSyncState (/usr/lib/node_modules/homebridge-mi-acpartner/accessories/baseSwitch.js:53:33) Oct 20 22:37:01 HC-Pi homebridge[637]: at syncLockUtil._shift2Queue (/usr/lib/node_modules/homebridge-mi-acpartner/lib/syncLockUtil.js:20:13) Oct 20 22:37:01 HC-Pi homebridge[637]: at syncLockUtil._exitSyncState (/usr/lib/node_modules/homebridge-mi-acpartner/lib/syncLockUtil.js:41:14) Oct 20 22:37:01 HC-Pi homebridge[637]: at Timeout.setTimeout (/usr/lib/node_modules/homebridge-mi-acpartner/accessories/switchRepeat.js:51:44) Oct 20 22:37:01 HC-Pi homebridge[637]: at ontimeout (timers.js:386:11) Oct 20 22:37:01 HC-Pi homebridge[637]: at tryOnTimeout (timers.js:250:5) Oct 20 22:37:01 HC-Pi homebridge[637]: at Timer.listOnTimeout (timers.js:214:5) Oct 20 22:37:01 HC-Pi systemd[1]: homebridge.service: main process exited, code=exited, status=1/FAILURE Oct 20 22:37:01 HC-Pi systemd[1]: Unit homebridge.service entered failed state. Oct 20 22:37:11 HC-Pi systemd[1]: homebridge.service holdoff time over, scheduling restart. Oct 20 22:37:11 HC-Pi systemd[1]: Stopping Node.js HomeKit Server...

重启Homebridge之后问题照旧。

麻烦你看看问题出在哪里,非常感谢!!!

运行环境树莓派,NPM版本6.3,nodejs版本6.14.3,Homebridge版本0.4.44 Homebridge相关的config.json如下: { "platform":"XiaoMiAcPartner", "devices":{ "192.168.0.24":"xxxxxx隐藏", "192.168.0.28":"xxxxxx隐藏", "192.168.0.29":"xxxxxx隐藏" }, "accessories":[ { "name": "IR Learner", "type": "learnIR", "deviceIp":"192.168.0.24" }, { "name": "switchRepeat", "type": "switchRepeat", "deviceIp":"192.168.0.24", "sendInterval":"300", "data":{ "on":[ "FE000000000000000000000000070024224B003900A700E401CA03960FC913884300000000000000000101010101010101000101010100010001000000000100010542063B", "FE000000000000000000000000070024224B003900A700E401CA03960FC913884300000000000000000101010101010101000101010100010001000000000100010542063B", "FE000000000000000000000000070024224B003900A700E401CA03960FC913884300000000000000000101010101010101000101010100010001000000000100010542063B" ], "off":["FE000000000000000000000000070024224B003900A700E401CA03960FC913884300000000000000000101010101010101000101010100010001000000000100010542063B", "FE000000000000000000000000070024224B003900A700E401CA03960FC913884300000000000000000101010101010101000101010100010001000000000100010542063B", "FE000000000000000000000000070024224B003900A700E401CA03960FC913884300000000000000000101010101010101000101010100010001000000000100010542063B" ] } }, { "name":"Living Room AC", "type":"climate", "deviceIp":"192.168.0.24", "maxTemp":30, "minTemp":16, "autoStart":"cool", "syncInterval":600000 }, { "name":"Study AC", "type":"climate", "deviceIp":"192.168.0.28", "maxTemp":30, "minTemp":16, "autoStart":"cool", "sensorSid":"lumi.158d0002091880", "syncInterval":600000 }, { "name":"Bedroom AC", "type":"climate", "deviceIp":"192.168.0.29", "maxTemp":30, "minTemp":16, "autoStart":"cool", "sensorSid":"lumi.158d000245f15d", "syncInterval":600000 } ] }

HarryChen55 commented 6 years ago

补充一点信息 空调伴侣是小米那一款,圆形那款。

请问是否有计划修复这个bug呢?谢谢!!

LASER-Yi commented 6 years ago

近期比较忙,暂时没有修复这个BUG的计划

98827ddb7e5a2c2e261912a23d9251d6 commented 5 years ago

我也遇到了这个问题,虽然这个解决方法比较暴力,但经测试可以防止 HB 崩溃,红外信号也能发出去。去 config/node_modules/homebridge-mi-acpartner/accessories/baseSwitch.js 把 83 行的 callback(err); 注释掉就好了。

稍后有空再看看究竟是啥问题…

LASER-Yi commented 5 years ago

有没有可能是因为发送间隔太短的缘故,可以帮忙测试下延长发送时间BUG能否解决呢?

98827ddb7e5a2c2e261912a23d9251d6 commented 5 years ago

有没有可能是因为发送间隔太短的缘故,可以帮忙测试下延长发送时间BUG能否解决呢?

调整 sendInterval 到 1000 后仍然报错,貌似不是发送间隔的问题…


硬件:小米空调伴侣(圆形) 配置:

{ "name": "Bedroom Lightbulb", "type": "switchRepeat", "sendInterval": 1000, "data": { "on": [ "FEXXXXXXX", "FEXXXXXXX" ], "off": [ "FEXXXXXXX", "FEXXXXXXX" ] } },

HarryChen55 commented 5 years ago

我也遇到了这个问题,虽然这个解决方法比较暴力,但经测试可以防止 HB 崩溃,红外信号也能发出去。去 config/node_modules/homebridge-mi-acpartner/accessories/baseSwitch.js 把 83 行的 callback(err); 注释掉就好了。

稍后有空再看看究竟是啥问题…

试了你的方法,HB依然会崩溃……

98827ddb7e5a2c2e261912a23d9251d6 commented 5 years ago

试了你的方法,HB依然会崩溃……

试试重启 HB 或者整个容器?我这边只要不返回错误 HB 就不会崩溃,就是每一个红外代码发送会有一条错误日志:

[XiaoMiAcPartner] [Master Bedroom Lightbulb]Failed! TypeError: callback is not a function