AlexGustafsson / homebridge-wol

A Wake on Lan plugin for Homebridge
MIT License
301 stars 30 forks source link

SyntaxError: Block-scoped ... strict mode. #37

Closed sempiternael closed 6 years ago

sempiternael commented 6 years ago

Backstory

I was attempting to re-configure homebridge-wol due to a recent move w/ switch of equipment.

Issue

I do not know what exactly happened, it didn't yell at me before. I've updated and reinstalled everything (including deleting the .homebridge folder at ~/ and /root/) to make sure something didn't corrupt or anything.

Environment

Configuration

My configuration looks like this:

{
   "bridge": {
        "name": "Homebridge",
        "username": "<Mac-address>",
        "port": 51826,
        "pin": "031-45-154"
   },
"accessories":[
   {
        "accessory": "WinPC",
        "name": "My Windows PC",
        "http_method": "GET",
        "on_url": "wol://<Mac-address>",
        "off_url": "http://10.0.0.1:7879/?action=System.Shutdown",
        "status_url": "http://10.0.0.1:7879/",
        "sendimmediately": "yes",
        "poll_status_interval": "60",
        "username" : "User",
        "password" : "<Mac-address>",
        "powerstateOnError" : "0",
        "powerstateOffError": "1"
   },
   {
       "accessory": "NetworkDevice",
       "name": "PC",
       "mac": "<Mac-address>",
       "ip": "10.0.0.1",
       "shutdownCommand": "net rpc shutdown --ipaddress 10.0.0.1 --user redacted%redacted"
   }
 ]
}

IMPORTANT!

Log

Homebridge fails to load at error, so can't really debug. But, here is the console output.

[28/04/2018, 22:16:41] Loaded plugin: homebridge-winpc
[28/04/2018, 22:16:41] Registering accessory 'homebridge-winpc.WinPC'
[28/04/2018, 22:16:41] ---
[28/04/2018, 22:16:41] ====================
[28/04/2018, 22:16:41] ERROR LOADING PLUGIN homebridge-wol:
[28/04/2018, 22:16:41] SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge-wol/index.js:1:88)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
[28/04/2018, 22:16:41] ====================
[28/04/2018, 22:16:41] Loaded config.json with 2 accessories and 0 platforms.
[28/04/2018, 22:16:41] ---
[28/04/2018, 22:16:41] Loading 2 accessories...
[28/04/2018, 22:16:41] [My Windows PC] Initializing WinPC accessory...
[28/04/2018, 22:16:41] [My Windows PC] Setting info: {"serialnumber":"Unknown","model":"Windows PC","manufacterer":"Microsoft","name":"Windows PC","softwareversion":"Unknown","manufacturer":"Microsoft"}
HAP Warning: Characteristic 00000054-0000-1000-8000-0026BB765291 not in required or optional characteristics for service 0000003E-0000-1000-8000-0026BB765291. Adding anyway.
/usr/local/lib/node_modules/homebridge/lib/api.js:64
      throw new Error("The requested accessory '" + name + "' was not registered by any plugin.");
      ^

Error: The requested accessory 'NetworkDevice' was not registered by any plugin.
    at API.accessory (/usr/local/lib/node_modules/homebridge/lib/api.js:64:13)
    at Server.str.replace.Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:264:42)
    at Server.str.replace.Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:86:38)
    at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)

Notes

none

AlexGustafsson commented 6 years ago

It seems to be a problem with the use of ES6 features that should be supported by the version of Node you’re using. Are you able to update the Node version? If so, please try to update and try to run homebridge again.

sempiternael commented 6 years ago

Are you able to update the Node version?

I went to update it before I posted the question, but just went to check and saw that it didn't actually update - got it to v8.11.1 now. I had to completely remove node and everything that was related to it, reboot, and then do a clean install.

That took care of that issue. Now all I have to do is get my shutdown command to work 😀 Windows 10 is such a crapshoot when it comes to stuff like this.

Thanks!

AlexGustafsson commented 6 years ago

Some users have had success with using “net rpc”. There should be a note about it in the readme below the configuration. Although I can’t really recommend it due to the implications it has on some security features. I guess we’ll have to wait for a proper SSH server on Windows (Microsoft have one in beta now) before it gets reliable. Best of luck!

sempiternael commented 6 years ago

@AlexGustafsson, I've reinstalled Windows 10 and updated my Pi 3 config recently and status pings and shutdown with RPC for Windows 10 is working now. I had to follow this to get it to work, otherwise, it would shoot me a ...OBJECT_NAME... error. I'm assuming because it was an non-user command. This is on the new 1803 preview, so hopefully this will be fixed for everyone shortly.

AlexGustafsson commented 6 years ago

@pfinnegane Good thing you were able to resolve the issue. Thank you for posting about your findings. It helps me and others when troubleshooting similar issues.