Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Start Time unavailable if HA restarted during print in Lan Mode #972

Open
MustardCat opened this issue Feb 11, 2025 · 1 comment
Open
Labels
bug Something isn't working by design

Comments

@MustardCat
Copy link

Home Assistant Version

2025.2.2

Bambu Lab Integration Version

V2.1.0

Describe the bug

If Home Assistant is restarted during a print, sensor.ZZZ_start_time will become unavailable.

Manually setting the state via Developer Tools will temporarily update it but seconds later it'll revert back to "unavailable"

To Reproduce

  1. Start a print
  2. Check the sensor.ZZZ_start_time entity
  3. Verify entity has a valid start time
  4. While printing, reboot Home Assistant
  5. Check the sensor.ZZZ_start_time entity
  6. Verify entity is now unavailable

Expected Behaviour

Entity will retain start time information upon reboot

What device are you using?

P1S

Diagnostic Output

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2025.2.2",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.13.1",
    "docker": true,
    "arch": "aarch64",
    "timezone": "America/Los_Angeles",
    "os_name": "Linux",
    "os_version": "6.6.62-haos-raspi",
    "supervisor": "2025.02.0",
    "host_os": "Home Assistant OS 14.2",
    "docker_version": "27.2.0",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "smartthinq_sensors": {
      "documentation": "https://github.com/ollo69/ha-smartthinq-sensors",
      "version": "0.41.1",
      "requirements": [
        "pycountry>=23.12.11",
        "xmltodict>=0.13.0",
        "charset_normalizer>=3.2.0"
      ]
    },
    "presence_simulation": {
      "documentation": "https://github.com/slashback100/presence_simulation",
      "version": "4.12",
      "requirements": []
    },
    "hacs": {
      "documentation": "https://hacs.xyz/docs/use/",
      "version": "2.0.5",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "spotcast": {
      "documentation": "https://github.com/fondberg/spotcast",
      "version": "v4.0.0",
      "requirements": [
        "spotipy==2.23.0"
      ]
    },
    "bambu_lab": {
      "documentation": "https://github.com/greghesp/ha-bambulab",
      "version": "2.1.0",
      "requirements": [
        "cloudscraper"
      ]
    },
    "nest_protect": {
      "documentation": "https://github.com/imicknl/ha-nest-protect",
      "version": "0.4.0",
      "requirements": []
    },
    "dyson_local": {
      "documentation": "https://github.com/libdyson-wg/ha-dyson",
      "version": "1.4.2",
      "requirements": []
    },
    "fontawesome": {
      "documentation": "https://github.com/thomasloven/hass-fontawesome",
      "version": "2.2.1",
      "requirements": []
    }
  },
  "integration_manifest": {
    "domain": "bambu_lab",
    "name": "Bambu Lab",
    "codeowners": [
      "greghesp",
      "AdrianGarside"
    ],
    "config_flow": true,
    "dependencies": [
      "device_automation",
      "http",
      "websocket_api",
      "ffmpeg",
      "mqtt",
      "frontend",
      "lovelace"
    ],
    "documentation": "https://github.com/greghesp/ha-bambulab",
    "iot_class": "local_push",
    "issue_tracker": "https://github.com/greghesp/ha-bambulab/issues",
    "requirements": [
      "cloudscraper"
    ],
    "ssdp": [
      {
        "st": "urn:bambulab-com:device:3dprinter:1"
      }
    ],
    "version": "2.1.0",
    "is_built_in": false,
    "overwrites_built_in": false
  },
  "setup_times": {
    "null": {
      "setup": 5.8074016124010086e-05
    },
    "01JK2CJXS30XEQ8CYT57WF20A9": {
      "wait_import_platforms": -2.3626164679881185,
      "config_entry_setup": 2.550796404015273,
      "config_entry_platform_setup": 0.08515040786005557
    }
  },
  "data": {
    "config_entry": {
      "created_at": "2025-02-02T03:52:05.155765+00:00",
      "data": {
        "device_type": "P1S",
        "serial": "**REDACTED**"
      },
      "discovery_keys": {},
      "disabled_by": null,
      "domain": "bambu_lab",
      "entry_id": "01JK2CJXS30XEQ8CYT57WF20A9",
      "minor_version": 1,
      "modified_at": "2025-02-11T04:24:34.354019+00:00",
      "options": {
        "access_code": "**REDACTED**",
        "auth_token": "",
        "email": "",
        "host": "192.168.1.60",
        "local_mqtt": true,
        "name": "",
        "region": "",
        "usage_hours": 54.8,
        "username": ""
      },
      "pref_disable_new_entities": false,
      "pref_disable_polling": false,
      "source": "user",
      "title": "**REDACTED**",
      "unique_id": null,
      "version": 2
    },
    "push_all": {
      "ipcam": {
        "ipcam_dev": "1",
        "ipcam_record": "enable",
        "timelapse": "disable",
        "resolution": "",
        "tutk_server": "disable",
        "mode_bits": 3
      },
      "upload": {
        "status": "idle",
        "progress": 0,
        "message": ""
      },
      "net": {
        "conf": 0,
        "info": [
          {
            "ip": 1006741696,
            "mask": 16777215
          }
        ]
      },
      "nozzle_temper": 220,
      "nozzle_target_temper": 220,
      "bed_temper": 55,
      "bed_target_temper": 55,
      "chamber_temper": 5,
      "mc_print_stage": "2",
      "heatbreak_fan_speed": "15",
      "cooling_fan_speed": "0",
      "big_fan1_speed": "0",
      "big_fan2_speed": "8",
      "mc_percent": 1,
      "mc_remaining_time": 792,
      "ams_status": 768,
      "ams_rfid_status": 2,
      "hw_switch_state": 1,
      "spd_mag": 100,
      "spd_lvl": 2,
      "print_error": 0,
      "lifecycle": "product",
      "wifi_signal": "-47dBm",
      "gcode_state": "RUNNING",
      "gcode_file_prepare_percent": "100",
      "queue_number": 0,
      "queue_total": 0,
      "queue_est": 0,
      "queue_sts": 0,
      "project_id": "241669628",
      "profile_id": "224904973",
      "task_id": "488489869",
      "subtask_id": "488489870",
      "subtask_name": "Bambu Spool Quick Release Desiccant Container",
      "gcode_file": "Bambu Spool Quick Release Desiccant Container.3mf",
      "stg": [
        2,
        14,
        1
      ],
      "stg_cur": 0,
      "print_type": "cloud",
      "home_flag": 7554359,
      "mc_print_line_number": "0",
      "mc_print_sub_stage": 0,
      "sdcard": true,
      "force_upgrade": false,
      "mess_production_state": "active",
      "layer_num": 1,
      "total_layer_num": 406,
      "s_obj": [],
      "filam_bak": [],
      "fan_gear": 9830400,
      "nozzle_diameter": "0.4",
      "nozzle_type": "stainless_steel",
      "cali_version": 0,
      "k": "0.0200",
      "flag3": 8,
      "upgrade_state": {
        "sequence_id": 0,
        "progress": "",
        "status": "IDLE",
        "consistency_request": false,
        "dis_state": 0,
        "err_code": 0,
        "force_upgrade": false,
        "message": "0%, 0B/s",
        "module": "",
        "new_version_state": 2,
        "cur_state_code": 1,
        "idx2": 1476900699,
        "new_ver_list": []
      },
      "hms": [],
      "online": {
        "ahb": false,
        "rfid": false,
        "version": 48727878
      },
      "ams": {
        "ams": [
          {
            "id": "0",
            "humidity": "5",
            "temp": "0.0",
            "tray": [
              {
                "id": "0",
                "remain": -1,
                "k": 0.019999999552965164,
                "n": 1,
                "cali_idx": -1,
                "tag_uid": "7A52A0DC00000100",
                "tray_id_name": "A00-K0",
                "tray_info_idx": "GFA00",
                "tray_type": "PLA",
                "tray_sub_brands": "PLA Basic",
                "tray_color": "000000FF",
                "tray_weight": "1000",
                "tray_diameter": "1.75",
                "tray_temp": "55",
                "tray_time": "8",
                "bed_temp_type": "0",
                "bed_temp": "0",
                "nozzle_temp_max": "230",
                "nozzle_temp_min": "190",
                "xcam_info": "803E803EE803E803CDCC4C3F",
                "tray_uuid": "AF339A8DA3E74781AD31D5D6FD565DCA",
                "ctype": 0,
                "cols": [
                  "000000FF"
                ]
              },
              {
                "id": "1",
                "remain": -1,
                "k": 0.019999999552965164,
                "n": 1,
                "cali_idx": -1,
                "tag_uid": "E4347DD000000100",
                "tray_id_name": "A00-W1",
                "tray_info_idx": "GFA00",
                "tray_type": "PLA",
                "tray_sub_brands": "PLA Basic",
                "tray_color": "FFFFFFFF",
                "tray_weight": "1000",
                "tray_diameter": "1.75",
                "tray_temp": "55",
                "tray_time": "8",
                "bed_temp_type": "0",
                "bed_temp": "0",
                "nozzle_temp_max": "230",
                "nozzle_temp_min": "190",
                "xcam_info": "34218813F401E8030000003F",
                "tray_uuid": "0ED87A0348DC40E88F628C1E79D5F740",
                "ctype": 0,
                "cols": [
                  "FFFFFFFF"
                ]
              },
              {
                "id": "2",
                "remain": -1,
                "k": 0.019999999552965164,
                "n": 1,
                "cali_idx": -1,
                "tag_uid": "246A51D500000100",
                "tray_id_name": "A00-B9",
                "tray_info_idx": "GFA00",
                "tray_type": "PLA",
                "tray_sub_brands": "PLA Basic",
                "tray_color": "0A2989FF",
                "tray_weight": "1000",
                "tray_diameter": "1.75",
                "tray_temp": "55",
                "tray_time": "8",
                "bed_temp_type": "0",
                "bed_temp": "0",
                "nozzle_temp_max": "230",
                "nozzle_temp_min": "190",
                "xcam_info": "34213421E803E8030000403F",
                "tray_uuid": "3D52219128D746FB840677F13B5E208C",
                "ctype": 0,
                "cols": [
                  "0A2989FF"
                ]
              },
              {
                "id": "3",
                "remain": -1,
                "k": 0.019999999552965164,
                "n": 1,
                "cali_idx": -1,
                "tag_uid": "44704DF600000100",
                "tray_id_name": "A00-R0",
                "tray_info_idx": "GFA00",
                "tray_type": "PLA",
                "tray_sub_brands": "PLA Basic",
                "tray_color": "C12E1FFF",
                "tray_weight": "1000",
                "tray_diameter": "1.75",
                "tray_temp": "55",
                "tray_time": "8",
                "bed_temp_type": "0",
                "bed_temp": "0",
                "nozzle_temp_max": "230",
                "nozzle_temp_min": "190",
                "xcam_info": "D007D007E803E8036666663F",
                "tray_uuid": "358164BEF97B44F5B1FBCCC976ED88B0",
                "ctype": 0,
                "cols": [
                  "C12E1FFF"
                ]
              }
            ]
          }
        ],
        "ams_exist_bits": "1",
        "tray_exist_bits": "f",
        "tray_is_bbl_bits": "f",
        "tray_tar": "1",
        "tray_now": "1",
        "tray_pre": "1",
        "tray_read_done_bits": "f",
        "tray_reading_bits": "0",
        "version": 1203,
        "insert_flag": true,
        "power_on_flag": false
      },
      "vt_tray": {
        "id": "254",
        "tag_uid": "0000000000000000",
        "tray_id_name": "",
        "tray_info_idx": "",
        "tray_type": "",
        "tray_sub_brands": "",
        "tray_color": "00000000",
        "tray_weight": "0",
        "tray_diameter": "0.00",
        "tray_temp": "0",
        "tray_time": "0",
        "bed_temp_type": "0",
        "bed_temp": "0",
        "nozzle_temp_max": "0",
        "nozzle_temp_min": "0",
        "xcam_info": "000000000000000000000000",
        "tray_uuid": "00000000000000000000000000000000",
        "remain": 0,
        "k": 0.019999999552965164,
        "n": 1,
        "cali_idx": -1
      },
      "lights_report": [
        {
          "node": "chamber_light",
          "mode": "on"
        }
      ],
      "command": "push_status",
      "msg": 0,
      "sequence_id": "54839"
    },
    "get_version": {
      "command": "get_version",
      "sequence_id": "0",
      "module": [
        {
          "name": "ota",
          "project_name": "C12",
          "sw_ver": "01.07.00.00",
          "hw_ver": "OTA",
          "sn": "**REDACTED**",
          "flag": 3
        },
        {
          "name": "esp32",
          "project_name": "C12",
          "sw_ver": "01.11.32.89",
          "hw_ver": "AP04",
          "sn": "**REDACTED**",
          "flag": 0
        },
        {
          "name": "mc",
          "project_name": "P1",
          "sw_ver": "00.00.29.75",
          "loader_ver": "00.00.00.28",
          "hw_ver": "MC07",
          "sn": "**REDACTED**",
          "flag": 0
        },
        {
          "name": "th",
          "project_name": "P1",
          "sw_ver": "00.00.09.95",
          "loader_ver": "00.00.00.14",
          "hw_ver": "TH09",
          "sn": "**REDACTED**",
          "flag": 0
        },
        {
          "name": "ams/0",
          "project_name": "",
          "sw_ver": "00.00.06.49",
          "loader_ver": "00.00.00.00",
          "ota_ver": "00.00.00.00",
          "hw_ver": "AMS08",
          "sn": "**REDACTED**",
          "flag": 0
        }
      ],
      "result": "success",
      "reason": ""
    }
  }
}

Log Extracts

Other Information

No response

@MustardCat MustardCat added the bug Something isn't working label Feb 11, 2025
@AdrianGarside
Copy link
Collaborator

AdrianGarside commented Feb 11, 2025

Unfortunately, the printer doesn't tell us the print start time. In cloud mode we back fill that with the bambu rest API. Or failing that we record it when the print starts. But if you restart the integration that information is lost. So right now this is by design due to those limitations.

With the new FTP support we might be able to get it from the timestamp of the 3mf file although that probably won't handle reprints from existing files. I can now save extra data into the configuration data for the instance much more easily so I can probably persist the start time into there so as long as the print start for the current print (need to match somehow) it can be restored on integration reboot.

@AdrianGarside AdrianGarside changed the title [Bug] Start Time unavailable if HA restarted during print [Bug] Start Time unavailable if HA restarted during print in Lan Mode Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working by design
Projects
None yet
Development

No branches or pull requests

2 participants