greghesp / ha-bambulab

A Home Assistant Integration for Bambu Lab Printers
1k stars 85 forks source link

[Bug] Blueprint States trigger incorrectly #483

Open jrsecor opened 8 months ago

jrsecor commented 8 months ago

Describe the bug

WLED turning Green when it should turn Red

To Reproduce

Cancel Print that is failing Check State See Failed Light is green

Settings in HA/Blueprint here: This image shows that the state is "Failed": image

This image shows that the only instance of failed in the blueprint should set Red: image

This is the printer WLED being Green in this state: image

Of note, if I turn the printer light off and then back on, the WLED integration will always go to the Green state, which indicates there is some base issue with the blueprint and how it gets interpreted. WLED is configured correctly as all colors appear correct when manually setting to RGB values normally.

Expected Behaviour

WLED should be Red

What device are you using?

X1C

Diagnostic Output

"custom_components": {
    "bambu_lab": {
      "version": "2.0.15",
      "requirements": []
    },
    "mail_and_packages": {
      "version": "0.0.0-dev",
      "requirements": [
        "imageio>=2.9.0",
        "python-resize-image>=1.1.19"
      ]
    },
    "govee": {
      "version": "2023.11.1",
      "requirements": [
        "govee-api-laggat==0.2.2",
        "dacite==1.8.0"
      ]
    },
    "waste_collection_schedule": {
      "version": "1.46.0",
      "requirements": [
        "icalendar",
        "recurring_ical_events",
        "icalevents",
        "beautifulsoup4",
        "lxml"
      ]
    },
    "hacs": {
      "version": "1.34.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "dwains_dashboard": {
      "version": "3.6.0",
      "requirements": []
    },
    "fontawesome": {
      "version": "2.2.1",
      "requirements": []
    },
    "adaptive_lighting": {
      "version": "1.20.0",
      "requirements": [
        "ulid-transform"
      ]
    },
    "watchman": {
      "version": "0.5.1",
      "requirements": [
        "prettytable==3.0.0"
      ]
    },
    "formulaone_api": {
      "version": "0.1.11",
      "requirements": [
        "requests>=2.20"
      ]
    }
  },
  "integration_manifest": {
    "domain": "bambu_lab",
    "name": "Bambu Lab",
    "codeowners": [
      "@greghesp",
      "@AdrianGarside"
    ],
    "config_flow": true,
    "dependencies": [
      "device_automation",
      "ffmpeg",
      "mqtt"
    ],
    "documentation": "https://github.com/greghesp/ha-bambulab",
    "iot_class": "local_push",
    "issue_tracker": "https://github.com/greghesp/ha-bambulab/issues",
    "ssdp": [
      {
        "st": "urn:bambulab-com:device:3dprinter:1"
      }
    ],
    "version": "2.0.15",
    "is_built_in": false
  },
  "data": {
    "config_entry": {
      "entry_id": "8c95ea76a78828a28a1b02f3d85b79ad",
      "version": 2,
      "minor_version": 1,
      "domain": "bambu_lab",
      "title": "**REDACTED**",
      "data": {
        "device_type": "X1C",
        "serial": "**REDACTED**"
      },
      "options": {
        "region": "",
        "email": "",
        "username": "",
        "name": "",
        "host": "192.168.1.248",
        "local_mqtt": true,
        "auth_token": "",
        "access_code": "**REDACTED**",
        "usage_hours": 215.42
      },
      "pref_disable_new_entities": false,
      "pref_disable_polling": false,
      "source": "user",
      "unique_id": null,
      "disabled_by": null
    },
    "push_all": {
      "ams": {
        "ams": [
          {
            "humidity": "4",
            "id": "0",
            "temp": "27.5",
            "tray": [
              {
                "bed_temp": "35",
                "bed_temp_type": "1",
                "cali_idx": -1,
                "cols": [
                  "000000FF"
                ],
                "ctype": 0,
                "drying_temp": "55",
                "drying_time": "8",
                "id": "0",
                "nozzle_temp_max": "230",
                "nozzle_temp_min": "190",
                "remain": 0,
                "tag_uid": "5C73CB3E00000100",
                "tray_color": "000000FF",
                "tray_diameter": "1.75",
                "tray_id_name": "A01-K1",
                "tray_info_idx": "GFA01",
                "tray_sub_brands": "PLA Matte",
                "tray_type": "PLA",
                "tray_uuid": "FA64C1E131D246D88865FDAA95D667CC",
                "tray_weight": "1000",
                "xcam_info": "A4388813E803E803CDCC4C3F"
              },
              {
                "bed_temp": "35",
                "bed_temp_type": "1",
                "cali_idx": -1,
                "cols": [
                  "00AE42FF"
                ],
                "ctype": 0,
                "drying_temp": "55",
                "drying_time": "8",
                "id": "1",
                "nozzle_temp_max": "230",
                "nozzle_temp_min": "190",
                "remain": 36,
                "tag_uid": "8DE692F300000100",
                "tray_color": "00AE42FF",
                "tray_diameter": "1.75",
                "tray_id_name": "A00-G6",
                "tray_info_idx": "GFA00",
                "tray_sub_brands": "PLA Basic",
                "tray_type": "PLA",
                "tray_uuid": "235ECB3143C1482F98C07D021D7B8167",
                "tray_weight": "1000",
                "xcam_info": "88138813E803E8039A99193F"
              },
              {
                "bed_temp": "35",
                "bed_temp_type": "1",
                "cali_idx": -1,
                "cols": [
                  "FFFFFFFF"
                ],
                "ctype": 0,
                "drying_temp": "55",
                "drying_time": "8",
                "id": "2",
                "nozzle_temp_max": "230",
                "nozzle_temp_min": "190",
                "remain": 66,
                "tag_uid": "CC6A599500000100",
                "tray_color": "FFFFFFFF",
                "tray_diameter": "1.75",
                "tray_id_name": "A01-W2",
                "tray_info_idx": "GFA01",
                "tray_sub_brands": "PLA Matte",
                "tray_type": "PLA",
                "tray_uuid": "F52F69B948DD4948960E18E67ACC98AC",
                "tray_weight": "1000",
                "xcam_info": "D007D007E803E8030000803F"
              },
              {
                "bed_temp": "35",
                "bed_temp_type": "1",
                "cali_idx": -1,
                "cols": [
                  "000000FF"
                ],
                "ctype": 0,
                "drying_temp": "55",
                "drying_time": "8",
                "id": "3",
                "nozzle_temp_max": "230",
                "nozzle_temp_min": "190",
                "remain": 46,
                "tag_uid": "AEA28E7B00000100",
                "tray_color": "000000FF",
                "tray_diameter": "1.75",
                "tray_id_name": "A01-K1",
                "tray_info_idx": "GFA01",
                "tray_sub_brands": "PLA Matte",
                "tray_type": "PLA",
                "tray_uuid": "B35D01137ED443AD935A252B6E5AA707",
                "tray_weight": "1000",
                "xcam_info": "A4388813E803E803CDCC4C3F"
              }
            ]
          }
        ],
        "ams_exist_bits": "1",
        "insert_flag": true,
        "power_on_flag": true,
        "tray_exist_bits": "f",
        "tray_is_bbl_bits": "f",
        "tray_now": "0",
        "tray_pre": "0",
        "tray_read_done_bits": "f",
        "tray_reading_bits": "0",
        "tray_tar": "0",
        "version": 6249
      },
      "ams_rfid_status": 4,
      "ams_status": 768,
      "aux_part_fan": true,
      "bed_target_temper": 55.0,
      "bed_temper": 55.0,
      "big_fan1_speed": "6",
      "big_fan2_speed": "10",
      "cali_version": 0,
      "chamber_temper": 32.0,
      "command": "push_status",
      "cooling_fan_speed": "15",
      "ctt": 0,
      "fail_reason": "50348044",
      "fan_gear": 11892223,
      "filam_bak": [
        9
      ],
      "force_upgrade": false,
      "gcode_file": "/data/Metadata/plate_7.gcode",
      "gcode_file_prepare_percent": "100",
      "gcode_start_time": "1710820226",
      "gcode_state": "FAILED",
      "heatbreak_fan_speed": "13",
      "hms": [],
      "home_flag": 14796167,
      "hw_switch_state": 1,
      "ipcam": {
        "ipcam_dev": "1",
        "ipcam_record": "enable",
        "mode_bits": 2,
        "resolution": "1080p",
        "rtsp_url": "**REDACTED**",
        "timelapse": "disable",
        "tutk_server": "enable"
      },
      "job_id": "0",
      "layer_num": 0,
      "lifecycle": "product",
      "lights_report": [
        {
          "mode": "on",
          "node": "chamber_light"
        },
        {
          "mode": "flashing",
          "node": "work_light"
        }
      ],
      "maintain": 3,
      "mc_percent": 0,
      "mc_print_error_code": "0",
      "mc_print_stage": "1",
      "mc_print_sub_stage": 0,
      "mc_remaining_time": 475,
      "mess_production_state": "active",
      "net": {
        "conf": 16,
        "info": [
          {
            "ip": 4160858304,
            "mask": 16777215
          },
          {
            "ip": 0,
            "mask": 0
          }
        ]
      },
      "nozzle_diameter": "0.4",
      "nozzle_target_temper": 140.0,
      "nozzle_temper": 174.0,
      "nozzle_type": "hardened_steel",
      "online": {
        "ahb": false,
        "ext": false,
        "version": 7
      },
      "print_error": 0,
      "print_gcode_action": 14,
      "print_real_action": 0,
      "print_type": "local",
      "profile_id": "",
      "project_id": "0",
      "queue_est": 0,
      "queue_number": 0,
      "queue_sts": 0,
      "queue_total": 0,
      "s_obj": [],
      "sdcard": true,
      "sequence_id": "2021",
      "spd_lvl": 2,
      "spd_mag": 100,
      "stg": [
        2,
        14,
        1,
        8
      ],
      "stg_cur": -1,
      "subtask_id": "",
      "subtask_name": "Bambu Lab P1 / X1 / X1C / X1CC Filament Spool Switcher & Winder if you use AMS",
      "task_id": "3801",
      "total_layer_num": 832,
      "upgrade_state": {
        "ahb_new_version_number": "",
        "ams_new_version_number": "",
        "consistency_request": false,
        "dis_state": 0,
        "err_code": 0,
        "ext_new_version_number": "",
        "force_upgrade": false,
        "idx": 7,
        "message": "",
        "module": "null",
        "new_version_state": 2,
        "ota_new_version_number": "",
        "progress": "0",
        "sequence_id": 0,
        "sn": "**REDACTED**",
        "status": "IDLE"
      },
      "upload": {
        "file_size": 0,
        "finish_size": 0,
        "message": "Good",
        "oss_url": "",
        "progress": 0,
        "sequence_id": "0903",
        "speed": 0,
        "status": "idle",
        "task_id": "",
        "time_remaining": 0,
        "trouble_id": ""
      },
      "vt_tray": {
        "bed_temp": "0",
        "bed_temp_type": "0",
        "cali_idx": -1,
        "cols": [
          "00000000"
        ],
        "ctype": 0,
        "drying_temp": "0",
        "drying_time": "0",
        "id": "254",
        "nozzle_temp_max": "0",
        "nozzle_temp_min": "0",
        "remain": 0,
        "tag_uid": "0000000000000000",
        "tray_color": "00000000",
        "tray_diameter": "0.00",
        "tray_id_name": "",
        "tray_info_idx": "",
        "tray_sub_brands": "",
        "tray_type": "",
        "tray_uuid": "00000000000000000000000000000000",
        "tray_weight": "0",
        "xcam_info": "000000000000000000000000"
      },
      "wifi_signal": "-57dBm",
      "xcam": {
        "allow_skip_parts": false,
        "buildplate_marker_detector": true,
        "first_layer_inspector": true,
        "halt_print_sensitivity": "medium",
        "print_halt": true,
        "printing_monitor": true,
        "spaghetti_detector": true
      },
      "xcam_status": "0"
    },
    "get_version": {
      "command": "get_version",
      "module": [
        {
          "hw_ver": "",
          "name": "ota",
          "sn": "",
          "sw_ver": "01.07.02.00"
        },
        {
          "hw_ver": "AP05",
          "name": "rv1126",
          "sn": "**REDACTED**",
          "sw_ver": "00.00.28.55"
        },
        {
          "hw_ver": "TH09",
          "name": "th",
          "sn": "**REDACTED**",
          "sw_ver": "00.00.07.12"
        },
        {
          "hw_ver": "MC07",
          "name": "mc",
          "sn": "**REDACTED**",
          "sw_ver": "00.00.22.37/00.00.22.37"
        },
        {
          "hw_ver": "",
          "name": "xm",
          "sn": "",
          "sw_ver": "00.01.02.02"
        },
        {
          "hw_ver": "AMS08",
          "name": "ams/0",
          "sn": "**REDACTED**",
          "sw_ver": "00.00.06.40"
        }
      ],
      "sequence_id": "0"
    }
  }
}

