Skip to content

Instantly share code, notes, and snippets.

@ephdtrg
Last active November 18, 2024 00:27
Show Gist options
  • Save ephdtrg/89ae6cf948494f1a9fecb37bfd7b1844 to your computer and use it in GitHub Desktop.
Save ephdtrg/89ae6cf948494f1a9fecb37bfd7b1844 to your computer and use it in GitHub Desktop.
Bambu LED controller
blueprint:
name: Bambu Lab LED Controller
description: Control one or more LED lights with Bambu 3d printer
domain: automation
input:
printer_status:
name: Print Status of your Bambu Lab printer
description: Select the print status entity.
selector:
entity:
filter:
- domain:
- sensor
integration: bambu_lab
multiple: false
printer_stage:
name: Current Stage of your Bambu Lab Printer
description: Select the printer current stage entity.
selector:
entity:
filter:
- domain:
- sensor
integration: bambu_lab
multiple: false
chamber_light:
name: Chamber Light of your Bambu Lab Printer
description: Select the printer chamber light entity.
selector:
entity:
filter:
- domain:
- light
integration: bambu_lab
multiple: false
current_layer:
name: Current Layer of your Bambu Lab Printer
description: Select the printer current layer entity.
selector:
entity:
filter:
- domain:
- sensor
integration: bambu_lab
multiple: false
target_nozzle_temp:
name: Target Nozzle Temperature of your Bambu Lab Printer
description: Select the printer target nozzle temperature layer entity.
selector:
entity:
filter:
- domain:
- sensor
integration: bambu_lab
multiple: false
hms_errors:
name: HMS Errors entity of your Bambu Lab Printer
description: Select the printer HMS Errors entity.
selector:
entity:
filter:
- domain:
- binary_sensor
integration: bambu_lab
multiple: false
led_lights:
name: LED Light devices
description: Select the LED light devices you wish to control.
selector:
entity:
filter:
- domain:
- light
multiple: true
brightness_white:
name: Main brightness
description: Value of brightness (from 1 to 100) for solid white color
selector:
number:
min: 0.0
max: 100.0
step: 1.0
mode: slider
brightness_signal:
name: Signal brightness
description: Value of brightness (from 1 to 255) for signal colors (red, green,
yellow, blue)
selector:
number:
min: 0.0
max: 255.0
step: 1.0
mode: slider
source_url: https://gist.github.com/ephdtrg/89ae6cf948494f1a9fecb37bfd7b1844
alias: Bambu Lab LED Controller
description: ''
trigger:
- platform: state
entity_id:
- !input chamber_light
- !input printer_status
- !input printer_stage
- !input current_layer
- !input target_nozzle_temp
alias: When printer stage,status or chamber light state changes
variables:
hms_error_code: ""
- platform: state
entity_id:
- !input hms_errors
alias: When printer stage,status or chamber light state changes
variables:
hms_error_code: "{{ trigger.event.data.hms_code }}"
condition: []
action:
- if:
- condition: state
state: 'on'
alias: chamber light is on
entity_id: !input chamber_light
- condition: not
conditions:
- condition: state
entity_id: !input printer_stage
state: scanning_bed_surface
alias: Scanning Bed Surface
- condition: state
entity_id: !input printer_stage
state: cleaning_nozzle_tip
alias: Cleaning Nozzle Tip
- condition: state
entity_id: !input printer_stage
state: calibrating_extrusion
alias: Calibrating Extrusion
- condition: state
entity_id: !input printer_stage
state: heatbed_preheating
alias: Heatbed Preheating
- condition: state
entity_id: !input printer_status
state: offline
alias: Printer is off
alias: And Lidar is NOT on
- condition: not
conditions:
- condition: numeric_state
entity_id: !input current_layer
above: 1
below: 3
- condition: numeric_state
entity_id: !input target_nozzle_temp
above: 139
below: 141
- condition: not
conditions:
- condition: template
value_template: >-
{{ trigger['hms_error_code'] == 'HMS_0C00_0300_0003_000B'}}
then:
- service: light.turn_on
data:
rgb_color:
- 255
- 237
- 168
brightness_pct: !input brightness_white
effect: Solid
alias: Turn LED light on white
target:
entity_id: !input led_lights
- choose:
- conditions:
- condition: or
conditions:
- condition: state
entity_id: !input printer_stage
state: Paused due to filament runout
- condition: state
entity_id: !input printer_stage
state: Pause of front cover falling
- condition: state
entity_id: !input printer_stage
state: Paused due to nozzle temperature malfunction
- condition: state
entity_id: !input printer_stage
state: Paused due to heat bed temperature malfunction
sequence:
- service: light.turn_on
data:
rgb_color:
- 255
- 0
- 0
brightness: !input brightness_signal
target:
entity_id: !input led_lights
alias: Turn on Wled to red
alias: Do we need to set color to red?
- choose:
- conditions:
- condition: or
conditions:
- condition: state
entity_id: !input printer_stage
state: Idle
- condition: state
entity_id: !input printer_status
state: Finish
- condition: state
entity_id: !input printer_status
state: Offline
sequence:
- service: light.turn_on
data:
rgb_color:
- 0
- 255
- 0
brightness: !input brightness_signal
effect: Solid
target:
entity_id: !input led_lights
alias: Turn on Wled to green
alias: Do we need to set color to green?
- choose:
- conditions:
- condition: or
conditions:
- condition: state
entity_id: !input printer_stage
state: Auto Bed Leveling
sequence:
- service: light.turn_on
data:
rgb_color:
- 0
- 0
- 255
brightness: !input brightness_signal
target:
entity_id: !input led_lights
alias: Turn on Wled to blue
alias: Do we need to set color to blue?
# - choose:
# - conditions:
# - condition: or
# conditions:
# - condition: state
# entity_id: !input printer_stage
# state: heatbed_preheating
# - condition: state
# entity_id: !input printer_stage
# state: heating_hotend
# sequence:
# - service: light.turn_on
# data:
# rgb_color:
# - 255
# - 169
# - 0
# brightness: !input brightness_signal
# target:
# entity_id: !input led_lights
# alias: Turn on Wled to yellow
# alias: Do we need to set color to yellow?
else:
- service: light.turn_off
data: {}
target:
entity_id: !input led_lights
alias: Turn LED light off
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment