greghesp / ha-bambulab

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

[Bug] Cannot open Camera stream #271

Closed i-B4se closed 10 months ago

i-B4se commented 11 months ago

Describe the bug

Hello, i added this Integration in Home Assistant, but I can not see the Camera of my X1C and getting the following Error:

Error from stream worker: Error opening stream (ERRORTYPE_101, Network unreachable) rtsps://:@192.168.234.100/streaming/live/1

But this is not my IP range. I have 192.168.178.XXX Other options/entitis appear normally.

I have the LAN Mode Liveview on.

Thank you in advance

To Reproduce

I have reinstalled it several times and also tested the cloud version

Expected Behaviour

I think he recognizes the wrong IP but i don't know the reason

What device are you using?

X1C

Diagnostic Output

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2023.11.2",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.11.6",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Berlin",
    "os_name": "Linux",
    "os_version": "6.1.59",
    "supervisor": "2023.11.3",
    "host_os": "Home Assistant OS 11.1",
    "docker_version": "24.0.6",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "hacs": {
      "version": "1.33.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "waste_collection_schedule": {
      "version": "1.43.0",
      "requirements": [
        "icalendar",
        "recurring_ical_events",
        "icalevents",
        "bs4",
        "lxml"
      ]
    },
    "auto_backup": {
      "version": "1.4.1",
      "requirements": []
    },
    "bambu_lab": {
      "version": "1.7.1",
      "requirements": []
    },
    "frigate": {
      "version": "4.0.0",
      "requirements": [
        "pytz==2022.7"
      ]
    },
    "mass": {
      "version": "2023.2.2",
      "requirements": []
    }
  },
  "integration_manifest": {
    "domain": "bambu_lab",
    "name": "Bambu Lab",
    "codeowners": [
      "@greghesp",
      "@AdrianGarside"
    ],
    "config_flow": true,
    "dependencies": [
      "device_automation",
      "mqtt",
      "ffmpeg"
    ],
    "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": "1.7.1",
    "is_built_in": false
  },
  "data": {
    "push_all": {
      "ams": {
        "ams": [
          {
            "humidity": "5",
            "id": "0",
            "temp": "28.7",
            "tray": [
              {
                "id": "0"
              },
              {
                "bed_temp": "0",
                "bed_temp_type": "0",
                "cali_idx": 4558,
                "cols": [
                  "0080C0FE"
                ],
                "ctype": 0,
                "drying_temp": "0",
                "drying_time": "0",
                "id": "1",
                "nozzle_temp_max": "240",
                "nozzle_temp_min": "190",
                "remain": -1,
                "tag_uid": "0000000000000000",
                "tray_color": "0080C0FE",
                "tray_diameter": "0.00",
                "tray_id_name": "",
                "tray_info_idx": "GFL99",
                "tray_sub_brands": "",
                "tray_type": "PLA",
                "tray_uuid": "00000000000000000000000000000000",
                "tray_weight": "0",
                "xcam_info": "000000000000000000000000"
              },
              {
                "bed_temp": "35",
                "bed_temp_type": "1",
                "cali_idx": 3434,
                "cols": [
                  "1D7C6AFF"
                ],
                "ctype": 0,
                "drying_temp": "55",
                "drying_time": "8",
                "id": "2",
                "nozzle_temp_max": "230",
                "nozzle_temp_min": "190",
                "remain": 100,
                "tag_uid": "C029F32D00000100",
                "tray_color": "1D7C6AFF",
                "tray_diameter": "1.75",
                "tray_id_name": "A02-G2",
                "tray_info_idx": "GFA02",
                "tray_sub_brands": "PLA Metal",
                "tray_type": "PLA",
                "tray_uuid": "0ECA261C0E154D589642300A72B9AFC1",
                "tray_weight": "1000",
                "xcam_info": "D007D007E803E803CDCC4C3F"
              },
              {
                "bed_temp": "0",
                "bed_temp_type": "2",
                "cali_idx": 6736,
                "cols": [
                  "FFC600FF"
                ],
                "ctype": 0,
                "drying_temp": "55",
                "drying_time": "8",
                "id": "3",
                "nozzle_temp_max": "240",
                "nozzle_temp_min": "200",
                "remain": 100,
                "tag_uid": "309CD15E00000100",
                "tray_color": "FFC600FF",
                "tray_diameter": "1.75",
                "tray_id_name": "A05-Y4",
                "tray_info_idx": "GFA05",
                "tray_sub_brands": "PLA Silk",
                "tray_type": "PLA",
                "tray_uuid": "CC5AB1EC1FA9473EB7F5379ECC50B910",
                "tray_weight": "1000",
                "xcam_info": "A438803EE803E8033333333F"
              }
            ]
          }
        ],
        "ams_exist_bits": "1",
        "insert_flag": true,
        "power_on_flag": false,
        "tray_exist_bits": "e",
        "tray_is_bbl_bits": "e",
        "tray_now": "1",
        "tray_pre": "1",
        "tray_read_done_bits": "e",
        "tray_reading_bits": "0",
        "tray_tar": "1",
        "version": 190
      },
      "ams_rfid_status": 2,
      "ams_status": 768,
      "aux_part_fan": true,
      "bed_target_temper": 35.0,
      "bed_temper": 35.0,
      "big_fan1_speed": "10",
      "big_fan2_speed": "0",
      "cali_version": 1,
      "chamber_temper": 30.0,
      "command": "push_status",
      "cooling_fan_speed": "15",
      "fail_reason": "0",
      "fan_gear": 45823,
      "filam_bak": [],
      "force_upgrade": false,
      "gcode_file": "/data/Metadata/plate_1.gcode",
      "gcode_file_prepare_percent": "100",
      "gcode_start_time": "1700238358",
      "gcode_state": "RUNNING",
      "heatbreak_fan_speed": "15",
      "hms": [],
      "home_flag": 116207,
      "hw_switch_state": 1,
      "ipcam": {
        "ipcam_dev": "1",
        "ipcam_record": "enable",
        "mode_bits": 2,
        "resolution": "1080p",
        "rtsp_url": "**REDACTED**",
        "timelapse": "enable",
        "tutk_server": "enable"
      },
      "layer_num": 190,
      "lifecycle": "product",
      "lights_report": [
        {
          "mode": "on",
          "node": "chamber_light"
        },
        {
          "mode": "flashing",
          "node": "work_light"
        }
      ],
      "maintain": 3,
      "mc_percent": 90,
      "mc_print_error_code": "0",
      "mc_print_stage": "2",
      "mc_print_sub_stage": 0,
      "mc_remaining_time": 28,
      "mess_production_state": "active",
      "msg": 0,
      "nozzle_diameter": "0.4",
      "nozzle_target_temper": 220.0,
      "nozzle_temper": 220.0,
      "nozzle_type": "hardened_steel",
      "online": {
        "ahb": false,
        "ext": false,
        "version": 9
      },
      "print_error": 0,
      "print_gcode_action": 0,
      "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": "9066",
      "spd_lvl": 2,
      "spd_mag": 100,
      "stg": [
        2,
        14,
        1,
        8
      ],
      "stg_cur": 0,
      "subtask_id": "",
      "subtask_name": "Schl\u00fcsselboard.gcode.3mf",
      "task_id": "8045",
      "total_layer_num": 215,
      "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": 9,
        "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": "PLA",
        "tray_uuid": "00000000000000000000000000000000",
        "tray_weight": "0",
        "xcam_info": "000000000000000000000000"
      },
      "wifi_signal": "-75dBm",
      "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.06.05.01"
        },
        {
          "hw_ver": "AP05",
          "name": "rv1126",
          "sn": "**REDACTED**",
          "sw_ver": "00.00.24.13"
        },
        {
          "hw_ver": "TH09",
          "name": "th",
          "sn": "**REDACTED**",
          "sw_ver": "00.00.05.83"
        },
        {
          "hw_ver": "MC07",
          "name": "mc",
          "sn": "**REDACTED**",
          "sw_ver": "00.00.16.68/00.00.16.68"
        },
        {
          "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

No response

Other Information

No response

greghesp commented 11 months ago

Yep same thing here. This isn't anything to do with this integration, it's something in the Bambu side. My printer is reporting the same IP address in the rtsp section

anoblet commented 11 months ago

I get intermittent access,. It seems to work for a little bit after reconfiguring the integration with a new static IP, though eventually breaks.

swampylee commented 11 months ago

I get intermittent access,. It seems to work for a little bit after reconfiguring the integration with a new static IP, though eventually breaks.

Try quitting from Bambu Studio and see if the stream reinstates itself, and if not restart the integration and see. I've seen if I've streamed the camera from within studio the HA integration camera doesn't show so it would seem you can't steam in studio and in HA at the same time.

Update: I just tried this myself when the stream stopped working in HA and quitting Bambu Studio didn't help and neither did reloading the Bambu integration. I see this in the logs:

2023-11-23 16:56:55.017 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.bambu_lab_x1_carbon_printer_camera] Error from stream worker: Error opening stream (ERRORTYPE_5, I/O error) rtsps://:@192.168.1.243/streaming/live/1

