NodeJS on Hass.io

Hi All,

I currently run a Hassbian build and would like to migrate to Hass.io.

I have a few scripts that I currently run using NodeJS to control my garage door and alarm system. Is there a way to run these Node scripts in Hass.io?

Any help would be appreciated.

Cheers,
Kaz

I managed to create a local addon with NodeJS.

Can you share what you did? I’m very interested in being able to integrate NodeJS code with Hass.io.

I basically created a HASS addon that installs NodeJS in a docker container.

Inside the container, I’m running an Express API that I connect from HASS to retrieve some sensor data.

This is what my Dockerfile looks like:

FROM %%BASE_IMAGE%%

ENV LANG C.UTF-8

RUN apk add --no-cache nodejs-current yarn && \
yarn global add npm && \
yarn cache clean && \
apk del yarn && \
npm set unsafe-perm true && \
npm install install express request

# Expose tcp/8081
EXPOSE 8088

# Copy data for add-on
# Bundle app source
COPY . /
COPY run.sh /
RUN chmod a+x /run.sh 

CMD [ "/run.sh" ]

How’s your config and run.sh looks like?

//Gustafsson

Are you please able to elaborate on this for the newer peeps like myself? I’ve just moved to hass.io and discovered I need node back for my kodi voice control. :slight_smile:

Here is a working addon i wrote in NodeJS for home assistant

you can take the dockerfile from there

1 Like

Have a look at https://github.com/helmut-hoffer-von-ankershoffen/hassio-ring-bridge for a Home Assistant -> Ring bridge built as an addon in NodeJS.

Hey guys, any update on this?

I’m using exact the same Dockerfile and run.sh as you, but I always get the error:
The command '/bin/bash -o pipefail -c cd / && npm install --unsafe-perm' returned a non-zero code: 1
Is your code outdated or did I miss something?

Here’s another NodeJS addon starter project. Works for me. hassio-addons/hassio-addon-nodejs-starter at master · kdw2060/hassio-addons · GitHub

HACS says now: “Repostitory structure for master is not compliant”

What is it that you are trying to install? The ring integration or nodered? If you are not running a supervised install and only the core in docker use the regular docker setup for nodered. Then add HA web socket to integrate in home assistant.

https://nodered.org/docs/getting-started/

HACS is not for add-ons, it makes you click ‘i have read and understand that HACS does not contain add-ons’ when you install it. Still they’re so friendly to provide a link to the supervisor-area where you can install add-ons. So head over to supervisor > add-on store and try again.