Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker container #25

Closed
yue31 opened this issue Oct 22, 2022 · 13 comments
Closed

Docker container #25

yue31 opened this issue Oct 22, 2022 · 13 comments

Comments

@yue31
Copy link

yue31 commented Oct 22, 2022

Installation requires HA addons. My HA system uses Docker container and it is impossible to use Addons installation. Could you provide instructions on installation with Docker system?

@fl4p
Copy link
Owner

fl4p commented Oct 24, 2022

Do you want to run it standalone (without Docker or Home Assistant)?
https://github.com/fl4p/batmon-ha/blob/master/doc/Standalone.md

@yue31
Copy link
Author

yue31 commented Oct 29, 2022

I tested standalone and it did work. Cell voltages are showing up on screen now. I'll need to figure out how to integrate into docker home assistant.
Great work and thank you very much!

@yue31
Copy link
Author

yue31 commented Nov 6, 2022

Just let you know everything works great with standalone setup and docker HA!

Edit:
I did experience the issue of bluetooth lost after a long-lasting connection with daly bms. The issue seems to be disappeared or minimized after setting timeout to 30s and sampling time to 60s.

@rromrrom
Copy link

@fl4p could you please explain how you build docker container? Especially what is base image (BUILD_FROM). I see it requires alpine, s6 and bashio which is pretty specific requirement (do you really need all that?) and I don't see any "official" image with all that onboard . Thanks in advance.

@rromrrom
Copy link

@fl4p ah, sorry, now I got all details. I've been assuming before that this is generic docker image, but not homeassistant specific. All clear now, thanks.

@robwolff3
Copy link

@rromrrom So a docker container cant be built from this repository? I am not using home assistant OS so I cannot use the traditional add-on method, I dont think.

@rromrrom
Copy link

@robwolff3 I did like this:

  1. go to batmon-ha sources folder
  2. docker build --build-arg BUILD_FROM=homeassistant/aarch64-base:latest -f Dockerfile .

Basically you can do without homeassistant/aarch64-base and use whatever base you want, but you need a bit manual adjustments in Dockerfile

@robwolff3
Copy link

robwolff3 commented Jan 23, 2023

I'm running docker on a amd64 architecture computer. The following worked for me:

  1. Change the first line in run.sh to #!/bin/sh
  2. docker build --build-arg BUILD_FROM=alpine -f Dockerfile -t batmon-ha .

and then I ran it in docker compose with:

  batmon-ha:
    container_name: batmon-ha
    image: batmon-ha
    restart: unless-stopped
    privileged: true
    volumes:
      - ${CONFIGDIR}/batmon-ha/options.json:/app/options.json
      - /var/run/dbus/:/var/run/dbus/:z

@fl4p
Copy link
Owner

fl4p commented Feb 25, 2023

Thanks, I'll reference this in the Standalone readme

@fl4p fl4p closed this as completed Feb 25, 2023
@Sayrin
Copy link

Sayrin commented Dec 14, 2023

I'm running docker on a amd64 architecture computer. The following worked for me:

1. Change the first line in run.sh to `#!/bin/sh`

2. `docker build --build-arg BUILD_FROM=alpine -f Dockerfile -t batmon-ha .`

and then I ran it in docker compose with:

  batmon-ha:
    container_name: batmon-ha
    image: batmon-ha
    restart: unless-stopped
    privileged: true
    volumes:
      - ${CONFIGDIR}/batmon-ha/options.json:/app/options.json
      - /var/run/dbus/:/var/run/dbus/:z

run.sh has bin renamed to addon_main.sh

@Dukat-Gul
Copy link

Apparently the errors:

fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/edge/main: temporary error (try again later)

require this for raspberrypi

wget http://ftp.de.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.4-2+b1_armhf.deb
dpkg -i libseccomp2_2.5.4-2+b1_armhf.deb

@coconup
Copy link

coconup commented Feb 19, 2024

I just went through the process as well and created a somewhat cleaner setup which avoids the extra install_bleak.py step currently pointing at an old version patched for windows (?). It also sets environment variables through docker-compose instead of addon_main.sh. Finally, it avoids running the container in privileged mode.

I'm running this on a Raspberry Pi (i.e. Linux Debian), but I don't think it matters much.

./services/batmon/Dockerfile:

FROM alpine

WORKDIR /app

RUN apk update \
  && apk add --no-cache \
    python3 \
    bluez \
    py-pip \
    git

RUN rm /usr/lib/python3.11/EXTERNALLY-MANAGED

COPY ./requirements.txt requirements.txt
RUN pip3 install -r requirements.txt

./services/batmon/requirements.txt

bleak==0.20.2
paho-mqtt>=2.0.0
backoff
crcmod

./docker-compose.yml

  batmon:
    container_name: batmon
    build:
      context: ./services/batmon
    restart: unless-stopped
    environment:
      MQTT_HOST: "mosquitto"
      MQTT_USER: ""
      MQTT_PASSWORD: ""
    volumes:
      - /run/dbus:/run/dbus:ro
      - ./volumes/batmon-ha/:/app # Clone the repo in ./volumes/batmon-ha
    command: ["/bin/sh", "-c", "python3 ./main.py"]

@ThomasCr
Copy link

It would be really nice, if there would be a official maintained container on docker-hub or so.
I also dot use HASS OS and also cant use HA addons the normal way.
Currently I have no BMS to monitor, but I am planning to buy and found this very interesting integration for HA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants