MTry / homebridge-smart-irrigation

Turn any electrical irrigation valve into a smart-valve.. or run your pumps on a smart schedule based on your climate! This homebridge plugin exposes a multi-zone irrigation sprinkler dummy control system to Apple's HomeKit. Although a dummy, it brings smarts of an evapotranspiration based climate and plant adaptive irrigation controller with the use of OpenWeatherMap API. The plugin can optionally email you, and/or send you push notifications through Pushover or Pushcut, with the watering schedule it has calculated, or when a watering run is completed, along with the next 7-day weather forecast. Added option to expose system controls to Homekit allowing a user to enable/disable irrigation, rechecks, push and email notifications from within the Home App. Associated WaterLevel Characteristic shows the % of watering cycle remaining.
MIT License
78 stars 3 forks source link

[BUG] #25

Closed shanevanj closed 2 years ago

shanevanj commented 2 years ago

Describe the bug Error after installation and restart

To Reproduce Install latest version of Home Bridge on Raspberry Pi 3B. Install this plugin. Do basic configuration of Geo co-ordinates, OPW key Restart HB serveices

Expected behavior No errors

Screenshots or logs [10/01/2022, 09:56:20] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null [10/01/2022, 09:56:25] [HB Supervisor] Restarting Homebridge... [10/01/2022, 09:56:25] [HB Supervisor] Starting Homebridge with extra flags: -I [10/01/2022, 09:56:25] [HB Supervisor] Started Homebridge v1.3.9 with PID: 5641 [10/01/2022, 09:56:27] Loaded config.json with 1 accessories and 2 platforms. [10/01/2022, 09:56:27] Loaded 8 cached accessories from cachedAccessories. [10/01/2022, 09:56:27] --- [10/01/2022, 09:56:29] Loaded plugin: homebridge-config-ui-x@4.41.5 [10/01/2022, 09:56:29] Registering platform 'homebridge-config-ui-x.config' [10/01/2022, 09:56:29] --- [10/01/2022, 09:56:30] Loaded plugin: homebridge-ewelink@8.9.1 [10/01/2022, 09:56:30] Registering platform 'homebridge-ewelink.eWeLink' [10/01/2022, 09:56:30] --- [10/01/2022, 09:56:30] ==================== [10/01/2022, 09:56:30] ERROR LOADING PLUGIN homebridge-smart-irrigation: [10/01/2022, 09:56:30] Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/local/lib/node_modules/homebridge-smart-irrigation/node_modules/got/dist/source/index.js from /usr/local/lib/node_modules/homebridge-smart-irrigation/index.js not supported. Instead change the require of /usr/local/lib/node_modules/homebridge-smart-irrigation/node_modules/got/dist/source/index.js in /usr/local/lib/node_modules/homebridge-smart-irrigation/index.js to a dynamic import() which is available in all CommonJS modules. at Object. (/usr/local/lib/node_modules/homebridge-smart-irrigation/index.js:9:13) at Plugin.load (/usr/local/lib/node_modules/homebridge/lib/plugin.js:132:77) at PluginManager.initializeInstalledPlugins (/usr/local/lib/node_modules/homebridge/lib/pluginManager.js:64:30) at async Server.start (/usr/local/lib/node_modules/homebridge/lib/server.js:106:9) [10/01/2022, 09:56:30] ==================== [10/01/2022, 09:56:30] Loading 2 platforms... [10/01/2022, 09:56:30] [Config] Initializing config platform... [10/01/2022, 09:56:30] [Config] Running in Service Mode [10/01/2022, 09:56:30] [eWeLink] Initializing eWeLink platform... [10/01/2022, 09:56:30] [eWeLink] Initialising plugin v8.9.1 | Node v16.13.1 | HB v1.3.9 | HAPNodeJS v0.9.8... [10/01/2022, 09:56:30] Loading 1 accessories... [10/01/2022, 09:56:30] No plugin was found for the accessory "SmartSprinklers" in your config.json. Please make sure the corresponding plugin is installed correctly.

Platform (please complete the following information):

Additional context Add any other context about the problem here.

MTry commented 2 years ago

Hi Shane.. just wanted to let you know that I'm trying to replicate this however without success so far.

shanevanj commented 2 years ago

Okay – Thanks – I will setup a clean build next week and try again – I am suspecting its memory related and I have ordered a Pi4(8GB) for arrival in mid feb – so will test there as well.

--

Warm Regards

Shane van Jaarsveldt+27 (82) 601 0499

