greghesp / ha-bambulab

A Home Assistant Integration for Bambu Lab Printers
1.05k stars 94 forks source link

[Bug] P1S camera feeding missing (please do not put X1 camera feedback here - see #221) #521

Closed cayalag closed 1 month ago

cayalag commented 7 months ago

Describe the bug

Hello !

I have added my second P1S and everything seems to be correct. However, I am missing the camera feed.

To Reproduce

Captura de pantalla 2024-05-01 a las 14 33 36

Expected Behaviour

I was expecting to find it under Sensors, same as the other printer.

What device are you using?

P1S

Diagnostic Output

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2024.4.3",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.12.2",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Madrid",
    "os_name": "Linux",
    "os_version": "6.6.25-haos",
    "supervisor": "2024.04.4",
    "host_os": "Home Assistant OS 12.2",
    "docker_version": "25.0.5",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "bambu_lab": {
      "version": "2.0.18",
      "requirements": []
    },
    "frigate": {
      "version": "4.0.0",
      "requirements": [
        "pytz==2022.7"
      ]
    },
    "dahua_vto": {
      "version": "1.0.7",
      "requirements": []
    },
    "dahua": {
      "version": "0.5.0",
      "requirements": []
    },
    "midea_dehumidifier": {
      "version": "1.0.3",
      "requirements": [
        "midea-inventor-lib==1.0.4"
      ]
    },
    "fusion_solar": {
      "version": "3.0.2",
      "requirements": []
    },
    "huawei_solar": {
      "version": "1.2.4",
      "requirements": [
        "huawei-solar==2.2.4"
      ]
    },
    "hacs": {
      "version": "1.34.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    }
  },
  "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.18",
    "is_built_in": false
  },
  "data": {
    "config_entry": {
      "entry_id": "57025516499b9b35642d620f801e222f",
      "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 #2 Carlos",
        "host": "",
        "local_mqtt": false,
        "auth_token": "**REDACTED**",
        "access_code": "**REDACTED**",
        "usage_hours": 79.94
      },
      "pref_disable_new_entities": false,
      "pref_disable_polling": false,
      "source": "user",
      "unique_id": null,
      "disabled_by": null
    },
    "push_all": {
      "ipcam": {
        "ipcam_dev": "1",
        "ipcam_record": "enable",
        "timelapse": "disable",
        "resolution": "",
        "tutk_server": "enable",
        "mode_bits": 3
      },
      "upload": {
        "status": "idle",
        "progress": 0,
        "message": ""
      },
      "nozzle_temper": 219.9375,
      "nozzle_target_temper": 220,
      "bed_temper": 54.96875,
      "bed_target_temper": 55,
      "chamber_temper": 5,
      "mc_print_stage": "2",
      "heatbreak_fan_speed": "15",
      "cooling_fan_speed": "15",
      "big_fan1_speed": "7",
      "big_fan2_speed": "0",
      "mc_percent": 76,
      "mc_remaining_time": 28,
      "ams_status": 1280,
      "ams_rfid_status": 2,
      "hw_switch_state": 1,
      "spd_mag": 100,
      "spd_lvl": 2,
      "print_error": 0,
      "lifecycle": "product",
      "wifi_signal": "-67dBm",
      "gcode_state": "RUNNING",
      "gcode_file_prepare_percent": "100",
      "queue_number": 0,
      "queue_total": 0,
      "queue_est": 0,
      "queue_sts": 0,
      "project_id": "0",
      "profile_id": "0",
      "task_id": "0",
      "subtask_id": "0",
      "subtask_name": "Belt_plate_1.3mf",
      "gcode_file": "Belt_plate_1.3mf",
      "stg": [
        2,
        14,
        1
      ],
      "stg_cur": 0,
      "print_type": "local",
      "home_flag": 41043263,
      "mc_print_line_number": "139637",
      "mc_print_sub_stage": 0,
      "sdcard": true,
      "force_upgrade": false,
      "mess_production_state": "active",
      "layer_num": 74,
      "total_layer_num": 100,
      "s_obj": [],
      "filam_bak": [],
      "fan_gear": 26367,
      "nozzle_diameter": "0.4",
      "nozzle_type": "stainless_steel",
      "cali_version": 0,
      "upgrade_state": {
        "sequence_id": 0,
        "progress": "",
        "status": "",
        "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,
        "new_ver_list": []
      },
      "hms": [],
      "online": {
        "ahb": false,
        "rfid": false,
        "version": 220129082
      },
      "ams": {
        "ams": [],
        "ams_exist_bits": "0",
        "tray_exist_bits": "0",
        "tray_is_bbl_bits": "0",
        "tray_tar": "254",
        "tray_now": "254",
        "tray_pre": "254",
        "tray_read_done_bits": "0",
        "tray_reading_bits": "0",
        "version": 9,
        "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": "4859"
    },
    "get_version": {
      "command": "get_version",
      "sequence_id": "0",
      "module": [
        {
          "name": "ota",
          "project_name": "C12",
          "sw_ver": "01.05.04.00",
          "hw_ver": "OTA",
          "sn": "**REDACTED**",
          "flag": 2
        },
        {
          "name": "esp32",
          "project_name": "C12",
          "sw_ver": "01.08.27.21",
          "hw_ver": "AP04",
          "sn": "**REDACTED**",
          "flag": 0
        },
        {
          "name": "mc",
          "project_name": "P1",
          "sw_ver": "00.00.26.60",
          "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
        }
      ],
      "result": "success",
      "reason": ""
    }
  }
}

