Guides / 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.
Google Home and Alexa speakers work too, through Home Assistant.
| Event | When |
|---|---|
print.started | A printer starts a print |
print.completed | A print finishes |
print.failed | A print fails on its own |
print.stopped | Someone stops a print |
printer.error | A new printer alert |
plate.clear_needed | A queue print is done and the bed needs clearing |
printer.queue_paused | The print queue puts a hold on a printer |
filament.low | A 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.
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
Layers3D runs on the internet, so Home Assistant has to be reachable from the internet.
https://hooks.nabu.casa/… address it shows.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.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.
Paste each one the same way as step 1. Change the printer name and the entity_ids to yours.
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 }
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 }
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 }}"
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 }}"
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 }
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
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.
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.
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.
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