Closed LRomandine closed 2 months ago
Resolves issue #525 and #515
@AdrianGarside I've been running this for a month and so far no issues except the binary sensor not being named with the serial number. I have all error alerts working on HA.
A curious behavior that happened once was the AMS failed to pull back the filament due to the end of the spool and Bambu Handy gave me the correct error. But the mqtt data did not have the expected print_error 0702_8004, it was null. I went and manually pulled the stuck filament out and hit retry on the touchscreen, then the HA alerts fired correctly. This is not an issue with the integration, but Bambu firmware not exposing the error in mqtt until after it was corrected.
For anyone else who finds this PR and wants HA alerts via automation here is what I am using. This ignores notifications for inspecting the first layer and AMS switching filament for same type at runout.
Search and replacements from this code
alias: Notification - 3D Printer - Paused (With Reason)
description: 3D Printer Paused
trigger:
- platform: state
entity_id:
- binary_sensor.x1c_SERIAL_hms_errors
for:
hours: 0
minutes: 0
seconds: 0
attribute: 1-Error
- platform: state
entity_id:
- binary_sensor.x1c_SERIAL_hms_errors
for:
hours: 0
minutes: 0
seconds: 0
attribute: 2-Error
- platform: state
entity_id:
- binary_sensor.x1c_SERIAL_hms_errors
for:
hours: 0
minutes: 0
seconds: 0
attribute: 3-Error
- platform: state
entity_id:
- binary_sensor.x1c_SERIAL_hms_errors
for:
hours: 0
minutes: 0
seconds: 0
attribute: 4-Error
- platform: state
entity_id:
- binary_sensor.bambu_x1c_print_error
for:
hours: 0
minutes: 0
seconds: 0
from: "off"
to: "on"
condition: []
action:
- alias: Test HMS 1-Error
if:
- condition: and
conditions:
- condition: template
value_template: >-
{{ state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'1-Error') != none }}
- condition: template
value_template: >-
{{ 'HMS_0C00_0300_0003_000B' not in
state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'1-Error') }}
- condition: template
value_template: >-
{{ 'filament has run out and automatically switched to the slot
with the same filament' not in
state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'1-Error') }}
then:
- service: notify.cell_phones
metadata: {}
data:
title: 3D Printer
message: >-
Printing Paused due to {{
state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'1-Error') }}
data:
priority: high
importance: high
clickAction: /3d-printer/0
- alias: Test HMS 2-Error
if:
- condition: and
conditions:
- condition: template
value_template: >-
{{ state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'2-Error') != none }}
- condition: template
value_template: >-
{{ 'HMS_0C00_0300_0003_000B' not in
state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'2-Error') }}
- condition: template
value_template: >-
{{ 'filament has run out and automatically switched to the slot
with the same filament' not in
state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'2-Error') }}
then:
- service: notify.cell_phones
metadata: {}
data:
title: 3D Printer
message: >-
Printing Paused due to {{
state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'2-Error') }}
data:
priority: high
importance: high
clickAction: /3d-printer/0
- alias: Test HMS 3-Error
if:
- condition: and
conditions:
- condition: template
value_template: >-
{{ state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'3-Error') != none }}
- condition: template
value_template: >-
{{ 'HMS_0C00_0300_0003_000B' not in
state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'3-Error') }}
- condition: template
value_template: >-
{{ 'filament has run out and automatically switched to the slot
with the same filament' not in
state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'3-Error') }}
then:
- service: notify.cell_phones
metadata: {}
data:
title: 3D Printer
message: >-
Printing Paused due to {{
state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'3-Error') }}
data:
priority: high
importance: high
clickAction: /3d-printer/0
- alias: Test HMS 4-Error
if:
- condition: and
conditions:
- condition: template
value_template: >-
{{ state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'4-Error') != none }}
- condition: template
value_template: >-
{{ 'HMS_0C00_0300_0003_000B' not in
state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'4-Error') }}
- condition: template
value_template: >-
{{ 'filament has run out and automatically switched to the slot
with the same filament' not in
state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'4-Error') }}
then:
- service: notify.cell_phones
metadata: {}
data:
title: 3D Printer
message: >-
Printing Paused due to {{
state_attr('binary_sensor.x1c_SERIAL_hms_errors',
'4-Error') }}
data:
priority: high
importance: high
clickAction: /3d-printer/0
- alias: Test Printer_Error
if:
- condition: and
conditions:
- condition: template
value_template: >-
{{ state_attr('binary_sensor.bambu_x1c_print_error', 'Error') !=
none }}
- condition: template
value_template: >-
{{ '0300_400C' not in
state_attr('binary_sensor.bambu_x1c_print_error', 'Error') }}
then:
- service: notify.cell_phones
metadata: {}
data:
title: 3D Printer
message: >-
Printing Paused due to {{
state_attr('binary_sensor.bambu_x1c_print_error', 'Error') }}
data:
priority: high
importance: high
clickAction: /3d-printer/0
mode: single
Hey @LRomandine cool contribution, I ended up doing something similar with fetching the HMS errors from the API but ended up sticking them in a JSON file for cleanliness instead in https://github.com/greghesp/ha-bambulab/pull/556
Just an FYI I've pulled in all the open pull requests (inc this one) from this repo into the main branch of my fork in case you wanted some updates to play with! https://github.com/t3chguy/ha-bambulab
Keep up the great work
PS
One issue I cannot figure out is the new entity is named binary_sensor.bambu_x1c_print_error instead of what I would expect binary_sensor.x1c_SERIAL_print_error (where SERIAL is the serial number). I cannot figure out why as definitions.py looks correct to me.
I cannot repro this
BTW running your final code for the first time and the entity is correctly named. I suspect HA cached an earlier entity name for you before a fix you made that impacted the entity identity.
One issue I cannot figure out is the new entity is named
binary_sensor.bambu_x1c_print_error
instead of what I would expectbinary_sensor.x1c_SERIAL_print_error
(where SERIAL is the serial number). I cannot figure out why asdefinitions.py
looks correct to me.