Log Extracts

No response

Other Information

No response

AdrianGarside commented 7 months ago

Can you try updating to v2.0.21 and seeing if this still reproes. If it does, I'll need debug logs to see if that shed light on how the camera sensor has gone AWOL.

cayalag commented 7 months ago

I tried but, but no luck. Let me know what you need and I’ll get the logs after work. Thanks !!

El 2 may 2024, a las 3:10, AdrianGarside @.***> escribió:



Can you try updating to v2.0.21 and seeing if this still reproes. If it does, I'll need debug logs to see if that shed light on how the camera sensor has gone AWOL.

— Reply to this email directly, view it on GitHubhttps://github.com/greghesp/ha-bambulab/issues/521#issuecomment-2089366227, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A53E2FBJOJCHQNRQSDWAYF3ZAGHAXAVCNFSM6AAAAABHB44YKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBZGM3DMMRSG4. You are receiving this because you authored the thread.Message ID: @.***>

AdrianGarside commented 7 months ago

On the P1S the image snapshot camera is under controls not sensors. I haven’t found a force home assistant to put it under sensors like the X1 video feed camera.

AdrianGarside commented 7 months ago

Actually… it’s seemingly not consistent. On my production HA instance camera and cover image are both under controls. But your cover image is under sensors. And on my test instance I think they’re both under sensors too (away from my PC so will have to confirm this).

AdrianGarside commented 7 months ago

The readme.md file in the root of the source has instructions on how to get debug logs.

cayalag commented 7 months ago

Hey Adrian.

I thing I got the debug log. Let me know if that's not what you need.

Regarding where the camera should appear... the other P1S definitely shows the camera feed under sensors:

Captura de pantalla 2024-05-02 a las 16 20 47

Thanks again ! Carlos

home-assistant_2024-05-02T14-19-38.856Z.log

AdrianGarside commented 6 months ago

2024-05-01 18:14:46.048 ERROR (P1S-Chamber-112) [custom_components.bambu_lab.pybambu] Socket error: [SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1000)

Possible that's involved - not an error I've ever seen. One thing that's odd about your log - you said you have two printers but I'm only seeing log output for one?

Looks like I'll need to tweak the logging here since I'm not seeing log output I expect.

cayalag commented 6 months ago

Yeah, both printers with the same firmware. The only difference is one of them has 2 AMS units connected to it, but I guess that's not key to the problem

Captura de pantalla 2024-05-08 a las 9 20 15

Let me know if there is anything I can test on my side.

Thanks !

nocomment-bln commented 6 months ago

my camera stream is also not working

honzis1364 commented 6 months ago

Heyo everyone, has anyone managed to get P1S camera into HomeBridge? I dont have a problem to watch the camera in Assistant (I also have it under Sensors). But when I try to import everything via HomeBridge, camera won't import.

marcinbauer85 commented 6 months ago

@honzis1364 This is because this integration generates an image.printer_camera entity which is from the image domain, and homekit doesn't allow for image domain publishing. I've just created a ticket for this: https://github.com/greghesp/ha-bambulab/issues/531

xinux87 commented 6 months ago

I hade the same problem, the camera feed desapeared but after disabling the integration, restarted HA, and activating it again, it started working...

The camera started to work again.

muusonos commented 6 months ago

