gcgarner/IOTstack

Integrating Telegram Nodes into Node-RED

goderz opened this issue · 3 comments

Hello,

I'm looking to integrate Telegram nodes into Node-RED.

Initially, during the Docker container setup, I overlooked selecting the Telegram Node in the installation options. I later attempted to include it through the Build Menu and proceeded to restart all the containers, but this didn't seem to have any effect. Attempting to add Telegram nodes from the Node-RED Palette results in errors, as shown in the attached screenshot.

Could someone guide me on how to successfully integrate Telegram nodes and potentially other nodes in the future? Any assistance would be greatly appreciated.

Thank you!

Zrzut ekranu 2024-02-03 220801

Can I get you to do two things, please:

  1. Read #194 (explains why this is the wrong repo and how you should be using SensorsIot/IOTstack instead); and then
  2. Read Component Management in the Node-RED section of the SensorsIot/IOTstack Wiki.

The short answer to your question is that the "best" way to add/remove add-on nodes is to edit:

~/IOTstack/services/nodered/Dockerfile

A somewhat longer answer involves explaining that the Dockerfile used by IOTstack's service definition for Node-RED has gone through several revisions.

If you (a) use SensorsIot/IOTstack (migrating to that repo if necessary), and (b) do something which "resets" Node-RED (eg remove and re-add Node-RED), you will wind up with a service definition that looks like this:

  nodered:
    container_name: nodered
    build:
      context: ./services/nodered/.
      args:
      - DOCKERHUB_TAG=latest
      - EXTRA_PACKAGES=
    restart: unless-stopped
    user: "0"
    environment:
    - TZ=${TZ:-Etc/UTC}
    ports:
    - "1880:1880"
    volumes:
    - ./volumes/nodered/data:/data
    - ./volumes/nodered/ssh:/root/.ssh

plus a Dockerfile that looks like this:

# reference argument - omitted defaults to latest
ARG DOCKERHUB_TAG=latest

# Download base image
FROM nodered/node-red:${DOCKERHUB_TAG}

# reference argument - omitted defaults to null
ARG EXTRA_PACKAGES
ENV EXTRA_PACKAGES=${EXTRA_PACKAGES}

# default user is node-red - need to be root to install packages
USER root

# install packages
RUN apk update && apk add --no-cache eudev-dev ${EXTRA_PACKAGES}

# switch back to default user
USER node-red

# variable not needed inside running container
ENV EXTRA_PACKAGES=

# add-on nodes follow

RUN cd /usr/src/node-red && npm install --save  node-red-configurable-ping
RUN cd /usr/src/node-red && npm install --save  node-red-contrib-boolean-logic
RUN cd /usr/src/node-red && npm install --save  node-red-contrib-influxdb
RUN cd /usr/src/node-red && npm install --save  node-red-dashboard
RUN cd /usr/src/node-red && npm install --save  node-red-node-pi-gpiod
RUN cd /usr/src/node-red && npm install --save  node-red-node-rbe

Personally, I think the structure of the last six lines sucks because:

  1. The cd commands are redundant (that's already the working directory);
  2. The --save flags are redundant (have been ignored by npm for ages); and
  3. Each distinct RUN command creates a new layer in the final local image which just adds overhead.

Here's what the last part of my Dockerfile looks like:

…
# add-on nodes follow

RUN npm install \ 
  node-red-node-pi-gpiod \
  node-red-dashboard \
  node-red-contrib-influxdb \
  node-red-contrib-boolean-logic \
  node-red-node-tail \
  node-red-configurable-ping \
  node-red-node-email \
  node-red-contrib-boolean-logic-ultimate \
  node-red-contrib-chartjs \
  node-red-contrib-md5 \
  node-red-contrib-moment \
  node-red-contrib-pushsafer

Anyway, suppose I wanted to add another package. I'd add a \ continuation to the last line followed by the new package. For example:

…
  node-red-contrib-pushsafer \
  node-red-contrib-simpletime

and then run:

$ cd ~/IOTstack
$ docker-compose up --build -d nodered
$ docker system prune -f

Hope this helps.

Okay, it's working for me now. Here's what I did:

I followed these instructions:
image
from this section:
https://sensorsiot.github.io/IOTstack/Basic_setup/#when-dockerfile-changes-local-image-only

So basically, I executed the last two commands mentioned in your post. Thank you! :)

You're welcome. Don't forget the docker system prune -f. Each time you use the --build flag, it creates a new image and leaves the old image dangling. The prune command cleans-up all those dangling bits and pieces. Leaving one or two old images lying about is no big deal but if you never tidy up then, eventually, you can run out of disk space (more important if you're running from SD).