ztalbot2000 / homebridge-cmd4

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

All of the sudden... #34

Closed zang74 closed 5 years ago

zang74 commented 5 years ago

I install another plugin ("homebridge-tuya-smartlamp") and boom, CMD4 starts throwing:

SyntaxError: Unexpected token A in JSON at position 0
    at JSON.parse (<anonymous>)
    at IncomingMessage.res.on (/usr/local/lib/node_modules/homebridge-cmd4/node_modules/github-version-checker/lib/check.js:64:21)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1129:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
homebridge.service: Main process exited, code=exited, status=255/EXCEPTION
homebridge.service: Failed with result 'exit-code'.
homebridge.service: Service RestartSec=3s expired, scheduling restart.
homebridge.service: Scheduled restart job, restart counter is at 2.

Nothing has changed in the CMD4 section of the config, it all validates via JSONlint and the problem continues to happen, even after both the Tuya plugin has been removed and CMD4 removed and reinstalled. If even one piece of CMD4 JSON exists in the config file, the error happens and takes down homebridge. every 10 seconds or so.

As I said, it's just like the plugin is now permanently broken—all (maybe) because of another plugin.

ztalbot2000 commented 5 years ago

Morning,

You are having a rough time. Sorry to hear that. Check your Config.json file at jsonlint.com. Try the config.json file that comes with home BridgeCmd4. I really think your problem is one of your settings to a TLV8 command. It would pass jsonlint, but cause homebridge to crash. Try removing that portion temporarily.

TTFN, John

On Sat, Sep 21, 2019 at 8:49 AM Zang notifications@github.com wrote:

I install another plugin ("homebridge-tuya-smartlamp") and boom, CMD4 starts throwing:

SyntaxError: Unexpected token A in JSON at position 0

at JSON.parse (<anonymous>)

at IncomingMessage.res.on (/usr/local/lib/node_modules/homebridge-cmd4/node_modules/github-version-checker/lib/check.js:64:21)

at IncomingMessage.emit (events.js:203:15)

at endReadableNT (_stream_readable.js:1129:12)

at process._tickCallback (internal/process/next_tick.js:63:19)

homebridge.service: Main process exited, code=exited, status=255/EXCEPTION

homebridge.service: Failed with result 'exit-code'.

homebridge.service: Service RestartSec=3s expired, scheduling restart.

homebridge.service: Scheduled restart job, restart counter is at 2.

Nothing has changed in the CMD4 section of the config, it all validates via JSONlint and the problem continues to happen, even after both the Tuya plugin has been removed and CMD4 removed and reinstalled. If even one piece of CMD4 JSON exists in the config file, the error happens and takes down homebridge. every 10 seconds or so.

As I said, it's just like the plugin is now permanently broken—all (maybe) because of another plugin.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/34?email_source=notifications&email_token=ABSBCX2NMNYMJ5Q3W7UUDRLQKYJ6HA5CNFSM4IY6EHEKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HM2KFZQ, or mute the thread https://github.com/notifications/unsubscribe-auth/ABSBCXZKM2K7AY4OMDB5EDLQKYJ6HANCNFSM4IY6EHEA .

NogginTheNog commented 5 years ago

I'm getting the same error also, the config checks out with jsonlint.

Trying to get a ping to show up as a sensor alert if it fails.

Sep 22 15:29:25 homebridge homebridge[1905]: SyntaxError: Unexpected token A in JSON at position 0
Sep 22 15:29:25 homebridge homebridge[1905]:     at JSON.parse (<anonymous>)
Sep 22 15:29:25 homebridge homebridge[1905]:     at IncomingMessage.res.on (/usr/lib/node_modules/homebridge-cmd4/node_modules/github-version-checker/lib/check.js:64:21)
Sep 22 15:29:25 homebridge homebridge[1905]:     at emitNone (events.js:111:20)
Sep 22 15:29:25 homebridge homebridge[1905]:     at IncomingMessage.emit (events.js:208:7)
Sep 22 15:29:25 homebridge homebridge[1905]:     at endReadableNT (_stream_readable.js:1064:12)
Sep 22 15:29:25 homebridge homebridge[1905]:     at _combinedTickCallback (internal/process/next_tick.js:139:11)
Sep 22 15:29:25 homebridge homebridge[1905]:     at process._tickCallback (internal/process/next_tick.js:181:9)
Sep 22 15:29:25 homebridge systemd[1]: homebridge.service: Main process exited, code=exited, status=255/n/a
Sep 22 15:29:25 homebridge systemd[1]: homebridge.service: Unit entered failed state.
Sep 22 15:29:25 homebridge systemd[1]: homebridge.service: Failed with result 'exit-code'.
Sep 22 15:29:36 homebridge systemd[1]: homebridge.service: Service hold-off time over, scheduling restart.

