-
Notifications
You must be signed in to change notification settings - Fork 19
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
Use on HA Docker install #8
Comments
I think you can easily install this manually on a HA Docker install as follows:
I think that should be it. Mind you I haven't tested it as I'm using a virtualised HassOS installation, so there might be further little modifications required. |
I guess one man's "easy" is another man's "WTF?!?!". @piit79, I had to think about what you said above, and as I am no expert in this field, so I thought I would add some more defined steps. Unfortunately, I got so far then failed to build the docker image (step 5).
I get the output:
Assuming the above works, I think the next step would be to create the container. If you have any ideas on what I'm doing wrong, that would be great. |
Apologies I didn't provide more details in my original comment as I didn't really have time for that - I thought I'd leave the details as an exercise for you ;) First, I see you're disabling the
Then, when building the image, you would probably have to specify the concrete source image for the Please let me know how you get on. I'll try to help more if I can :) |
Yep on the build front :) - you beat me to posting ;) I changed the
then ran:
Which at least completed a build of the image. I need to crash now and will look more at this tomorrow. Thanks. |
ok, just before I fall over, I change the
Built with:
A build completes OK, but I will have to wait until tomorrow to see if the container works, and if I can get HA to work with it. |
You're making good progress! I see you left the custom component installation in I would expect the container to work. Then it's just a matter of the main HA container being able to access the API of the whatsapp container. Please keep us updated :) |
Er... yes.. it was a great idea... completely meant... not a fluke or luck at all... Actually, I did want to map a local host folder to the container config folder, but the next step of mapping that to HA eluded me. Even an infinite number of monkeys with infinite time, and an infinite number of typewriters, may produce Shakespeare's complete works at some point. I guess randomly bashing on the keyboard will have a similar end result with this ;) Have a good rest of what is left of Christmas :) |
okey-dokey, finally back to the land of the living, the container creates using the following
Unfortunately, then exists immediately. The docker logs show:
So, I think something needs to be fixed with JSON parsing, I think? Looking at the Currently, I don't have a HA OS installation (my server recently blew up and took the HA VM with it, hence using the Synology NAS to run docker). |
Wow, it's great to see how much progress has been made. I raised the question but haven't had a chance to implement this myself yet. I did a bit of research and found this page: https://developers.home-assistant.io/docs/add-ons/configuration/ which explains the use of options.json and the data folder. Looking through index.js I noticed it refers to the supervisor which doesn't exist on docker installs. I wonder if this could be causing the issue and if there is another route which needs to be used to connect to the home assistant api? |
As far as I understand (looking at the link @Chief-T1 posted above helped as well) - So you should be able to fix this by configuring a persistent volume for the container, mounting it in
Unfortunately, as @Chief-T1 pointed out, the add-on uses the supervisor API to display the persistent notification with the linking QR code. That would have to be replaced by the native HA API as you have no supervisor... Another much simpler (but much less user-friendly) possibility would be to dump the linking data into the add-on logs and then create the QR code manually using an on-line QR code. |
I might be wrong but I think the API may still be available to use if you replace The example in the Rest API docs doesn't seem to use supervisor and connects to api/services using the ip and port. https://developers.home-assistant.io/docs/api/rest/ |
I'm sorry, I have been busy for a few days. Indeed @Chief-T1, issuing a GET method against the For example,
returns (truncated for easier reading) :
|
Oh, a bit more progress, thanks to you two. So, I added a folder So, on the Synology, I have the volume root (mapped to /data/whatsapp-ha/)
The data folder contains the The
Now, the container still exits, BUT it does spit out a whole bunch more logs: HAPPY NEW YEAR (well, it might be if this is resolved). From the logs, it looks as if the following URL (and probably others after this call), cannot be found:
So, if this were redirected to. |
FWIW, I asked a question regarding converting add-ons to stand-alone docker containers in the HA community, and there was some good info posted (see https://community.home-assistant.io/t/is-it-possible-to-convert-an-addon-for-ha-os-to-run-in-a-standalone-container-for-ha-as-a-docker/511306/4?u=swinster) relating to the need for authentication toward the above API (as shown in #8 (comment) with the use of a long live token) |
Ok, I think I have a docker container running :) without exiting - here are the logs:
I edited the
Original code:
Modified code block:
I then rebuilt the image as before and re-ran it, and et voila. Not sure where to go now though. |
OK, I needed to pay more attention to the main HA Settings - a QR code automagically popup up and allowed me to connect to my WhatsApp account. I now have a new device logged in on Ubuntu. So, we are getting there.. Unfortunately, there seem to be some crashes in the Whatsapp-HA docker code, and I see no whatsapp.send_message service.:
If I tried to add: whatsapp: to the HA
|
Good progress! I'm not sure what the mutex issues mean, or what could be causing them unfortunately...
That would mean you don't have the custom component installed yet, or it's installed, but not active. If you've installed it and want to avoid a double restart, just restart the main HA docker manually (skipping the configuration check). Or remove the |
Ok, I'm not entirely sure how to install the custom component yet. It's not an integration (and doesn't appear in that list), and other is no concept of add-ons in HA Docker. I will re-read the above to see if there are things I glossed over, but whatever I do to either restart HA or the HA docker (with the WhatsApp docker running), as soon as I re-add |
The custom component is the code that provides the new If you check the docker entrypoint script run.sh, it's installed there automatically - it goes into Then restart HA, add |
Awesome. I guess this is what you were talking about previously regarding mapping volumes. After sleeping on it, the change is simple and doesn't involve manually copying config, but rather redirecting the
And once HA has restarted, we can see the WhatsApp services: I haven't tried to send anything yet, which may need to wait for a bit but I will try later. |
FWIW, I have tried to send some messages via the Will try again tomorrow. |
That's great you now see the services in home assistant. Hopefully this is the last stretch and you're nearly there 🙂. I'm not sure what you're using for the send params but this page (hidden away from the home page) already has some example params for each service and states how the user id should be formatted. |
That all matches what I see in the documentation apart from body where they've used it in this format. So hopefully that should get it working |
@Chief-T1 , I have missed this, where did you see this? It would imply that |
It seems that all problems have been solved, I close the issue. |
|
That's great to hear, @swinster! I'm glad I could help a bit. The |
Hmm, I was looking to see if I could build an image that wouldn't require manual configuration for each user (by hopefully passing docker environment variables into the container to remove the reliance on the template variable
I checked, and the |
OK, never mind, I see a bunch of things (including this) have changed in the last commit. Just trying to keep me on my toes ;) |
This add-on is tested on various supervised home assistant devices. I don't understand everything you did with the docker compose file, it's not included in my repo, sorry. In the README file there is also an installation guide which in my opinion is not that difficult. |
UPDATED: Updated the UPDATED 2: There was a bug in the @Chief-T1 , I think I might have made some progress in creating an image that can be reused (although, TBH, I am kind of randomly bashing the keyboard ;) ). Currently, this is built using the https://hub.docker.com/r/swinster/whatsapp-ha The following docker-compose service component for the NOTE: I link the whatsapp-ha:
image: swinster/whatsapp-ha:amd64-base
container_name: whatsapp-ha
volumes:
- /data/homeassistant/custom_components:/config/custom_components
- /data/whatsapp-ha/data:/data
ports:
- 3000:3000
environment:
- HA_PORT=<Port_used_by_HA_container>
- HOSTNAME_ID=<IP_Address_of_HA_container>
- TOKEN=<long_livedHA_token> The three environment variables map to variables used in the You also need to add the As an example, here is my HA homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
volumes:
- /data/homeassistant:/config
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
privileged: true
network_mode: host
environment:
- HOSTNAME_ID=<IP_Address_of_WhatsApp-ha_container> I'm sure this is an inefficient way of doing things, but its a start :) For reference, here are the modified |
@giuseppecastaldo, you are correct, it is not that difficult - assuming you are using a supervised HA deployment. If you are running on a HA that is non-supervised (such as in an HA Docker container), there is no facility for an add-on at all, hence this thread. What we have done here is take the add-on and turned it into a stand-alone docker image that could then be deployed in non-supervised HA deployments. WIth a bit of luck, the modification above should allow people to deploy it as an add-on OR a stand-alone container. |
UPDATE - to make better use of environment variables UPDATE 2 - Added some steps to explain about persistent volumes and mapping them to the docker containers, and added the I need help figuring out (at the moment) how to build the images for other architectures (such as arm7), given I do not have access to those architectures. If the various images could be built and published online as per the In the meantime, here is my manual build process:
Other architectures are:
whatsapp-ha:
image: whatsapp-ha
container_name: whatsapp-ha
volumes:
- /data/homeassistant/custom_components:/config/custom_components
- /data/whatsapp-ha/data:/data
ports:
- 3000:3000
environment:
- HA_PORT=<Port_used_by_HA_container>
- HOSTNAME_ID=<IP_Address_of_HA_container>
- TOKEN=<long_livedHA_token> NOTE: make sure you then update the
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
volumes:
- /data/homeassistant:/config
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
privileged: true
network_mode: host
environment:
- HOSTNAME_ID=<IP_Address_of_WhatsApp-ha_container> NOTE 2: make sure you update the |
I was going to look at creating multiple architecture stand-alone docker images, but unfortunately (for some reason), I am now seeing a Syntax error in
It does look like a commit was made that changed things on this line (5429368#diff-042b282ca284738d79e928df8b79cf09d265058fd48103b6a401d9034701a3bf), but I am not skilled enough to understand why this is causing an issue now. Even so, things worked after I pulled these changes, so I wonder why they have broken now. |
I'm checking the problem, thanks for reporting |
I installed the add-on on a clean instance of Home Assistant and there doesn't seem to be any issues. Maybe it's a cache problem. Try uninstalling the addon completely or doing a rebuild. |
Hi @swinster I use a Raspberry pi 4 which is ARM64 architecture, so I can test the installation on this. I just had a couple of questions from your comment here: #8 (comment) When you say:
I use openmediavault and my docker data folders are on different drives. I've never used symbolic links before (although it looks like something I should learn about using in the future) but can I just reference the path location as I normally would or do I need to change something else too? For this bit here, I already have some custom_components which I want to keep separate, I assume I can just reference the whatsapp component folder inside the custom_component folder instead?
I currently access HA over https and have an SSL certificate. Is this where the hostname environment variable you mentioned comes into play or would this not work over https?
Thanks again for all your great work 😄 |
@giuseppecastaldo , indeed, whist what we are doing here is NOT working on the add-on and instead we are working on a standalone docker image, I removed all previous configuration, re-cloned this git repo and replace the FWIW, I have also figured out how to build separate containers based on different architectures using the HA builder, so with a bit of luck, we should be able to publish standalone docker containers for all architectures. @Chief-T1 in the process of re-building the above and going back to a blank canvas, I realised that there were a couple of bit missing from my build process above. I will add those to the post above (#8 (comment) - which will be UPDATE 2). However, if the build process works as I hope, then YOU would NOT need to build, merely add the relevant P.S. I am merely floundering my way through this :) The "great work" celebration need to go towards @giuseppecastaldo and the others to bring this functionality to the stage. |
okey-dokey, looks like we have something resembling an actual resolution for this issue :) @Chief-T1 , I have created a cross-architectural image that allows this add-on to run a standalone container, which finally resembles a resolution to this issue. There are still some things to think about, but it's close. I have had to post the images to individual Docker hub repositories as I can't figure out how to post the same
To make use of these, you need to pull the image using the following whatsapp-ha:
image: swinster/whatsapp-ha-amd64
container_name: whatsapp-ha
restart: "no"
depends_on:
- homeassistant
volumes:
- /data/homeassistant/custom_components:/config/custom_components
- /data/whatsapp-ha/data:/data
ports:
- 3000:3000
environment:
#- HA_PORT=8123
- HA_HOSTNAME=<your_hostname_or_ip_of_the_HA_container>
- TOKEN=<long_lived_API_token> NOTE 1: Select the correct image for your architecture by updating the NOTE: 2 Ensure the NOTE 3: The NOTE 4: I have also changed the environment variable names (e.g. In addition, you need to update the Home Assistant homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
volumes:
- /data/homeassistant:/config
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
privileged: true
network_mode: host
environment:
- WHATSAPP_HOSTNAME=<your_hostname_or_ip_of_the_whatsapp-ha_container>
#- WHATSAPP_PORT=3000 NOTE: This is an example of my HA Once deployed, you still need to update the HA whatsapp: I might do a little video on all of this. It would be super cool (@giuseppecastaldo) if the changes to the |
@Chief-T1 - there was an update to this repo by @giuseppecastaldo in the last couple of days, and the version bumped to 1.3. I thought I would rebuild the standalone image, but unfortunately, in the first instance, it failed :( I am still determining this issue, but it relates to the update to
|
Hmm - the folder I think @giuseppecastaldo was originally forking the entire Again, apologies if I do not understand this correctly. |
A quick update. I thought this was my issue, as I had forked this repo to add the relevant changes to the The error printed above:
seem to be similar to the issue #6, abliet that issue reference the |
Having an issue with the docker install. I've changed the port to 3001 as 3000 was already in use. upon sending a message i get the following error, any help would be appreciated: Logger: homeassistant.components.websocket_api.http.connection [139975312049536] Error handling message: Unknown error (unknown_error) from 192.168.86.166 (Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36) During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): |
@chinedu40 Did you verify that |
Thanks a lot for this nudge. It made me realise that if you are changing the ports, only the docker host port needs to change and not the container port. This meant i just needed to change the port mapping to 3001:3000 instead of 3001:3001. It appears for the plugin that port 3000 is a constant container port that the node is listening on. |
@chinedu40 , I guess anything is doable. I have some other issue at the moment and haven't had time to figure out the update of this docker image. Hopefully, I can get back to it soon. |
I finally got around to testing this on my Raspberry Pi. It took me ages as I previously was using a selenium script to automate this with Node Red and while my hacky method wasn't perfect it worked. First of all, this now works 10 times better and messages send instantly, I've had no issues with it randomly stopping working how I did with my old method. I had some issues using your image on the Raspberry Pi related to what you mentioned above with the ha-builder not working. So I had to manually change the build argument in the Dockerfile to I access home assistant using HTTPS and unfortunately, this failed to work as it's hardcoded to use HTTP. I have raised a pull request on your forked repo to take this into account. I manually changed this on my build and it works seamlessly now. Just out of interest have you used any of the subscribe to WhatsApp status methods? I was reading about them but was unsure how one would unsubscribe. Thanks |
I spent some time fixing the error. I forked @swinster repo, made the change to src/Defaults/baileys-version.json and changed it to "version": [2, 2323, 4]. I then downloaded the zip file and unpacked it on my synology nas drive. I edited the dockerfile to include ghcr.io/home-assistant/amd64-base architecture. I ran "sudo docker build -t whatsapp-ha ." It was built successfully. I then didn't exactly know where the image was stored but turns out running docker on synology 6.2 listed my image on the docker app and i made a container from there. I had to stop swinters/image so i could use the same settings as before but i hope the above helps someone else to fix the issue. |
Hey @chinedu40 . I love this comment, "I don’t have the expertise to update".... There is a queue 🤣 I have recently broken my HA, and have just been fixing it tonight. Maybe I can look at this at the weekend. |
Hello, is anybody keeping a how-to on this install somewhere, I am not sure I would be able to re-create it from all the comments? |
Hi,
I use the HA docker installation and don't have the addon store. Your addon looks really amazing and I would be really keen to use it. Is there a method in which I can install this on the docker install or would this be difficult to implement?
Thanks
The text was updated successfully, but these errors were encountered: