Using node js package in an integration

Hi all. I have the example integration from the Dev docs working and I am starting to work on my own integration, but I am running into an issue. I am trying to use a nodejs package. Obviously that won’t work directly so I am trying to use Js2Py. I have that as one of my requirements in the manifest and that appears to be working. One features of Js2Py is the ability to load a full module which is what I need for my integration. When I try to do that I get this error:

2020-04-24 23:25:30 ERROR (MainThread) [homeassistant.setup] Error during setup of component pentair
Traceback (most recent call last):
  File "/workspaces/home-assistant-dev/homeassistant/setup.py", line 175, in _async_setup_component
    component.setup, hass, processed_config  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/workspaces/home-assistant-dev/homeassistant/components/pentair/__init__.py", line 14, in setup
    ScreenLogic = js2py.require("node-screenlogic")
  File "/usr/local/lib/python3.7/site-packages/js2py/node_import.py", line 151, in require
    maybe_version_str=maybe_version)
  File "/usr/local/lib/python3.7/site-packages/js2py/node_import.py", line 74, in _get_and_translate_npm_module
    _init()
  File "/usr/local/lib/python3.7/site-packages/js2py/node_import.py", line 19, in _init
    ) == 0, 'You must have node installed! run: brew install node'
AssertionError: You must have node installed! run: brew install node

I tried adding node to the requirements in the manifest, but that didn’t change anything. Has anyone needed to use a nodejs package in an integration before? I’m starting to wonder if it is even possible and/or worth the effort?

Here is my manifest.json:

{
  "domain": "pentair",
  "name": "Pentair ScreenLogic",
  "documentation": "https://www.home-assistant.io/integrations/pentair",
  "requirements": [
    "node==0.9.25",
    "js2py==0.70"
  ],
  "ssdp": [],
  "zeroconf": [],
  "homekit": {},
  "dependencies": [
    "sensor"
  ],
  "codeowners": [
    "@bwoodworth"
  ]
}
1 Like