Guides / Home Assistant

Connect your print farm to Home Assistant.

Layers3D tells Home Assistant when a print starts, finishes or fails, with the printer, the job and the material. Home Assistant does the rest: fans, plugs, lights and speakers.

What you can do with it

  • Air filter for ABS and ASA. The enclosure fan comes on when a fume-heavy print starts and goes off 15 minutes after it ends.
  • Power off when done. A smart plug cuts power once the printer has cooled.
  • Hear about failures. The shop lights flash red and a speaker says which printer failed.
  • Plate reminders. A speaker says "Clear the plate on H2D-1" when the queue needs you.
  • Light for the camera. A lamp turns on while a printer is printing.

Google Home and Alexa speakers work too, through Home Assistant.

The events Layers3D sends

EventWhen
print.startedA printer starts a print
print.completedA print finishes
print.failedA print fails on its own
print.stoppedSomeone stops a print
printer.errorA new printer alert
plate.clear_neededA queue print is done and the bed needs clearing
printer.queue_pausedThe print queue puts a hold on a printer
filament.lowA spool drops below your low mark

Each one carries printer (the name you gave it in Layers3D), job, order_number, material, vent (true for ABS, ASA, PC, nylon and other fume-heavy materials), minutes_left on a start, progress and error on a failure, and a link back to Layers3D.

Step 1: a relay automation in Home Assistant

This one automation receives everything from Layers3D and passes it on as a Home Assistant event called layers3d_printer. Every other automation listens for that event, so you set up the address once.

In Home Assistant go to Settings › Automations & scenes › Create automation › Create new automation, open the ⋮ menu, choose Edit in YAML and paste this. Change the webhook_id to something long and random: it works like a password.

alias: Layers3D relay
triggers:
  - trigger: webhook
    webhook_id: layers3d-change-me-to-something-long-and-random
    allowed_methods: [POST]
    local_only: false
actions:
  - event: layers3d_printer
    event_data:
      event: "{{ trigger.json.event }}"
      printer: "{{ trigger.json.data.printer }}"
      job: "{{ trigger.json.data.job }}"
      order_number: "{{ trigger.json.data.order_number }}"
      material: "{{ trigger.json.data.material }}"
      vent: "{{ trigger.json.data.vent }}"
      minutes_left: "{{ trigger.json.data.minutes_left }}"
      progress: "{{ trigger.json.data.progress }}"
      error: "{{ trigger.json.data.error }}"
      link: "{{ trigger.json.data.link }}"
mode: queued

Step 2: get the address

Layers3D runs on the internet, so Home Assistant has to be reachable from the internet.

  • With Home Assistant Cloud: go to Settings › Home Assistant Cloud, find Webhooks, and turn on the one for "Layers3D relay". Copy the https://hooks.nabu.casa/… address it shows.
  • Without it: the address is https://your-home-assistant-address/api/webhook/ followed by your webhook_id. An address like 192.168.1.20 only works inside your building, so it won't work here.

Step 3: add it in Layers3D

In Layers3D go to Settings › Data › Send events out › Add a webhook. Paste the address, leave Send as on Detect from the address, tick the events under Printers, and press Add webhook. Press Send test on the new row: Home Assistant's automation trace should show a run.

Ready automations

Paste each one the same way as step 1. Change the printer name and the entity_ids to yours.

Air filter for ABS and ASA

alias: H2D-1 air filter for ABS/ASA
mode: restart
triggers:
  - trigger: event
    event_type: layers3d_printer
    event_data: { event: print.started, printer: H2D-1 }
    id: start
  - trigger: event
    event_type: layers3d_printer
    event_data: { event: print.completed, printer: H2D-1 }
  - trigger: event
    event_type: layers3d_printer
    event_data: { event: print.failed, printer: H2D-1 }
  - trigger: event
    event_type: layers3d_printer
    event_data: { event: print.stopped, printer: H2D-1 }
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: start
          - condition: template
            value_template: "{{ trigger.event.data.vent | bool }}"
        sequence:
          - action: switch.turn_on
            target: { entity_id: switch.h2d_1_air_filter }
      - conditions:
          - condition: trigger
            id: start
        sequence:
          - action: switch.turn_off
            target: { entity_id: switch.h2d_1_air_filter }
    default:
      - delay: "00:15:00"
      - action: switch.turn_off
        target: { entity_id: switch.h2d_1_air_filter }

Smart plug off when a print is done

Waits 20 minutes so the nozzle and bed cool, and does nothing if another print starts in that time. Don't use it on a printer that takes print queue jobs: the queue can't send to a printer that's off.

alias: H2S-2 power off after printing
mode: restart
triggers:
  - trigger: event
    event_type: layers3d_printer
    event_data: { event: print.completed, printer: H2S-2 }
    id: done
  - trigger: event
    event_type: layers3d_printer
    event_data: { event: print.started, printer: H2S-2 }
actions:
  - condition: trigger
    id: done
  - delay: "00:20:00"
  - action: switch.turn_off
    target: { entity_id: switch.h2s_2_plug }

Flash the lights and say it when a print fails

alias: Print failed alert
triggers:
  - trigger: event
    event_type: layers3d_printer
    event_data: { event: print.failed }
actions:
  - action: light.turn_on
    target: { entity_id: light.print_room }
    data: { color_name: red, flash: long }
  - action: tts.speak
    target: { entity_id: tts.google_translate_en_com }
    data:
      media_player_entity_id: media_player.shop_speaker
      message: "Print failed on {{ trigger.event.data.printer }}"

Say when a plate needs clearing

alias: Plate to clear
triggers:
  - trigger: event
    event_type: layers3d_printer
    event_data: { event: plate.clear_needed }
actions:
  - action: tts.speak
    target: { entity_id: tts.google_translate_en_com }
    data:
      media_player_entity_id: media_player.shop_speaker
      message: "Clear the plate on {{ trigger.event.data.printer }}"

Camera light while printing

alias: X2D-1 camera light
mode: restart
triggers:
  - trigger: event
    event_type: layers3d_printer
    event_data: { event: print.started, printer: X2D-1 }
    id: start
  - trigger: event
    event_type: layers3d_printer
    event_data: { event: print.completed, printer: X2D-1 }
  - trigger: event
    event_type: layers3d_printer
    event_data: { event: print.failed, printer: X2D-1 }
  - trigger: event
    event_type: layers3d_printer
    event_data: { event: print.stopped, printer: X2D-1 }
actions:
  - if:
      - condition: trigger
        id: start
    then:
      - action: light.turn_on
        target: { entity_id: light.x2d_1_lamp }
    else:
      - action: light.turn_off
        target: { entity_id: light.x2d_1_lamp }

What Home Assistant can't do

It can't start a print. Starting stays in Layers3D, where the plate checks are, so a plate that wasn't cleared never gets a new print on top of it.

Questions

Quick answers

Does it work with printers other than Bambu Lab?

Start, done, failed and plate events come from what the Layers3D shop agent sees, so they follow the printers it watches. The material and vent fields are filled from the queue job, or from the AMS on a Bambu printer.

Is the address safe to share?

Treat it like a password. Anyone with it can trigger your relay automation, so keep the webhook_id long and random, and change it if it leaks.

What happens if Home Assistant is offline?

Layers3D tries again after 30 seconds and after 5 minutes. After 20 failures in a row it pauses that webhook, and you can resume it under Send events out.

Run the farm, not the light switches.

Layers3D runs quotes, orders and the print queue, and tells your shop when to act. Founding Shops get Professional at CA$119.20 a month for their first year.

Become a Founding Shop