Occasionally it seems to work after adding the first MotionSensor, but as soon as I try and add the second the error occurs.

{
    "platform": "Cmd4",
    "name": "Cmd4",
    "outputConstants": false,
    "accessories": [{
            "type": "MotionSensor",
            "displayName": "ap-1",
            "motionDetected": "FALSE",
            "statusActive": "TRUE",
            "statusFault": "NO_FAULT",
            "statusTampered": "NOT_TAMPERED",
            "name": "ap-1",
            "stateChangeResponseTime": 3,
            "state_cmd": "bash /var/homebridge/cmd4/pinger-ap-1.sh"
        },
        {
            "type": "MotionSensor",
            "displayName": "mac-mini",
            "motionDetected": "FALSE",
            "statusActive": "TRUE",
            "statusFault": "NO_FAULT",
            "statusTampered": "NOT_TAMPERED",
            "name": "mac-mini",
            "stateChangeResponseTime": 3,
            "state_cmd": "bash /var/homebridge/cmd4/pinger-mac-mini.sh"
        }
    ]
}
zang74 commented 5 years ago

The config file has been verified via JSONlint and a couple of other online validators. And none of the CMD4 json code was changed, and was working prior to trying to get the Tuya bulbs working.

I left things the other night in their "broken" state; with the Tuya plugin uninstalled and all CMD4 json gone from the config. When I got back to it this morning, and re-added the CMD4 config, all was working again.

So, I yet again attempted to add the Tuya bulbs; which seem to have an issue connecting in general, but I'm taking that up with the creator of that plugin. But again, CMD4 started taking issue and exiting homebridge.

And yet again, I've removed the Tuya plugin and all it's config info, and yet again I'm still getting a the CMD4-related error.

These scripts were working again this morning, but the Tuya plugin changed something that's interfering with CMD4 far after its removal.

Is this some sort of caching-related issue? Are there caches I can delete that might fix this problem?

zang74 commented 5 years ago

My json for Cmd4:

    {
        "platform": "Cmd4",
        "name": "Cmd4",
        "accessories": [
            {
                "type": "Switch",
                "Name": "Fix Kodi",
                "displayName": "Fix Kodi",
                "polling": true,
                "interval": 3,
                "timeout": 5000,
                "on": 1,
                "state_cmd": "/var/lib/homebridge/scripts/kodimulti.sh"
            },
            {
                "type": "Switch",
                "Name": "Unpause Kodi",
                "displayName": "Unpause Kodi",
                "polling": true,
                "interval": 3,
                "timeout": 5000,
                "on": 1,
                "state_cmd": "/var/lib/homebridge/scripts/kodimulti.sh"
            },
            {
                "type": "Switch",
                "Name": "Kodi Speaker",
                "displayName": "Kodi Speaker",
                "state_cmd": "/var/lib/homebridge/scripts/kodivolume.sh",
                "polling": true,
                "interval": 5,
                "on": 1,
                "timeout": 5000
            },
            {
                "type": "Switch",
                "Name": "Play Games",
                "displayName": "Play Games",
                "state_cmd": "/var/lib/homebridge/scripts/kodimulti.sh",
                "polling": true,
                "interval": 3,
                "on": 1,
                "timeout": 5000
            },
            {
                "type": "Switch",
                "Name": "Fix the Channel",
                "displayName": "Fix the Channel",
                "state_cmd": "/var/lib/homebridge/scripts/kodimulti.sh",
                "polling": true,
                "interval": 3,
                "on": 1,
                "timeout": 5000
            },
            {
                "type": "Television",
                "displayName": "Kodi",
                "name": "Kodi",
                "active": 1,
                "currentMediaState": 2,
                "closedCaptions": 0,
                "sleepDiscoveryMode": 0,
                "activeIdentifier": 0,
                "targetMediaState": 0,
                "on": 1,
                "mute": 0,
                "remoteKey": 0,
                "volume": 45,
                "state_cmd": "/var/lib/homebridge/scripts/kodivolume.sh",
                "polling": [
                    {
                        "mute": 0,
                        "interval": 540,
                        "timeout": 5000
                    },
                    {
                        "volume": 45,
                        "interval": 60,
                        "timeout": 5000
                    },
                    {
                        "active": 0,
                        "interval": 50,
                        "timeout": 5000
                    },
                    {
                        "currentMediaState": "STOP",
                        "interval": 540,
                        "timeout": 5000
                    },
                    {
                        "on": 1,
                        "interval": 540,
                        "timeout": 10000
                    }
                ]
            }
        ]
    }
zang74 commented 5 years ago

