Giter Site home page Giter Site logo

nrchkb / node-red-contrib-homekit-docker Goto Github PK

View Code? Open in Web Editor NEW
38.0 2.0 8.0 1.3 MB

Node-RED-homekit-docker is a Node-RED based project with support for homekit.

Home Page: https://nrchkb.github.io

License: Apache License 2.0

JavaScript 100.00%
docker raspberry-pi raspberrypi nrchkb node-red

node-red-contrib-homekit-docker's Introduction

Node-RED-homekit-docker

Docker Build DockerHub Pull DockerHub Star

Node-RED-homekit-docker is a Node-RED based project with support for homekit. It is based on the official Node-RED Docker images with the necessary tools and npm module node-red-contrib-homekit-bridged installed to run homekit within a docker container.

Architecture

Node-RED-homekit-docker is supported by manifest list, which means one doesn't need to specify the tag for a specific architecture. Using the image without any tag or the latest tag, will pull the right image for the architecture required.

Currently, Node-RED-homekit has support for multiple architectures:

  • amd64 : based on linux Alpine - for most desktop computer (e.g. x64, x86-64, x86_64)
  • arm32v6 : based on linux Alpine - (i.e. Raspberry Pi 1 & Zero)
  • arm32v7 : based on linux Alpine - (i.e. Raspberry Pi 2, 3, 4)
  • arm64v8 : based on linux Alpine - (i.e. Pine64)

Note: Currently there is a bug in Docker's architecture detection that fails for arm32v6 - e.g. Raspberry Pi Zero or 1. For these devices you currently need to specify the full image tag for arm32v6.

Note: As of Node-RED 3.0.0 release, we are no longer building docker image for version 1. At the same time, images with NodeJS 10 and 12 are dropped, Node-RED 2 will be shipped with NodeJS 14. Next major NRCHKB release will require NodeJS >= 16.

Quick Start (for those already running Docker)

docker run -d --net=host -v <path_on_host>:/data -e TZ=Europe/Amsterdam -e DEBUG=NRCHKB:* --name=node-red-homekit nrchkb/node-red-homekit

Let's dissect that command:

docker run                  - Run this container.
-d                          - Run container in background and print container ID.
--net=host                  - Connect to the host network, which is required to work with homekit.
-v <path_on_host>:/data     - Persist container data
-e TZ=Europe/Amsterdam      - Set timezone, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
-e DEBUG=NRCHKB:*           - Print basic debug logs for NRCHKB
--name node-red-homekit     - Give this machine a friendly local name.
nrchkb/node-red-homekit     - The image to base it.

Raspberry Pi (including install Docker)

Following these commands will install Docker, add user pi to Docker group, then set the docker container to always run.

We assume you have some basic knowledge of Linux and you are logged in as pi user.

  1. Make sure we are in the home directory of the pi user:
cd ~
  1. Make sure we have the latest packages available and upgrade to the latest versions (reboot if needed!):
sudo apt update && sudo apt upgrade -y
  1. Download the docker install script and execute it to install Docker on your system.
curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh
  1. As the Docker script explains, add the pi user to the Docker group so that the pi user has the permissions to execute docker commands:
sudo usermod -aG docker pi
  1. Reboot the Raspberry PI or just log out and back in:
sudo reboot
  1. To test if your Docker install went well:
docker run --rm hello-world

The above command should say 'Hello from Docker':

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:7f0a9f93b4aa3022c3a4c147a449bf11e0941a1fd0bf4a8e6c9408b2600777c5
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

If the above steps went as expected, you are ready to run the nrchkb/node-red-homekit image as a container. But before that we create a directory on the pi host so that all node-red / node-red-homekit files are stored outside the container on your raspberry pi.

  1. Make directory in your pi user's home directory:
mkdir node-red-homekit
  1. Run the Docker run command to deploy the nrchkb/node-red-homekit image as a container and where the container /data directory is bound to the /home/pi/node-red-homekit directory on your Raspberry PI.
docker run -d --net=host -v ~/node-red-homekit:/data --restart always -e TZ=Europe/Amsterdam -e DEBUG=NRCHKB:* --name node-red-homekit nrchkb/node-red-homekit

You don't need to explicit map ports, since all ports are opened on the hosts network! This is required for homekit to work well.

Upgrade to the latest image

Suppose there is a new nrchkb/node-red-homekit image available? How do I make use of this new image?

  1. Find the id of your current deployed container:
docker container ls

The above command lists all running container and in the first column it displays the id of the container and in the last column it's name.

  1. Stop the current container:
docker stop <container_id or container_name>
  1. Remove the current container:
docker rm  <container_id or container_name>
  1. Pull the latest nrchkb/node-red-homekit image from Docker Hub:
docker pull nrchkb/node-red-homekit
  1. Deploy the container again:
docker run -d --net=host -v ~/node-red-homekit:/data --restart always -e TZ=Europe/Amsterdam -e DEBUG=NRCHKB:* --name node-red-homekit nrchkb/node-red-homekit

