Skip to content

Home Assistant

Daniel Heinen edited this page May 9, 2026 · 1 revision

Home Assistant Integration

ankerctl supports Home Assistant MQTT Discovery, publishing your printer state directly to Home Assistant as native entities — sensors, binary sensors, a switch for the printer light, and an MJPEG camera entity.

This page covers the setup, the published entities, and a few example automations.

Architecture

[ankerctl] ──MQTT publish──▶ [MQTT broker (Mosquitto)] ──◀ subscribe── [Home Assistant]

ankerctl connects to your MQTT broker (separate from Anker's cloud MQTT) and publishes:

  • HA Discovery configuration on <HA_MQTT_DISCOVERY_PREFIX>/sensor/<id>/config
  • State on <HA_MQTT_TOPIC_PREFIX>/<printer_sn>/state (single JSON document)
  • Availability on <HA_MQTT_TOPIC_PREFIX>/<printer_sn>/availability
  • Light command/state on <HA_MQTT_TOPIC_PREFIX>/<printer_sn>/light/{set,state}

Home Assistant auto-discovers and creates the entities — no configuration.yaml edits required.

Prerequisites

  • A working MQTT broker that both ankerctl and Home Assistant can reach. The standard choice is the HA "Mosquitto broker" add-on.
  • The HA MQTT integration installed and configured to use that broker.

Setup

Via web UI

Open Setup → Home Assistant and fill:

  • Enabled
  • Broker host — e.g. homeassistant.local or 192.168.1.50
  • Broker port — typically 1883
  • Username / password — credentials for the MQTT broker
  • Discovery prefix — usually homeassistant (default)
  • Topic prefix — usually ankerctl (default)
  • HA base URLhttp://homeassistant.local:8123
  • HA long-lived access token — from your HA profile (Profile → Long-Lived Access Tokens)

The HA URL and token are used only for the MJPEG camera auto-registration — they are optional if you do not want the camera entity.

Click Save. The service auto-reloads and publishes discovery payloads within a few seconds.

Via environment variables

HA_MQTT_ENABLED=true
HA_MQTT_HOST=homeassistant.local
HA_MQTT_PORT=1883
HA_MQTT_USER=mqttuser
HA_MQTT_PASSWORD=mqttpass
HA_MQTT_DISCOVERY_PREFIX=homeassistant
HA_MQTT_TOPIC_PREFIX=ankerctl

# Optional — required only for camera auto-registration
HA_BASE_URL=http://homeassistant.local:8123
HA_TOKEN=eyJ... (long-lived access token)

See Configuration → Home Assistant MQTT Discovery for the full table.

Published entities

After discovery completes, you should see in HA → Settings → Devices & Services → MQTT:

Sensors

Entity Source
sensor.ankerctl_<sn>_progress ct=1001 progress (0–100)
sensor.ankerctl_<sn>_state ct=1000 (idle / printing / paused / aborted)
sensor.ankerctl_<sn>_filename ct=1044 path
sensor.ankerctl_<sn>_speed ct=1001 realSpeed
sensor.ankerctl_<sn>_layer_current ct=1052 real_print_layer
sensor.ankerctl_<sn>_layer_total ct=1052 total_layer (overridden from G-code header when known)
sensor.ankerctl_<sn>_nozzle_temp ct=1003 currentTemp (1/100 °C)
sensor.ankerctl_<sn>_nozzle_target ct=1003 targetTemp
sensor.ankerctl_<sn>_bed_temp ct=1004 currentTemp
sensor.ankerctl_<sn>_bed_target ct=1004 targetTemp
sensor.ankerctl_<sn>_time_elapsed ct=1001 time
sensor.ankerctl_<sn>_time_remaining ct=1001 remaining

Binary sensors

Entity Source
binary_sensor.ankerctl_<sn>_mqtt_connected MQTT cloud connection health
binary_sensor.ankerctl_<sn>_pppp_connected PPPP LAN connection health

Switch

Entity Source
switch.ankerctl_<sn>_printer_light Bidirectional — toggle in HA controls the printer LED via PPPP

Camera

Entity Source
camera.ankerctl_<sn> MJPEG stream registered via the HA REST API (requires HA_BASE_URL + HA_TOKEN)

Note Multi-printer camera auto-registration is currently incomplete. With 2+ printers configured, only the active printer's camera is registered automatically.

Lovelace examples

Quick status card

type: entities
title: AnkerMake M5
entities:
  - sensor.ankerctl_ak7abc0123401234_state
  - sensor.ankerctl_ak7abc0123401234_filename
  - sensor.ankerctl_ak7abc0123401234_progress
  - sensor.ankerctl_ak7abc0123401234_layer_current
  - sensor.ankerctl_ak7abc0123401234_layer_total
  - sensor.ankerctl_ak7abc0123401234_nozzle_temp
  - sensor.ankerctl_ak7abc0123401234_bed_temp
  - sensor.ankerctl_ak7abc0123401234_time_remaining
  - switch.ankerctl_ak7abc0123401234_printer_light

Camera + controls

type: vertical-stack
cards:
  - type: picture-entity
    entity: camera.ankerctl_ak7abc0123401234
    show_state: false
    show_name: false
  - type: entities
    entities:
      - sensor.ankerctl_ak7abc0123401234_progress
      - sensor.ankerctl_ak7abc0123401234_time_remaining
      - switch.ankerctl_ak7abc0123401234_printer_light

Example automations

Notify when a print finishes

automation:
  - alias: M5 print finished
    trigger:
      - platform: state
        entity_id: sensor.ankerctl_ak7abc0123401234_state
        from: printing
        to: idle
    action:
      - service: notify.mobile_app_pixel
        data:
          title: "Print finished"
          message: "{{ states('sensor.ankerctl_ak7abc0123401234_filename') }} done!"

Turn off the printer LED at night

automation:
  - alias: M5 light off at 22:00
    trigger:
      - platform: time
        at: "22:00:00"
    condition:
      - condition: state
        entity_id: sensor.ankerctl_ak7abc0123401234_state
        state: idle
    action:
      - service: switch.turn_off
        target:
          entity_id: switch.ankerctl_ak7abc0123401234_printer_light

Beep on print failure

automation:
  - alias: M5 print failed
    trigger:
      - platform: state
        entity_id: sensor.ankerctl_ak7abc0123401234_state
        to: aborted
    action:
      - service: media_player.play_media
        target:
          entity_id: media_player.living_room_speaker
        data:
          media_content_type: music
          media_content_id: !secret tts_print_failed_url

Multi-printer caveats

ankerctl publishes one set of entities per configured printer (using the serial number as suffix). The exception is the camera entity: only the currently active printer's camera is auto-registered with HA. To work around this, configure the additional cameras manually in HA's configuration.yaml pointing at http://<ankerctl-host>:4470/video?printer_index=N.

API endpoints

Method Path Description
GET /api/settings/mqtt Get current HA MQTT config (contains broker password)
POST /api/settings/mqtt Update HA MQTT config; auto-reloads service

Troubleshooting

See Troubleshooting → Home Assistant issues for common problems (entities missing, light switch not working, multi-printer camera quirks).

HA Supervisor add-on

If you run Home Assistant OS or Supervised, you can install ankerctl itself as an HA add-on instead of a separate Docker container. See Installation → Home Assistant Supervisor add-on.

Clone this wiki locally