muppet3000 / growatt-weather-based-charger

A tool for configuring overnight charging (i.e. during off-peak periods) for Growatt inverters that have storage capacity (batteries) based on the predicted solar generation for the day
MIT License
16 stars 4 forks source link

Error attempting to install on rpi based OpenMediaVault #3

Closed jimwormold closed 1 year ago

jimwormold commented 1 year ago

Hi I was hoping to get this to run on my OMV server as it looks like a superb piece of work!

However if I do it via your image in the docker run command in the readme: muppet3000/growatt-charger:latest I receive:

Status: Downloaded newer image for muppet3000/growatt-charger:latest WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v8) and no specific platform was requested

And if I attempt it via the DockerFile in this repo via a git clone, I receive the following error: when it attempts to build the cffi package.

gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DFFI_BUILDING=1 -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/local/include/python3.11 -c c/_cffi_backend.c -o build/temp.linux-aarch64-cpython-311/c/_cffi_backend.o c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory 15 | #include <ffi.h> | ^~~~~~~ compilation terminated. error: command '/usr/bin/gcc' failed with exit code 1 I assume that both of these are due to it running on a RPi4 (armv8 not aarch64)?

Anyway just wondering if you had encountered this, and had any quick way of fixing or whether this is likely to be a big rabbit hole!?

Best wishes and thanks for the excellent work!

Jim

muppet3000 commented 1 year ago

Hi @jimwormold thanks for reaching out. You're right, this is down to the fact you're running on an RPI. I haven't run into this issue because I've always run this on fully-fledged Linux VMs.

When you attempted to build from the dockerfile did you remember to change the FROM line here so that it uses an ARM python image? e.g. FROM arm64v8/python:3-slim

Assuming you are using an ARM image, the specific error you're getting is a compilation error (I assume it happens during one of the apt steps) it looks like it's missing a dependency file which implies the dependencies aren't 100% aligned between the amd64 image and the arm image.

Based on this if you add libffi-dev after gcc on line 6 then you should have what you need to continue.

Good luck, let me know how you get on, bonus points if you share the Dockerfile with me afterwards to I can add it to this repo.

jimwormold commented 1 year ago

Hah! Completely missed that! Yes it runs perfectly now after trying out a few python images until one worked ...

FROM arm32v7/python:3.7-slim-buster

COPY requirements.txt /tmp/

RUN apt-get update && \
    apt-get install -y gcc libffi-dev && \  
    pip install -r /tmp/requirements.txt && \
    rm /tmp/requirements.txt && \
    apt autoremove -y gcc && \
    apt-get clean

RUN mkdir /opt/growatt-charger

COPY defaults /opt/growatt-charger/defaults
COPY bin /opt/growatt-charger/bin

VOLUME /opt/growatt-charger/conf
VOLUME /opt/growatt-charger/output
VOLUME /opt/growatt-charger/logs

ENTRYPOINT ["/opt/growatt-charger/bin/growatt-charger.py"

Excellent job and thanks for the swift help.