I have had the same problem for two days. The image.camerafeed has disappeared. @xinux87: It's not working for me.

briandye commented 6 months ago

It was working for a bit on my X1C but is no longer working, feels like it stopped after that most recent firmware update? I tried disabling, and re-activating, reinstalling add-in and switching from cloud mode to local ip address mode, none have helped.

briandye commented 6 months ago

It was working for a bit on my X1C but is no longer working, feels like it stopped after that most recent firmware update? I tried disabling, and re-activating, reinstalling add-in and switching from cloud mode to local ip address mode, none have helped.

Power cycling the Bambu printer seems to have resolved this

github-actions[bot] commented 3 months ago

Stale issue message

nzrutman commented 2 months ago

+1, No camera feed for my A1 Mini anywhere, ever.

mayermatt commented 2 months ago

I also never see a camera image with this integration for my X1C. The camera.x1c_<serialNumber> entity from this integration appears in Home Assistant as Unavailable.

It worked previously, but it's been at least a month or two since I last recall seeing it work.

Integration version: v2.0.22 Bambu firmware version: 01.08.02.00

I have power-cycled my printer, uninstalled and reinstalled the integration, and configured it to talk to my printer over LAN. The camera entity still appears, but as unavailable, after the this process.

nzrutman commented 2 months ago

+1, No camera feed for my A1 Mini anywhere, ever.

A1 Mini AP07 missing camera is resolved with https://github.com/greghesp/ha-bambulab/pull/589 This will not help the X1C problems.

nramo013 commented 2 months ago

I am in the latest version of the repo and am also having issues seeing either of my x1 cameras

AdrianGarside commented 1 month ago

I am in the latest version of the repo and am also having issues seeing either of my x1 cameras

X1 rtsp support is just very buggy. There's a discussion post on how you can mitigate it using a go2rtc to proxy a single connection and keep it alive.

AdrianGarside commented 1 month ago

@cayalag are you still seeing this?

cayalag commented 1 month ago

@cayalag are you still seeing this?

Hey Adrian ! Yeah still around. I keep having access to one of the P1S video feed but the other one no luck

secco04 commented 1 month ago

Hi i see this issue too... powercycling the p1s helps for a it... Additional question: can i somehow Integrate the camera Feed to octoprint.... I got it working temporarily but the ha access token renews quickly and all i found was not so helpful or to complicated...

nramo013 commented 1 month ago

After updating both HA and BambuLab and rebooting both printers, the cameras show and consistently for 3 days now on my X1Cs

AdrianGarside commented 1 month ago

@cayalag can you provide debug logs of the non-working case please.

cayalag commented 1 month ago

@cayalag can you provide debug logs of the non-working case please.

I have just updated to the last version of the integration and lost the camera feed on the printer that used to work !

Captura de pantalla 2024-10-26 a las 20 13 40

These are the diagnostic files on both printers (first the one that never showed the camera, second the one that just lost the feed)

First:

config_entry-bambu_lab-57025516499b9b35642d620f801e222f-2.json

Second:

config_entry-bambu_lab-d3761cb7963f4d01d59058b9a2e23f0b.json

nramo013 commented 1 month ago

Same. For some reason the cameras on the printers in the middle of a job show no feed, but the one that is not shows a good feed. I will not know if it's only applicable to the non printing devices, until that job finishes tomorrow

AdrianGarside commented 1 month ago

@cayalag can you provide debug logs of the non-working case please.

I have just updated to the last version of the integration and lost the camera feed on the printer that used to work !

Captura de pantalla 2024-10-26 a las 20 13 40

These are the diagnostic files on both printers (first the one that never showed the camera, second the one that just lost the feed)

First:

config_entry-bambu_lab-57025516499b9b35642d620f801e222f-2.json

Second:

config_entry-bambu_lab-d3761cb7963f4d01d59058b9a2e23f0b.json

The newer build replaced the image 'camera' with a camera camera. Which means the entity name changes. You'll need to delete that and put the new camera entity into your dashboards. Please check to see if one or both printers has that present and working.

secco04 commented 1 month ago

Hi AdrianGarside i replaced the image entity with the camera entity on the dashboard after reconfigure the integration but still i got no image here is my debug log (hope this is the one you need ... )

home-assistant_bambu_lab_2024-10-27T03-11-58.787Z.log home-assistant_2024-10-27T03-14-04.555Z.log

AdrianGarside commented 1 month ago