Log Extracts

None

Other Information

None

AdrianGarside commented 7 months ago

I've not been involved with the wled blueprint but I don't see failed being set to red in the current or any historical version of the blueprint: image

And failed is not one of the potential (Bambu doesn't actually use over half of these) values that print stage can have: CURRENT_STAGE_IDS = { "default": "unknown", 0: "printing", 1: "auto_bed_leveling", 2: "heatbed_preheating", 3: "sweeping_xy_mech_mode", 4: "changing_filament", 5: "m400_pause", 6: "paused_filament_runout", 7: "heating_hotend", 8: "calibrating_extrusion", 9: "scanning_bed_surface", 10: "inspecting_first_layer", 11: "identifying_build_plate_type", 12: "calibrating_micro_lidar", # DUPLICATED? 13: "homing_toolhead", 14: "cleaning_nozzle_tip", 15: "checking_extruder_temperature", 16: "paused_user", 17: "paused_front_cover_falling", 18: "calibrating_micro_lidar", # DUPLICATED? 19: "calibrating_extrusion_flow", 20: "paused_nozzle_temperature_malfunction", 21: "paused_heat_bed_temperature_malfunction", 22: "filament_unloading", 23: "paused_skipped_step", 24: "filament_loading", 25: "calibrating_motor_noise", 26: "paused_ams_lost", 27: "paused_low_fan_speed_heat_break", 28: "paused_chamber_temperature_control_error", 29: "cooling_chamber", 30: "paused_user_gcode", 31: "motor_noise_showoff", 32: "paused_nozzle_filament_covered_detected", 33: "paused_cutter_error", 34: "paused_first_layer_error", 35: "paused_nozzle_clog",

X1 returns -1 for idle

-1: "idle",  # DUPLICATED
# P1 returns 255 for idle
255: "idle", # DUPLICATED

}

AdrianGarside commented 7 months ago

print_status is where 'failed' gets set. Which has these options (some of which also never get used by Bambu): GCODE_STATE_OPTIONS = [ "failed", "finish", "idle", "init", "offline", "pause", "prepare", "running", "slicing", "unknown" ]

AdrianGarside commented 7 months ago

Honestly, I'm looking at the blueprint and wondering how it works at all since it doesn't have the correct entity names listed. Are you using it unmodified?

jrsecor commented 7 months ago

It has been working, yes. The only modification I made was changing a couple of the "effect" variables to what I preferred. The only part that doesn't work is any type of failure notifying correctly. Every other state seems to act correctly (orange for heating, blue for preparing, etc)

github-actions[bot] commented 5 months ago

Stale issue message