cbrandlehner / homebridge-daikin-local

Supports Daikin Air Conditioners on HomeBridge
MIT License
99 stars 18 forks source link

Issue with apiroute #3

Closed MegaGio94 closed 5 years ago

MegaGio94 commented 5 years ago

Hello, nice job with this project, thanks for keeping alive this! I tried homebridge-daikin of DirtyDevWork and yours homebridge-daikin-local. With homebridge-daikin zero problem while with yours seems i cant pass apiroute correctly. Here the error:

[3/15/2019, 8:00:06 PM] Loaded config.json with 3 accessories and 0 platforms. [3/15/2019, 8:00:06 PM] --- [3/15/2019, 8:00:07 PM] Loaded plugin: homebridge-bme280 [3/15/2019, 8:00:07 PM] Registering accessory 'homebridge-bme280.BME280' [3/15/2019, 8:00:07 PM] --- [3/15/2019, 8:00:08 PM] Loaded plugin: homebridge-daikin-local [3/15/2019, 8:00:08 PM] Registering accessory 'homebridge-daikin-local.Daikin-Local' [3/15/2019, 8:00:08 PM] --- [3/15/2019, 8:00:09 PM] Loaded plugin: homebridge-sonoff-tasmota-http [3/15/2019, 8:00:09 PM] Registering accessory 'homebridge-sonoff-tasmota-http.SonoffTasmotaHTTP' [3/15/2019, 8:00:09 PM] --- [3/15/2019, 8:00:09 PM] Loading 0 platforms... [3/15/2019, 8:00:09 PM] Loading 3 accessories... [3/15/2019, 8:00:09 PM] [Daikin] Initializing Daikin-Local accessory... /usr/local/lib/node_modules/homebridge-daikin-local/index.js:16 const myURL = new URL(config.apiroute); ^

ReferenceError: URL is not defined at Object.Daikin (/usr/local/lib/node_modules/homebridge-daikin-local/index.js:16:27) at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:297:29) at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:87:38) at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:45:10) at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22) at Module._compile (module.js:577:32) at Object.Module._extensions..js (module.js:586:10) at Module.load (module.js:494:32) at tryModuleLoad (module.js:453:12) at Function.Module._load (module.js:445:3)

And this is my config.json:

"accessories":[ { "accessory":"Daikin-Local", "name":"Daikin", "apiroute":"http://192.168.0.8" }

cbrandlehner commented 5 years ago

Your config looks OK. I think your environment seems to lack support for "URL": https://www.npmjs.com/package/url

I can not reproduce the problem but you might want to try to add URL as a dependency in package.json and use "npm install". Please share your results.

Any other user here who can help out?

MegaGio94 commented 5 years ago

I tried to put the "url" dependency in package.json of homebridge-daikin-local in /usr/local/lib/node_modules/homebridge-daikin-local

"dependencies": { "request": "^2.88.0", "url": "^0.11.0" },

and used npm install but it does not install url, i tried then npm install -g url, it install it but when i run homebridge i have the same error.

Be patient with me because i am a noob and new in this thing.

lleroux76 commented 5 years ago

Hello. I had the exact same problem. From what I understand, Node version prior to v10 doesn't have URL global. I had to add manually in /usr/local/lib/node_modules/homebridge-daikin-local/index.js the following line near the top (just after var request = require("request");):

var URL = require('url').URL;

I've found the solution here: https://stackoverflow.com/questions/52566578/url-is-not-defined-in-node-js

Hope this help!

crunchy59 commented 5 years ago

Hello. I had the exact same problem. From what I understand, Node version prior to v10 doesn't have URL global. I had to add manually in /usr/local/lib/node_modules/homebridge-daikin-local/index.js the following line near the top (just after var request = require("request");):

var URL = require('url').URL;

I've found the solution here: https://stackoverflow.com/questions/52566578/url-is-not-defined-in-node-js

Hope this help!

Hello excuse for my english but I have the same problem.

I had manually in /usr/lib/node_modules/homebridge-daikin-local Just after var request = require("request");): var URL = require('url').URL;

But now I have thios error: /usr/lib/node_modules/homebridge-daikin-local/index.js:17 const myURL = new URL(config.apiroute); ^ TypeError: URL is not a constructor at Object.Daikin (/usr/lib/node_modules/homebridge-daikin-local/index.js:17:23) at Server._loadAccessories (/var/www/html/plugins/homebridge/resources/node_modules/homebridge/lib/server.js:297:29) at Server.run (/var/www/html/plugins/homebridge/resources/node_modules/homebridge/lib/server.js:87:38) at module.exports (/var/www/html/plugins/homebridge/resources/node_modules/homebridge/lib/cli.js:45:10) at Object.<anonymous> (/var/www/html/plugins/homebridge/resources/node_modules/homebridge/bin/homebridge:17:22) at Module._compile (module.js:541:32) at Object.Module._extensions..js (module.js:550:10) at Module.load (module.js:458:32) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3) /var/www/html/plugins/homebridge/resources/node_modules/bindings/bindings.js:91 throw e ^ Error: The module '/var/www/html/plugins/homebridge/resources/node_modules/ed25519-hap/build/Release/ed25519.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 48. This version of Node.js requires NODE_MODULE_VERSION 57. Please try re-compiling or re-installing the module (for instance, usingnpm rebuildornpm install). at Object.Module._extensions..node (module.js:681:18) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at bindings (/var/www/html/plugins/homebridge/resources/node_modules/bindings/bindings.js:84:48) at Object.<anonymous> (/var/www/html/plugins/homebridge/resources/node_modules/ed25519-hap/index.js:1:99) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10)

Can you help me?

Thanks in advance.

C.

MegaGio94 commented 5 years ago

Hello. I had the exact same problem. From what I understand, Node version prior to v10 doesn't have URL global. I had to add manually in /usr/local/lib/node_modules/homebridge-daikin-local/index.js the following line near the top (just after var request = require("request");):

var URL = require('url').URL;

I've found the solution here: https://stackoverflow.com/questions/52566578/url-is-not-defined-in-node-js

Hope this help!

I followed your instruction and it worked just fine, thanks. I am on node v6.17 now and it worked like a charm.

Thanks dude!

cbrandlehner commented 5 years ago

I published a new release to address this issue. Can you please re-test?

crunchy59 commented 5 years ago

Same problem for me. But I have tested a lot of things. For exemple when I made a fresh install of jeedom/homebridge/daikin il working great (with var URL = require('url').URL;).

I tink it is nodejs version because when I launch this command: npm install -g homebridge-daikin-local in result we have: info using node@v6.3.1 And with my fresh install it is different version v8.

Not finding the solution I spent the whole weekend doing a complete reinstallation of my jeedom to make the dakin-local plugin work with homebridge

C.

MegaGio94 commented 5 years ago

I published a new release to address this issue. Can you please re-test?

I reinstalled homebridge-daikin-local and it works fine with the new release.

Nice job!