ankermake-m5-protocol icon indicating copy to clipboard operation
ankermake-m5-protocol copied to clipboard

Home assistant integration

Open cunninr2 opened this issue 1 year ago β€’ 17 comments

Your issue may already be reported! Please search on the issue tracker before creating one.

Describe the solution you'd like Excellent work. I'm really interested in getting status monitoring of the Ankermake M5 into home assistant so I can monitor from afar and auto shutdown. Probably only needs a few status parameters such as printing, job completed, bed/nozzle temps. start/stop printing. The icing on the cake would be a camera feed for sure. keep up the good work.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

cunninr2 avatar Sep 14 '23 22:09 cunninr2

Despite the title, #92 seems to be working in this same direction -- you may want to see about coordinating efforts.

BowlesCR avatar Sep 17 '23 20:09 BowlesCR

I would also be ninteressted in a HA integration. Thanks ✌🏻

Phoenix-DH avatar Apr 24 '24 18:04 Phoenix-DH

Please work on this#

JayRHa avatar Jun 23 '24 16:06 JayRHa

Hi - I've been working on a Home Assistant integration that seems to have now reached a usable stage, which is available here: https://github.com/sondregronas/ankermake-hass-component and can be installed via hacs.

Note: I've only tested with ankerctl in the v1.1 branch, and I'm not sure how stable it is yet as finding errors or debugging takes a lot of time

I'm also open to moving said integration over to the Ankermgmt organization if it's of any interest. (https://github.com/Ankermgmt/ankermgmt-hassio-addons/issues/5)

sondregronas avatar Jul 07 '24 18:07 sondregronas

Hey, this sounds great! Thanks. Does that mean that in addition to your hacs also an ankerctl instance must be running? Anything else needrd on HA? MQTT Broker?

But where to find ankerctl for HA? Am I blind?

Thanks

β€”

Addon found πŸ‘πŸ»

Phoenix-DH avatar Jul 07 '24 19:07 Phoenix-DH

You just need an instance of ankerctl running, yes. Once you've installed via HACS / imported to custom_components you should find it under "Add Integration" in the Devices & Services dashboard. There's no need for an MQTT broker or any other dependencies as it uses ankerctl's own provided webserver (/ws/mqtt endpoint)

image

sondregronas avatar Jul 07 '24 20:07 sondregronas

Thanks! Just added your repo to HACS and the Addon to HA. Will try next time when I use the printer.

Thanks.

Phoenix-DH avatar Jul 07 '24 20:07 Phoenix-DH

Is the current way to install home assistant addon. Afterwards install ankerctl on your pc to generste login.json. Import login.json on the home assistant ankerctl webpage?

Phoenix-DH avatar Jul 10 '24 12:07 Phoenix-DH

You need ankerctl running, I use this fork in docker for the time being: https://github.com/sondregronas/ankermake-m5-protocol/tree/patch-exiles-1.1-auto-restart-on-failure, but I presume the home assistant version should work.

The integration only needs the URL of an ankerctl instance, it doesn't matter if its running via home assistant or not.

EDIT: This docker-compose.yml file should work with my changes, though there's not much deviation from this default branch for the integration if you don't use go2rtc for the camera

services:
    ankerctl:
        container_name: ankerctl
        restart: unless-stopped
        build: 
          context: https://github.com/sondregronas/ankermake-m5-protocol.git#patch-exiles-1.1-auto-restart-on-failure
        privileged: true
        # host-mode networking is required for pppp communication with the
        # printer, since it is an asymmetrical udp protocol.
        network_mode: host
        environment:
            - FLASK_HOST=0.0.0.0
            - FLASK_PORT=4470
        volumes:
            - ankerctl_vol:/root/.config/ankerctl
            - ./ankermake-m5-protocol/web/:/app/web

    # This container will restart the ankerctl container every 2 hours
    # as a temporary workaround for some socket issues.
    ankerctl_restarter:
      image: docker
      volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
      # 2 hours = 7200 seconds
      command: ["/bin/sh", "-c", "while true; do sleep 7200; docker restart ankerctl; done"]
      restart: unless-stopped
volumes:
    ankerctl_vol:

sondregronas avatar Jul 10 '24 14:07 sondregronas

Sure, but i do not want to run something in parallel. I think I found in one orher thread maybe a solution: https://github.com/Ankermgmt/ankermake-m5-protocol/issues/161

Phoenix-DH avatar Jul 10 '24 18:07 Phoenix-DH

@Phoenix-DH

https://github.com/sondregronas/ankermgmt-hassio-addons - try replacing the main addon with this (remove the old repo from AddOn repos & replace with the new one - works for me :smile: (<hass-ip>:4470, ingress does not work on mine either)

This is the same Dockerfile as in my fork - which has the same changes as the fork/pr you linked, though it is not a long term solution. Once merged I'll most likely remove it.. (or just update it to the main repo's latest release)

I'd recommend creating an automation to restart the AddOn every 2 hours, if you want a reliable videostream.

sondregronas avatar Jul 10 '24 19:07 sondregronas

Thanks! Will try next days. I have only a M5C without video.

Edit: Replaced quickly the add-on, but it wonβ€˜t start: W] No printers found in config. Please upload configuration using the webserver or 'ankerctl.py config import' [!] Printer number 0 out of range, max printer number is -1 [*] ServiceManager: Shutdown complete [W] No printers found in config. Please upload configuration using the webserver or 'ankerctl.py config import' [!] Printer number 0 out of range, max printer number is -1 [*] ServiceManager: Shutdown complete [W] No printers found in config. Please upload configuration using the webserver or 'ankerctl.py config import' [!] Printer number 0 out of range, max printer number is -1 [*] ServiceManager: Shutdown complete

Do I miss somerhing in addition?

Phoenix-DH avatar Jul 10 '24 20:07 Phoenix-DH

I'll have a fix out in a couple minutes - good catch, this must've been an oversight in one of the other PRs :)

Go to AddOns and hit Check for Updates then rebuild the container in ~30 minutes

sondregronas avatar Jul 10 '24 20:07 sondregronas

Hey, will try it tomorrow! Thanks!

Phoenix-DH avatar Jul 10 '24 20:07 Phoenix-DH

Should be working now in a couple minutes (requires a rebuild of the addon) - I'm not 100% certain the M5C is supported, from what I can tell it should?

EDIT: I've tried to log off and log back in again via the addon - everything seems to be working fine on the M5 at least πŸ˜„

If there's any issues with the component please move the convo over here: https://github.com/sondregronas/ankermake-hass-component/issues - I won't be able to work on this again until a couple weeks from now, but as far as I can tell we're stable-ish.

sondregronas avatar Jul 10 '24 21:07 sondregronas

Thanks! I installed the latest and there is a login windows. Will do the rest of testing today.

Phoenix-DH avatar Jul 11 '24 05:07 Phoenix-DH

Login worked, will install the plugin. Also the upgrade to v1.0.2. of the addon was working.

Phoenix-DH avatar Jul 11 '24 12:07 Phoenix-DH