So, I have an AppleTV on my network as well. It would appear rebooting that seems to have cleared up that error.

NogginTheNog commented 5 years ago

Thanks, removed my homebridge controller and rebooted both my AppleTVs, this seemed to fix the issue I can now add all my Cmd4 Motion Sensors using exactly the same json config.

Now to re-add my homebridge controller.

ztalbot2000 commented 5 years ago

Can you send me your pinger.sh file and I will try it all together.

Thanks, John

On Sun, Sep 22, 2019 at 10:36 AM NogginTheNog notifications@github.com wrote:

I'm getting the same error also, the config checks out with jsonlint.

Trying to get a ping to show up as a sensor alert if it fails.

Sep 22 15:29:25 homebridge homebridge[1905]: SyntaxError: Unexpected token A in JSON at position 0 Sep 22 15:29:25 homebridge homebridge[1905]: at JSON.parse () Sep 22 15:29:25 homebridge homebridge[1905]: at IncomingMessage.res.on (/usr/lib/node_modules/homebridge-cmd4/node_modules/github-version-checker/lib/check.js:64:21) Sep 22 15:29:25 homebridge homebridge[1905]: at emitNone (events.js:111:20) Sep 22 15:29:25 homebridge homebridge[1905]: at IncomingMessage.emit (events.js:208:7) Sep 22 15:29:25 homebridge homebridge[1905]: at endReadableNT (_stream_readable.js:1064:12) Sep 22 15:29:25 homebridge homebridge[1905]: at _combinedTickCallback (internal/process/next_tick.js:139:11) Sep 22 15:29:25 homebridge homebridge[1905]: at process._tickCallback (internal/process/next_tick.js:181:9) Sep 22 15:29:25 homebridge systemd[1]: homebridge.service: Main process exited, code=exited, status=255/n/a Sep 22 15:29:25 homebridge systemd[1]: homebridge.service: Unit entered failed state. Sep 22 15:29:25 homebridge systemd[1]: homebridge.service: Failed with result 'exit-code'. Sep 22 15:29:36 homebridge systemd[1]: homebridge.service: Service hold-off time over, scheduling restart.

Occasionally it seems to work after adding the first MotionSensor.

{ "platform": "Cmd4", "name": "Cmd4", "outputConstants": false, "accessories": [{ "type": "MotionSensor", "displayName": "ap-1", "motionDetected": "FALSE", "statusActive": "TRUE", "statusFault": "NO_FAULT", "statusTampered": "NOT_TAMPERED", "name": "ap-1", "stateChangeResponseTime": 3, "state_cmd": "bash /var/homebridge/cmd4/pinger-ap-1.sh" }, { "type": "MotionSensor", "displayName": "mac-mini", "motionDetected": "FALSE", "statusActive": "TRUE", "statusFault": "NO_FAULT", "statusTampered": "NOT_TAMPERED", "name": "mac-mini", "stateChangeResponseTime": 3, "state_cmd": "bash /var/homebridge/cmd4/pinger-mac-mini.sh" } ] }

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/34?email_source=notifications&email_token=ABSBCX2BUKVZBTA2PWHS6XDQK57FPA5CNFSM4IY6EHEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7JHTKI#issuecomment-533887401, or mute the thread https://github.com/notifications/unsubscribe-auth/ABSBCX5N3BNQSHQRSCIINDLQK57FPANCNFSM4IY6EHEA .

MichlW commented 5 years ago

Exactly that was my issue some weeks ago. --> Issue 31

Was only able to fix this, when NOT copying my correct content of my old config.json.

NogginTheNog commented 5 years ago

It's now working after removing my homebridge instance and rebooting the both my Apple TVs.

I run IPv4/IPv6 dual stack, hence the ping4

Basically I want to alert when my network kit at home goes down.

root@homebridge:/var/homebridge/cmd4# more pinger-ap-1.sh
#!/bin/bash
IP='172.16.1.11'

if ping4 -c 1 -w 1 $IP > /dev/null; 
then echo 0
else echo 1
fi

exit 0

Screenshot 2019-09-23 at 13 18 58

Passwords & IDs changed:-

config.json.zip

Would you recommend adding polling ?

"polling": [
 {
"on": false,
"interval": 300,
"timeout": 4000
 }
 ],
ztalbot2000 commented 5 years ago

Hi,

I'm glad your up and running again. If you enable polling for the accessory, Your GUI will always be current, not just when you open the App. FakeGato would give you a graph over time of the status.. the graph would be shown in Eve.

Enjoy, John Talbot

On Mon, Sep 23, 2019 at 8:22 AM NogginTheNog notifications@github.com wrote:

It's now working after removing my homebridge instance and rebooting the both my Apple TVs.