This runs the container based on the latest nrchkb/node-red-homekit image and retains your flows!

Docker Compose (including install Docker Compose)

For demo purpose we use a Raspberry Pi with Docker installed (see )

  1. Install required packages for Docker Compose
sudo apt update && sudo apt install -y libffi-dev libssl-dev python3 python3-pip
  1. Install Docker Compose using pip3
sudo pip3 -v install docker-compose
  1. Create a Docker compose yml for nrchkb/node-red-homekit:

Let's assume you have a directory /home/pi/node-red-homekit with a data sub-directory:

node-red-homekit/
`-- data

1 directory, 0 files

Use your favorite editor like nano to create a file named docker-compose.yml with the content below and save it in /home/pi/node-red-homekit.

version: '2'
services:
  node-red-homekit:
    image: nrchkb/node-red-homekit
    restart: always
    network_mode: host
    environment:
      - TZ=Europe/Amsterdam
      - DEBUG=NRCHKB:*
    volumes:
      - /home/pi/node-red-homekit/data:/data

note 1: /home/pi/node-red-homekit/data is the persistence directory where the Docker container stores its files. note 2: there is no port mapping defined, since the container is attached / uses the host network.

  1. Deploy the service as define in docker-compose.yml

From the /home/pi/node-red-homekit directory executed the command below to deploy the service and therefore the container:

docker-compose up -d
  1. Verify your deployed container:
docker container ls
  1. To update to the latest image:

The command below stops the current running container, removes it and removes the image.

docker-compose down --rmi  all

Run the command in step 4 to redeploy the service. It pulls the (latest) image, since now is available locally.

Synology

Synology users need to add the environment variable DSM_HOSTNAME.

Click the Environment tab and add a new environment variable named DSM_HOSTNAME. The value of the DSM_HOSTNAME environment variable should exactly match the server name as shown under Synology DSM Control Panel -> Info Center -> Server name, it should contain no spaces or special characters.

docker run -it --net=host -v <path_on_host>:/data -e DSM_HOSTNAME=<synology_hostname> -e TZ=Europe/Amsterdam -e DEBUG=NRCHKB:* --name=homekit nrchkb/node-red-homekit:<tag>

Permissions

Since Node-RED 1.0 the container user is node-red and has uid 1000 and gid 1000, make sure your <path_on_host> has the same uid and gid:

Verify command:

ls -nal <path_on_host>

Modify command:

chown -R  1000:1000 <path_on_host>

Debug

To debug NRCHKB you have to add environment variable to command running node-red in docker by adding -e argument:

-e "DEBUG=NRCHKB*,HAP-NodeJS*"

To do that modify starting script like below:

docker run -it -e "DEBUG=NRCHKB*,HAP-NodeJS*" --net=host -v <path_on_host>:/data -e DSM_HOSTNAME=<synology_hostname> -e TZ=Europe/Amsterdam -e DEBUG=NRCHKB:* --name=homekit nrchkb/node-red-homekit:<tag>

Node-RED Docker official

For more detailed info refer to the Node-RED Docker official pages.

NRCHKB Support

For more info visit our Website or Discord.

node-red-contrib-homekit-docker's People

Contributors

crxporter avatar dependabot[bot] avatar github-actions[bot] avatar raymondmouthaan avatar reitermarkus avatar rlindner avatar shaquu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-red-contrib-homekit-docker's Issues

Rationale behind host network mode

Hi,

as you probably know the Docker's host network mode has its limitation. Please, could you explain why it's the only network mode supported? Have you tried adding support for the other modes, e.g. bridge?

node.js 16 support

Hi,
I am very happily using the latest image, however when trying to install a node-red package like nodered-contrib-ring-alarm it requires node.js >= 16.x, the latest image here is based on node.js 14.x
What would be the best way to "lift" the docker image to support node.js 16.x packages?
I put this as an issue in order to either get you expert opinion in how to do it on my end or on the official image side.

Synology installation

Hi,

when trying to install the NRCHKB-Docker-Image via the SSH-shell of my Synology DS220+

sudo docker run it --net=host -v /volume1/docker/nrchkb:/data -e DSM_HOSTNAME=ds220 -e TZ=Europe/Berlin --name=homekit nrchkb/node-red-homekit

I get the following error message:

Unable to find image 'it:latest' locally docker: Error response from daemon: pull access denied for it, repository does not exist or may require 'docker login'. See 'docker run --help'.

Do I have to add the described Environment variable before or after pulling the docker image?

Thanks in advance!

Frank

Problem with video playback with copy codec

Hey.

I add cameras with RTSP stream. I specify copy as the codec. Everything is great adding and showing video in Home app on phone. But when you start a broadcast on Apple TV, the broadcast doesn't start. Tell me what could be the problem?

Stateless container

Hi,

I came across an issue that isn't directly related to this docker image, but as it's related to the topic of containerisation I'm posting it here.

My node-red container is stateless. I setup the homekit plugin and it worked fine until I updated the image. After the update, the devices present in the app aren't synchronised with the server.

After a quick research I noticed two things:
Logs before the update:
2022-02-15T21:16:53.226Z NRCHKB:ServiceUtils [garden light:08f97fb592e46698] onCharacteristicGet with status: 0, value: true, reachability is true with context undefined on connection 854ccad2-7679-4424-a53b-1dbf909c28c9
Logs after the update:
2022-02-15T21:20:42.163Z NRCHKB:ServiceUtils [entrance light:79e11c5148783c6b] onCharacteristicSet with status: 0, value: false, reachability is true with context undefined on connection undefined

The homekit plugin creates a directory /data/nrchkb/

Without digging deeper I'm guessing that the homekit plugin persists pieces of information that are essential for it to operate.
Have you ever considered the stateless scenario? Is is possible? Which pieces of information/directories are essential to make it operate correctly?

[Bug]: CameraSource-Error ERROR: FFmpeg exited with code 1 (No such file or directory)

NRCHKB Plugin Version

1.4.3

Node JS Version

14.18.2

NPM Version

6.14.15

Node-RED Version

2.2.0

Operating System

Raspberry bullseye (docker node-red-contrib-homekit-docker)

What happened?

node-red       | 2022-02-14T01:38:06.539Z CameraSource ffmpeg -i rtsp://192.168.0.32:554/user=free&password=***&channel=3 -map 0:0 -vcodec copy -pix_fmt yuv420p -r 15 -f rawvideo  -b:v 299k -bufsize 299k -maxrate 299k -payload_type 99 -ssrc 16657252 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params er1ZhH4s/12lu8zGqkODN9hLDLvqY/AR/WrOwUTW srtp://192.168.0.111:53641?rtcpport=53641&localrtcpport=53641&pkt_size=1316
node-red       | 2022-02-14T01:38:06.555Z CameraSource ffmpeg data: ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
node-red       |   built with gcc 9.3.0 (Alpine 9.3.0)
node-red       |   configuration: --pkgconfigdir=/build/workspace/lib/pkgconfig --prefix=/build/workspace --pkg-config-flags=--static --extra-cflags=-I/build/workspace/include --extra-ldflags=-L/build/workspace/lib --extra-libs='-lpthread -lm' --enable-static --disable-debug --disable-shared --disable-ffplay --disable-doc --enable-openssl --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-libvpx --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libx264 --enable-runtime-cpudetect --enable-libfdk-aac --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-decoder=h264 --enable-network --enable-protocol=tcp --enable-libspeex --enable-demuxer=rtsp --enable-indev=alsa --enable-outdev=alsa
node-red       |   libavutil      56. 51.100 / 56. 51.100
node-red       |   libavcodec     58. 91.100 / 58. 91.100
node-red       |   libavformat    58. 45.100 / 58. 45.100
node-red       |   libavdevice    58. 10.100 / 58. 10.100
node-red       |   libavfilter     7. 85.100 /  7. 85.100
node-red       |   libswscale      5.  7.100 /  5.  7.100
node-red       |   libswresample   3.  7.100 /  3.  7.100
node-red       |   libpostproc    55.  7.100 / 55.  7.100
node-red       | 2022-02-14T01:38:12.056Z CameraSource ffmpeg data: Input #0, rtsp, from 'rtsp://192.168.0.32:554/user=free&password=***&channel=3':
node-red       |   Metadata:
node-red       |     title           : RTSP Session
node-red       |   Duration: 
node-red       | 2022-02-14T01:38:12.058Z CameraSource ffmpeg data: N/A, start: 0.260867, bitrate: N/A
node-red       |     Stream #0:0: Video: h264 (High), yuv420p(tv, progressive), 1920x1080, 23 fps, 23 tbr, 90k tbn, 46 tbc
node-red       | : No such file or directory
node-red       | 2022-02-14T01:38:12.063Z CameraSource-Error ERROR: FFmpeg exited with code 1

How to reproduce?

empty "Additional Command Line"

image

Expected behavior:

Describe expected behavior here, with relevant screenshots if they would help.

Additional comments?

Additional comments here, if any.

Relevant log output

No response

[Setup Help]: Can't add bridge (no response) - docker setup

First of all, thanks again for this great piece of software!! :-)

Maybe somebody has an idea..

Since 1-2 weeks I can't connect to the homekit objects. Maybe there have been some changes... Does anybody have an idea for me or has the same issues?

Problem description:

  • Bridge is found while scanning.
  • After adding the bridge it tries to add.
  • "No response from device" comes up after 1-2 minutes.

Setup Help
Physical hardware device:

  • RPi4
  • docker
  • node-red:latest
  • homekit bridge library latest release (1.2.0)

Apple Setup:

  • Apple TV 4. Gen as Home
  • iPhone 8Plus / iPad Pro 2020 with latest iOS 14

HomeKit setup:

  • Switch Service
  • Bridge with default settings (PIN 111-11-111), allow message passthrough

Node-red container setup:

  • host mode
  • ports: 80:80 (TCP), 443:443 (TCP), 5353:5353 (UDP+TCP), 51827:51827 (TCP)
  • priviledged mode

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.