And I have a static IP address assigned to the printer and is shown correctly in the above extract.

AdrianGarside commented 11 months ago

My experience is that the camera feed breaks permanently at the end of the first print. You have to restart the printer to get it working again... for exactly one print.

i-B4se commented 11 months ago

And I have a static IP address assigned to the printer and is shown correctly in the above extract.

My printer also has a static IP.

I have reinstalled the integration several times and then restarted the printer, but I always get the error message with the wrong IP

wjbuys commented 11 months ago

It looks like the official Bambu Studio code that handles this ignores the address returned from the rtsp_url field (it only uses the protocol information):

https://github.com/bambulab/BambuStudio/blob/5f0f0b0b619a28d65b9d534137556456a998eee7/src/slic3r/GUI/DeviceManager.cpp#L3567-L3582

and then manually constructs a URL using the actual device IP:

https://github.com/bambulab/BambuStudio/blob/5f0f0b0b619a28d65b9d534137556456a998eee7/src/slic3r/GUI/MediaPlayCtrl.cpp#L195-L209

wjbuys commented 11 months ago

Looks like this was fixed once before, and then reverted: https://github.com/greghesp/ha-bambulab/commit/cf6a360b39cce96a281594b14f38940dff8d0765

AdrianGarside commented 11 months ago

Re-applied that fix with #299

AdrianGarside commented 10 months ago

Closing this specific issue. We have another one tracking general unreliability of the rtsp feed - that is, unfortunately, entirely on the Bambu side.