I run IPv4/IPv6 dual stack, hence the ping4

root@homebridge:/var/homebridge/cmd4# more pinger-ap-1.sh

!/bin/bash

IP='172.16.1.11'

if ping4 -c 1 -w 1 $IP > /dev/null; then echo 0 else echo 1 fi

exit 0

[image: Screenshot 2019-09-23 at 13 18 58] https://user-images.githubusercontent.com/6253212/65425108-1fba0c00-de05-11e9-9c41-efec91c67f4a.png

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/34?email_source=notifications&email_token=ABSBCXZFISUI3PSRA6WBHBTQLCYJPA5CNFSM4IY6EHEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7KVO5Y#issuecomment-534075255, or mute the thread https://github.com/notifications/unsubscribe-auth/ABSBCX6DWX3BAKZ673H2Z7TQLCYJPANCNFSM4IY6EHEA .

ztalbot2000 commented 5 years ago

As per conversation

TimofeyK commented 5 years ago

This is a problem in github-version-checker module https://github.com/axelrindle/github-version-checker/issues/6

I just hit that after restarting my homebridge. Fixed by updating to the latest version of Cmd4 (I had previous version) which refreshed github-version-checker

ztalbot2000 commented 5 years ago

Thanks for the debug info. I really appreciate it. I had taken this code from somewhere else and it was really hard to test, without a version in github that did not have version checking. I think I will change this to a npm version checking scheme. It works better when npm just has releases and github has development code.

Thanks very much. John

On Mon, Oct 7, 2019 at 7:42 AM TimofeyK notifications@github.com wrote:

This is a problem in github-version-checker module axelrindle/github-version-checker#6 https://github.com/axelrindle/github-version-checker/issues/6

I just hit that after restarting my homebridge. Fixed by updating to the latest version of Cmd4 (I had previous version) which refreshed github-version-checker

— 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/34?email_source=notifications&email_token=ABSBCX6EYR6E24JXL5FRB7TQNMODPA5CNFSM4IY6EHEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAQAEYQ#issuecomment-538968674, or mute the thread https://github.com/notifications/unsubscribe-auth/ABSBCX7KJU45ZMWZQEE2FOTQNMODPANCNFSM4IY6EHEA .

ztalbot2000 commented 5 years ago

Hmm, I'm lost. I thought this was a new issue for me.

On Mon, Oct 7, 2019 at 9:33 AM John Talbot ztalbot2000@gmail.com wrote:

Thanks for the debug info. I really appreciate it. I had taken this code from somewhere else and it was really hard to test, without a version in github that did not have version checking. I think I will change this to a npm version checking scheme. It works better when npm just has releases and github has development code.

Thanks very much. John

On Mon, Oct 7, 2019 at 7:42 AM TimofeyK notifications@github.com wrote:

This is a problem in github-version-checker module axelrindle/github-version-checker#6 https://github.com/axelrindle/github-version-checker/issues/6

I just hit that after restarting my homebridge. Fixed by updating to the latest version of Cmd4 (I had previous version) which refreshed github-version-checker

— 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/34?email_source=notifications&email_token=ABSBCX6EYR6E24JXL5FRB7TQNMODPA5CNFSM4IY6EHEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAQAEYQ#issuecomment-538968674, or mute the thread https://github.com/notifications/unsubscribe-auth/ABSBCX7KJU45ZMWZQEE2FOTQNMODPANCNFSM4IY6EHEA .

TimofeyK commented 5 years ago

Oh, sorry for the confusing message. I meant this is a known issue in another module that your already helped to fix but one needs to kick Cmd4 reinstallation so NPM pulls the latest version of that module

ztalbot2000 commented 5 years ago

I just pushed 2.2.4. There are no code changes (2.2.3 pushed incorrectly). This will hopefully force a pickup of the latest github-version-checker to fix the issue

TTFN, John Talbot

On Mon, Oct 7, 2019 at 9:15 PM TimofeyK notifications@github.com wrote:

Oh, sorry for the confusing message. I meant this is a known issue in another module that your already helped to fix but one needs to kick Cmd4 reinstallation so NPM pulls the latest version of that module

— 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/34?email_source=notifications&email_token=ABSBCXYXYG2MP2VOUF5DI43QNPNLRA5CNFSM4IY6EHEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEASJ2ZY#issuecomment-539270503, or mute the thread https://github.com/notifications/unsubscribe-auth/ABSBCX6LWSUOGS37KIHGNA3QNPNLRANCNFSM4IY6EHEA .

ztalbot2000 commented 5 years ago

GitHub-version-checker is still causing issues. I removed it for a direct comparison of what is in npm. New release is 2.2.5