From: Mayank @.> Reply to: MTry/homebridge-smart-irrigation @.> Date: Wednesday, 12 January 2022 at 13:52 To: MTry/homebridge-smart-irrigation @.> Cc: Shane van Jaarsveldt @.>, Author @.***> Subject: Re: [MTry/homebridge-smart-irrigation] [BUG] (Issue #25)

Hi Shane.. just wanted to let you know that I'm trying to replicate this however without success so far.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

MTry commented 2 years ago

Sure - will await your feedback. My own build uses a Pi4-8gb and the plugin sits well with a dozen other plugins.. and on its own child bridge since several months!

On 12-Jan-2022, at 8:19 PM, Shane van Jaarsveldt @.***> wrote:

Okay – Thanks – I will setup a clean build next week and try again – I am suspecting its memory related and I have ordered a Pi4(8GB) for arrival in mid feb – so will test there as well.

--

Warm Regards

Shane van Jaarsveldt+27 (82) 601 0499

From: Mayank @.> Reply to: MTry/homebridge-smart-irrigation @.> Date: Wednesday, 12 January 2022 at 13:52 To: MTry/homebridge-smart-irrigation @.> Cc: Shane van Jaarsveldt @.>, Author @.***> Subject: Re: [MTry/homebridge-smart-irrigation] [BUG] (Issue #25)

Hi Shane.. just wanted to let you know that I'm trying to replicate this however without success so far.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/MTry/homebridge-smart-irrigation/issues/25#issuecomment-1011121623, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQP4KMHWDKTMVQWK6QOHQTDUVWIFZANCNFSM5LS75KJA. You are receiving this because you were assigned.

angyalz commented 2 years ago

Same issue here. Node: v16.13.2 HomeBridge: v1.4.0

angyalz commented 2 years ago

This issue is absolutely not memory related. The “require” of ES Module no longer supported for some reason at index.js. @MTry I think you should change them to “import” of CommonJS – as is in error message.

PS: but I don't understand this error. First of all, I know that require() is from CommonJS and import() from ES Module. Second: many plugins are working well with require().

shanevanj commented 2 years ago

I did try that to my very limited skills but that threw up other errors that I could not resolve.

--

Warm Regards

Shane van Jaarsveldt+27 (82) 601 0499

From: Angyal Zoltán @.> Reply to: MTry/homebridge-smart-irrigation @.> Date: Wednesday, 26 January 2022 at 09:36 To: MTry/homebridge-smart-irrigation @.> Cc: Shane van Jaarsveldt @.>, Author @.***> Subject: Re: [MTry/homebridge-smart-irrigation] [BUG] (Issue #25)

This issue is absolutely not memory related. The “require” of ES Module no longer supported for some reason at index.js. @MTry I think you should change them to “import” of CommonJS – as is in error message.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

VocalOverdub commented 2 years ago

I have the same issue.

Running on macOS (arm64)

Node v 15.14.0 NPM v 7.7.6

[2/3/2022, 7:51:10 PM] ==================== [2/3/2022, 7:51:10 PM] ERROR LOADING PLUGIN homebridge-smart-irrigation: [2/3/2022, 7:51:10 PM] Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/js/.nvm/versions/node/v15.14.0/lib/node_modules/homebridge-smart-irrigation/node_modules/got/dist/source/index.js require() of ES modules is not supported. require() of /Users/js/.nvm/versions/node/v15.14.0/lib/node_modules/homebridge-smart-irrigation/node_modules/got/dist/source/index.js from /Users/js/.nvm/versions/node/v15.14.0/lib/node_modules/homebridge-smart-irrigation/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules. Instead rename /Users/js/.nvm/versions/node/v15.14.0/lib/node_modules/homebridge-smart-irrigation/node_modules/got/dist/source/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/js/.nvm/versions/node/v15.14.0/lib/node_modules/homebridge-smart-irrigation/node_modules/got/package.json.

at new NodeError (node:internal/errors:329:5)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1109:13)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object.<anonymous> (/Users/js/.nvm/versions/node/v15.14.0/lib/node_modules/homebridge-smart-irrigation/index.js:9:13)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)

[2/3/2022, 7:51:10 PM] ====================

jmaferreira commented 2 years ago

Same problem here:

Log message:

[05/02/2022, 14:01:58] ====================
[05/02/2022, 14:01:58] ERROR LOADING PLUGIN homebridge-smart-irrigation:
[05/02/2022, 14:01:58] Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/local/lib/node_modules/homebridge-smart-irrigation/node_modules/got/dist/source/index.js from /usr/local/lib/node_modules/homebridge-smart-irrigation/index.js not supported.
Instead change the require of /usr/local/lib/node_modules/homebridge-smart-irrigation/node_modules/got/dist/source/index.js in /usr/local/lib/node_modules/homebridge-smart-irrigation/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge-smart-irrigation/index.js:9:13)
    at Plugin.load (/usr/local/lib/node_modules/homebridge/lib/plugin.js:135:108)
    at PluginManager.initializeInstalledPlugins (/usr/local/lib/node_modules/homebridge/lib/pluginManager.js:64:30)
    at async Server.start (/usr/local/lib/node_modules/homebridge/lib/server.js:106:9)