Can you view the camera successfully from the device itself? There are gotchas trying to get a camera to be live in a dashboard so please confirm it's not working when viewed directly from the device: image

Looks like you were adding/removing the printer repeatedly in the logs? Once added I see the chamber image thread started without any errors so as best I can tell the integration should be receiving the images at that point.

The second log file does have a timeout error for the chamber image connection seemingly out of the blue but also no log evens for a bit over a minute prior to that - did you turn the printer off?

secco04 commented 1 month ago

strange :( i have tried to reconfig the printer for maximal debug logs :D in the Second log the printer was still on but not sure if it was printing at that moment....

In the Device itself the Entitiy is also not showing an image... all i get is the title
Bild_2024-10-27_053238418

from the dev tools i can see that it should be able to accessible via the url - but it gives me an "500: Internal Server Error" ... maybe another hint?

access_token: redacted brand: Bambu Lab entity_picture: >- /api/camera_proxy/camera.p1s_xxxxxxxxxx_camera?token=redacted icon: mdi:camera friendly_name: P1S_xxxxxxxxxx Camera supported_features: 0

secco04 commented 1 month ago

i got it working by refreshing the access code on the printer... still dont know what exactly the problem was... i viewed in the code of the camera.py - since i want to use obico via octoprint and some more plugins i need the stream there... when i want to grab the stream the rtpsps url must be rtsps://bblp:accesscode@192.168.2.119/streaming/live/1 am i right?

btw https://github.com/MrDrache333/webcamd works now too -.- thats my workaroud if the direct stream does not work

cayalag commented 1 month ago

The newer build replaced the image 'camera' with a camera camera. Which means the entity name changes. You'll need to delete that and put the new camera entity into your dashboards. Please check to see if one or both printers has that present and working.

Now none of the printers have an entity that allows me to access the camera, it even disappeared from the Sensors section:

Captura de pantalla 2024-10-27 a las 8 42 23
nramo013 commented 1 month ago

I'm a little newer to this; how do I remove the old camera entity and add the new entity? I go into the printer device and sensor location but it won't let me remove the "camera.old_bambu_entir_camera" and then add a new one. I'm sorry

AdrianGarside commented 1 month ago

@nramo013 The old one was image.[printer]_camera. When you upgrade that remains present but stops working. Clicking it should give you a popup saying that the integration is no longer providing this entity and an option (bottom left IIRC) to delete it.

The new is camera.[printer]_camera.

With an upgrade, both should be showing up in your device page - the image one sometimes showed up in the top 'controls' section inconsistently for some people.

AdrianGarside commented 1 month ago

i got it working by refreshing the access code on the printer... still dont know what exactly the problem was... i viewed in the code of the camera.py - since i want to use obico via octoprint and some more plugins i need the stream there... when i want to grab the stream the rtpsps url must be rtsps://bblp:accesscode@192.168.2.119/streaming/live/1 am i right?

btw https://github.com/MrDrache333/webcamd works now too -.- thats my workaroud if the direct stream does not work

No, the rtsp feed is solely for the X1. It has a completely different way to expose it's camera and you have an P1S. It just has a way of receiving static images every ~2 seconds from the printer and we used to just expose that as an image until just recently where someone found the built-in way to cheaply get HA to expose those images as a true camera.

AdrianGarside commented 1 month ago

@secco04 "i got it working by refreshing the access code on the printer..." - that means it was a permissions issue accessing the printer to get the camera images. But I would have expected to have seen errors for that in your logs. The timeouts are probably related since I've not observed those when I turn off my printers but in your logs one minute after the integration disconnects from the offline printer there was always a timeout error.

cayalag commented 1 month ago

I am now at v2.0.26... deleted both printers, configure them back and none of them has a camera entity.

@AdrianGarside any other suggestion of what I can do at this stage ?

nramo013 commented 1 month ago

My cameras show up as camera._xxx_xxx__camera but they do not stream while I am printing. When they are idle, they will show:

Screenshot 2024-10-27 141047 Screenshot 2024-10-27 141423

AdrianGarside commented 1 month ago

@nramo013 the X1C camera issues are a different problem. See #221.

AdrianGarside commented 1 month ago

@cayalag can you get me a fresh debug log of HA startup with neither of your two printers getting the camera entity? And to double check - you provided the local IP address when adding the printers?

cayalag commented 1 month ago

@cayalag can you get me a fresh debug log of HA startup with neither of your two printers getting the camera entity? And to double check - you provided the local IP address when adding the printers?

Full reset of HA and this is the log. Thanks !

home-assistant_2024-10-27T20-01-58.753Z.log

secco04 commented 1 month ago

@cayalag can you get me a fresh debug log of HA startup with neither of your two printers getting the camera entity? And to double check - you provided the local IP address when adding the printers?

Full reset of HA and this is the log. Thanks !

home-assistant_2024-10-27T20-01-58.753Z.log

^^ Interesting lines in your log file.... FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.10/site-packages/ffmpeg' 2024-10-27 21:00:17.443 WARNING (MainThread) [haffmpeg.tools] Error starting FFmpeg.

Some lines above state that python 3.12 is beeing used

AdrianGarside commented 1 month ago

ffmpeg being bust might explain missing visuals although I think it's unrelated to this integration, but wouldn't explain missing entities.

In the very latest dev release (2.0.27-dev1) I added extra logging to capture the case where we do not have printer IP address and/or access code. The latter gets auto populated during cloud setup of a printer but the local IP address you must enter manually. It is required for camera access. I don't think you provided that during printer setup?

cayalag commented 1 month ago

ffmpeg being bust might explain missing visuals although I think it's unrelated to this integration, but wouldn't explain missing entities.

In the very latest dev release (2.0.27-dev1) I added extra logging to capture the case where we do not have printer IP address and/or access code. The latter gets auto populated during cloud setup of a printer but the local IP address you must enter manually. It is required for camera access. I don't think you provided that during printer setup?

I deleted everything, installed 2.0.27-dev2 and reinstalled the printers. If I add the IP address, it fails to connect to the printer:

Captura de pantalla 2024-10-28 a las 14 14 12

When I don't provide the IP the printer gets recognized (however the one with 2 AMS gets only recognized as printer without AMS... which worked until previous version)

Still no camera for neither of the printers.

Last log attached:

home-assistant_bambu_lab_2024-10-28T13-16-59.258Z.log

AdrianGarside commented 1 month ago

Debug logs weren't enabled but it is expected that you won't get a camera if the printer IP isn't provided. I'd need debug logs to have a chance to know why it failed the test connection at that point. You'll need to turn debug logs on in the configuration.yaml to get them for the initial integration setup. All I see in these logs is that the mqtt connection to the printer is repetitively being denied with access denied. In one case (that I know of) the pin code retrieved from bambu cloud was incorrect for the printer which is why I show it in that screen - so double check that against what the printer says it should be.

configuration.yaml to turn on debug logs permanently for the integration. This is chatty so once we get you sorted you'll want to remove this:

logger:
  default: info
  logs:
    custom_components.bambu_lab: debug

There's a race condition during setup where sometimes the AMS's don't get added that I haven't found a solution for yet. But so far they've always appeared on a reload of the integration / restart of home assistant. But this latest version did have a change to delete orphaned AMS's that could be misbehaving. So if they appear on restarting HA / reloading the integration then it's the known issue. If they remain MIA, please let me know (and provide debug logs of an integration load :)).

cayalag commented 1 month ago

Debug logs weren't enabled but it is expected that you won't get a camera if the printer IP isn't provided. I'd need debug logs to have a chance to know why it failed the test connection at that point. You'll need to turn debug logs on in the configuration.yaml to get them for the initial integration setup. All I see in these logs is that the mqtt connection to the printer is repetitively being denied with access denied. In one case (that I know of) the pin code retrieved from bambu cloud was incorrect for the printer which is why I show it in that screen - so double check that against what the printer says it should be.

configuration.yaml to turn on debug logs permanently for the integration. This is chatty so once we get you sorted you'll want to remove this:

logger:
  default: info
  logs:
    custom_components.bambu_lab: debug

There's a race condition during setup where sometimes the AMS's don't get added that I haven't found a solution for yet. But so far they've always appeared on a reload of the integration / restart of home assistant. But this latest version did have a change to delete orphaned AMS's that could be misbehaving. So if they appear on restarting HA / reloading the integration then it's the known issue. If they remain MIA, please let me know (and provide debug logs of an integration load :)).

It Works !! With the last update to dev2 I had forgotten to activate debug logs as you said. So the only thing I did was to edit the yaml, delete printers once again... reset HA, config the printers again (this time it worked when adding IPs) and both of them show camera feeds and AMS.

Thanks Adrian !