Shutdown a PC from HA installed on Docker (RPi)

Hello ,

Text I have been using for a while HA from hassio image for Raspberry Pi 4. There is RPC shutdown official add-in. I never used it but liked the idea. I have moved to HA installed on docker, so no option to use official add-ins, but I need this functionality. I have Raspberrry Pi4 with 4G RAM with raspbian buster.

Can you please recommend if I can use same functionality ? I am not sure how the official plugin works and how to re-create the functionality on Docker environment . I have seen few topics in the forum, but non of them is referring to the official plugin architecture.

Thank you in advance !

Hey mate - I worked this out over the weekend. The requirement for RPC shutdown to work is the Samba package, which the alpine base image for home assistant does not contain. So we need to build our own version of home assistant which adds in the Samba package.

What you need to do is create a Dockerfile (named Dockerfile) in your home assistant directory (although i think you can put it anywhere) which contains the following:

FROM homeassistant/home-assistant:latest
RUN apk update && apk add samba

Then your docker-compose file changes to:

  homeassistant:
    restart: always
    build:
      context: ${USERDIR}/docker/homeassistant
      dockerfile: Dockerfile
    volumes:
      - ${USERDIR}/docker/homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
      - ${USERDIR}/docker/shared:/shared
    network_mode: host

I’ve got some other things in my compose file which I left out, but the key part here is the build section which describes the folder (context) where the Dockerfile is located, and the name of the dockerfile (mine is actually called Dockerfile).

Then run the command

docker-compose build --no-cache --pull

This will build your new home assistant image and install Samba. Then run:

docker-compose up -d homeassistant

Replace homeassistant with whatever your container is called in the docker-compose file, and your new container will start. RPC shutdown will now work.

Not sure why they don’t just include this in the base image. Hope that helps

Should have installed ha as supervised as explained in the guide, then you’d have access to the add-on store.

@minez it was not included in base because it is a separate potentially unwanted service, hence it being included as a separate add-on. If you over complicate it building your own custom version of the image you won’t be able to keep as up to date / add additional work needed to the update process

My update procedure to build the container whenever there is a new version of HA is 1 line of code, the same as it was using the docker image before I did any of this. So there is no reason at all that I can’t stay up to date, and it is no additional work than it was previously. Nothing about this is complicated

My opinion is that if HA offers a native integration that requires that service, then the service should be included in the base image.

Sorry for reopening this topic, I allready install the image with samba, but how can I install the addon?