greghesp / ha-bambulab

A Home Assistant Integration for Bambu Lab Printers
698 stars 59 forks source link

[Bug] Integration not working #447

Closed elax46 closed 5 months ago

elax46 commented 5 months ago

Describe the bug

After the latest updates, the integration suddenly started to stop working. Also if I try to reload I get the following error: Screenshot 2024-01-21 164419 Screenshot 2024-01-21 164334

To Reproduce

There is no way to reproduce the problem it just doesn't work. The strange thing is that with the a1 mini everything works

Expected Behaviour

May the integration work as before

What device are you using?

P1S

Diagnostic Output

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2024.1.5",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.11.6",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Rome",
    "os_name": "Linux",
    "os_version": "6.1.71-haos",
    "supervisor": "2023.12.1",
    "host_os": "Home Assistant OS 11.4",
    "docker_version": "24.0.7",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "bambu_lab": {
      "version": "2.0.13",
      "requirements": []
    },
    "fontawesome": {
      "version": "2.2.1",
      "requirements": []
    },
    "hacs": {
      "version": "1.33.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "localtuya": {
      "version": "5.2.1",
      "requirements": []
    },
    "aarlo": {
      "version": "0.7.4.2",
      "requirements": [
        "unidecode",
        "cloudscraper>=1.2.71",
        "paho-mqtt"
      ]
    },
    "frigate": {
      "version": "4.0.1",
      "requirements": [
        "pytz==2022.7"
      ]
    },
    "smartir": {
      "version": "1.17.9",
      "requirements": [
        "aiofiles>=0.6.0"
      ]
    },
    "alexa_media": {
      "version": "4.9.0",
      "requirements": [
        "alexapy==1.27.10",
        "packaging>=20.3",
        "wrapt>=1.14.0"
      ]
    },
    "formulaone_api": {
      "version": "0.1.11",
      "requirements": [
        "requests>=2.20"
      ]
    },
    "meross_cloud": {
      "version": "1.2.10",
      "requirements": [
        "meross_iot==0.4.6.0rc2"
      ]
    },
    "pun_sensor": {
      "version": "0.5.0",
      "requirements": [
        "holidays",
        "bs4"
      ]
    }
  },
  "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.13",
    "is_built_in": false
  },
  "data": {
    "config_entry": {
      "entry_id": "10e4f3fd8dca813b594c9ec9280dfc4f",
      "version": 2,
      "minor_version": 1,
      "domain": "bambu_lab",
      "title": "**REDACTED**",
      "data": {
        "device_type": "P1S",
        "serial": "**REDACTED**"
      },
      "options": {
        "region": "Europe",
        "email": "**REDACTED**",
        "username": "**REDACTED**",
        "name": "P1S-Elax46",
        "host": "**REDACTED**",
        "local_mqtt": true,
        "auth_token": "**REDACTED**",
        "access_code": "**REDACTED**",
        "usage_hours": 6.010555555555555
      },
      "pref_disable_new_entities": false,
      "pref_disable_polling": false,
      "source": "user",
      "unique_id": null,
      "disabled_by": null
    },
    "push_all": null,
    "get_version": null
  }
}

Log Extracts

No response

Other Information

No response

AdrianGarside commented 5 months ago

And there's no error output being flagged by home assistant when it attempts to load the integration? You might need to enable debug logging to help me work out what the problem is.

I think I see what might be causing the reload error although the error text doesn't match directly to existing code. I'll make a fix and post that shortly.

AdrianGarside commented 5 months ago

Hmm, that fix wouldn't hit during reload. image

That code doesn't exist any more - I think I had a bug along those lines in an earlier 2.0.11-alpha release as I was working on adding total usage hours but not in the 2.0.13 build you're running. Can you turn on debug logging and repro the error please and provide the debug logs as that'll give a callstack to the point it's failing.

elax46 commented 5 months ago

The log is too long home-assistant_bambu_lab_2024-01-21T21-56-00.917Z.log

AdrianGarside commented 5 months ago

Was your printer turned off? Looks like, separately from this issue, I need to not spam the log with errors for an expected case like that:

2024-01-21 22:55:40.692 ERROR (Thread-965) [custom_components.bambu_lab.pybambu] A1MINI: A Chamber Image thread outer exception occurred: 2024-01-21 22:55:40.692 ERROR (Thread-965) [custom_components.bambu_lab.pybambu] A1MINI: Exception. Type: <class 'OSError'> Args: [Errno 113] Host is unreachable

elax46 commented 5 months ago

yes sorry you are right home-assistant_bambu_lab_2024-01-21T22-14-36.985Z.log

AdrianGarside commented 5 months ago

That's still seeing your A1 Mini as unreachable via the 192.168.1.75 IP address. And still doesn't have the usage_hours error anywhere in the log.

AdrianGarside commented 5 months ago

Did your DHCP assign a different IP address to the printer?

elax46 commented 5 months ago

That's still seeing your A1 Mini as unreachable via the 192.168.1.75 IP address. And still doesn't have the usage_hours error anywhere in the log.

a1 mini is right now running the card function by the way Screenshot 2024-01-21 231916

AdrianGarside commented 5 months ago

Hmm, I see you're connected via local mqtt which uses the same IP address so I'm not sure why the camera thread is getting a host is unreachable error if the local mqtt connection is working - it should be both succeeding or neither.

AdrianGarside commented 5 months ago

I'll push a fix shortly to avoid that case spamming the log but it's unrelated to the original issue. And surprising in its own right.

elax46 commented 5 months ago

I honestly don't know if the printer's IP has changed because I restarted the ISP router both cameras can't be seen but I also use the mqtt for other services and it works

AdrianGarside commented 5 months ago

Please upgrade to https://github.com/greghesp/ha-bambulab/releases/tag/v2.0.14 to fix the nuisance logging. Maybe something will then stand out in the debug logs.

AdrianGarside commented 5 months ago
  "data": {
    "device_type": "P1S",

Per your logs, you have an A1 Mini - did you set this up before the A1/A1 mini was properly supported as a choice? If so, you'll want to delete and re-add your integration to get into a fully supported state.

AdrianGarside commented 5 months ago

Or do you have both? In which case the logs you've provided don't include anything about the P1S. A reload of the integration instance for the P1S should include references to the P1S, which the ones you provided didn't. The logs only cover interaction with the A1 Mini. Can you grab logs with a reload of the P1S instance of the integration?

elax46 commented 5 months ago

I have both a1 mini and p1s but when I collected the log the p1s looked like it didn't exist at all

elax46 commented 5 months ago

I completely reinstalled the integration now it works

AdrianGarside commented 5 months ago

Great! Closing this issue then as there's nothing more to investigate.