[05/02/2022, 14:01:58] ====================
ddalbroi commented 2 years ago

hey guys.. I'm not much of a coder but found what the issue is.. the plugin (when installed recently) is downloading version 12 of 'got' module which appears to be incompatible and hence throws the ES Module error. I managed to get the plugin working again by manually getting version 11.8.3 of 'got' and overwriting the files in .../homebridge-smart-irrigation/node_modules/got/ with the older version.

This is not a permanent fix - just a workaround...

VocalOverdub commented 2 years ago

hey guys.. I'm not much of a coder but found what the issue is.. the plugin (when installed recently) is downloading version 12 of 'got' module which appears to be incompatible and hence throws the ES Module error. I managed to get the plugin working again by manually getting version 11.8.3 of 'got' and overwriting the files in .../homebridge-smart-irrigation/node_modules/got/ with the older version.

This is not a permanent fix - just a workaround...

Thanks for the tip. I tried this, but am still getting the same error :(

jmaferreira commented 2 years ago

It worked well for me. You need to go the ".../homebridge-smart-irrigation/node_modules/" folder and remove the existing got version and install the older one:

npm uninstall got
npm install got@11.8.3
VocalOverdub commented 2 years ago

It worked well for me. You need to go the ".../homebridge-smart-irrigation/node_modules/" folder and remove the existing got version and install the older one:

npm uninstall got
npm install got@11.8.3

I had run the uninstall and the 11.8.3 install, but had not first deleted the files under homebridge-smart-irrigation.

Doing that first and re-running those commands did the trick.

Thank you both very much!

matbe81 commented 2 years ago

Same issue.

Trying uninstalling & reinstallating got without success=

AM] ==================== [2/17/2022, 12:28:21 AM] ERROR LOADING PLUGIN homebridge-smart-irrigation: [2/17/2022, 12:28:21 AM] Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/lib/node_modules/homebridge-smart-irrigation/node_modules/got/dist/source/index.js from /usr/lib/node_modules/homebridge-smart-irrigation/index.js not supported. Instead change the require of /usr/lib/node_modules/homebridge-smart-irrigation/node_modules/got/dist/source/index.js in /usr/lib/node_modules/homebridge-smart-irrigation/index.js to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (/usr/lib/node_modules/homebridge-smart-irrigation/index.js:9:13) at Plugin.load (/usr/lib/node_modules/homebridge/lib/plugin.js:135:108) at PluginManager.initializeInstalledPlugins (/usr/lib/node_modules/homebridge/lib/pluginManager.js:64:30) at async Server.start (/usr/lib/node_modules/homebridge/lib/server.js:106:9) [2/17/2022, 12:28:21 AM] ====================

angyalz commented 2 years ago

@MTry I think problem solved, but needs some check (but it works for me without error messages or warnings). See pull requests!

MTry commented 2 years ago

@MTry I think problem solved, but needs some check (but it works for me without error messages or warnings). See pull requests!

@angyalz - Thank you for your effort and time!! I've been caught with stuff that has prevented me from contributing.

Could there be more feedback on this so I can go ahead and merge?

MTry commented 2 years ago

Did you try with GOT v12.x.x?

On 29-Mar-2022, at 21:14, Angyal Zoltán @.***> wrote:

@MTry https://github.com/MTry I think problem solved, but needs some check (but it works for me without error messages or warnings). See pull requests!

— Reply to this email directly, view it on GitHub https://github.com/MTry/homebridge-smart-irrigation/issues/25#issuecomment-1082043001, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQP4KMEMVHGKZLUZXNJ22RTVCMQPRANCNFSM5LS75KJA. You are receiving this because you were mentioned.

MTry commented 2 years ago

Please check now - have merged the changes and this should be working now.

angyalz commented 2 years ago

@MTry I tested with got v12.0.3, but I think I forgot update it in pushed branch.

The current (updated and published) version seems working for me.

MTry commented 2 years ago

Yes.. I bumped the got version as well..

MTry commented 2 years ago

I suppose this has been addressed - closing.