ztalbot2000 / homebridge-cmd4

CMD4 Plugin for Homebridge - Supports ~All Accessory Types & now all Characteristics too
Apache License 2.0
149 stars 13 forks source link

[Support] TypeError #89

Closed shungo27 closed 3 years ago

shungo27 commented 3 years ago

I get an error every time I restart homebridge.

TypeError: Cannot read property 'reduce' of null

Paste of Logs:

[2/15/2021, 9:58:27 AM] TypeError: Cannot read property 'reduce' of null
    at /Users/xxxxx/.nodebrew/node/v14.15.5/lib/node_modules/homebridge-cmd4/Cmd4Accessory.js:677:49
    at ChildProcess.exithandler (child_process.js:299:7)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1048:16)
    at Socket.<anonymous> (internal/child_process.js:439:11)
    at Socket.emit (events.js:315:20)
    at Pipe.<anonymous> (net.js:673:12)
[2/15/2021, 9:58:27 AM] TypeError: Cannot read property 'reduce' of null
    at /Users/xxxxx/.nodebrew/node/v14.15.5/lib/node_modules/homebridge-cmd4/Cmd4Accessory.js:677:49
    at ChildProcess.exithandler (child_process.js:299:7)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1048:16)
    at Socket.<anonymous> (internal/child_process.js:439:11)
    at Socket.emit (events.js:315:20)
    at Pipe.<anonymous> (net.js:673:12)

Cmd4 Config:

        {
            "platform": "Cmd4",
            "name": "Cmd4",
            "allowTLV8": false,
            "outputConstants": false,
            "restartRecover": false,
            "fetch": "Polled",
            "accessories": [
                {
                    "type": "Switch",
                    "name": "エアコン",
                    "on": "0",
                    "state_cmd": "/Applications/homebridge/thermostat/shellscript.sh",
                    "stateChangeResponseTime": 3,
                    "Polling": [
                        {
                            "characteristic": "On",
                            "interval": 5,
                            "timeout": 5000
                        }
                    ]
                },
                {
                    "type": "Switch",
                    "name": "サーキュレーター",
                    "on": "0",
                    "state_cmd": "/Applications/homebridge/circulator/shellscript.sh",
                    "stateChangeResponseTime": 3,
                    "Polling": [
                        {
                            "characteristic": "On",
                            "interval": 5,
                            "timeout": 5000
                        }
                    ]
                }
            ]
        }

Environment:

ztalbot2000 commented 3 years ago

Hi,

Sorry, I did not see this come in. I only saw it by accident. I'll get back to you shortly. What an odd message.

ztalbot2000 commented 3 years ago

Interesting indeed. For whatever reason your shell script is returning nothing. In 3.0 I had added parsing of quotes around the incoming data. The data was supposed to have been checked before hand. I guess with all the testing around the quotes, I actually did not notice that the test of no data was moved after the reduce. Ooops. I will fix this ASAP.

ztalbot2000 commented 3 years ago

Actually, I think it would have failed before as well. instead of reduce, it would have been for match. No matter. A fix is underway.

ztalbot2000 commented 3 years ago

v3.1.1 submitted to GitHub. Package testing underway before release to NPM.

ztalbot2000 commented 3 years ago

Package testing complete. Fix is in v3.1.1, however your script I believe is still returning nothing to Cmd4.

shungo27 commented 3 years ago

thx! the problem is solved!

ztalbot2000 commented 3 years ago

On Mon, Feb 15, 2021 at 3:39 PM shungo27 notifications@github.com wrote:

thx! the problem is solved!

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/89#issuecomment-779437871, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCXZSJBJIQB7ZHE7GEVTS7GA6RANCNFSM4XTZR2HA .

I created some unit test cases and submitted 3.1.2 that stumbled upon something else. The unit tests mean this should not happen again. The modularity of v3 allows me to test it in a much better way.

Enjoy Cmd4, TTFN, John Talbot