greghesp / ha-bambulab

A Home Assistant Integration for Bambu Lab Printers
696 stars 58 forks source link

[Bug] current_layer and total_layers seem to be strings instead of floats #537

Open allgoewer opened 3 weeks ago

allgoewer commented 3 weeks ago

Describe the bug

I noticed that the sensors for current_layer and total_layer seem to not be floating points / integers. I suppose this could be changed in definitions.py via the value_fn?

I'm willing to provide a PR.

To Reproduce

  1. Go to your printer's device page
  2. Open current_layer or total_layers
  3. See screenshot

grafik

Expected Behaviour

I expect to see a graph, like normal sensors providing floats in HA

What device are you using?

A1 Mini

Diagnostic Output

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2024.5.5",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.12.2",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Berlin",
    "os_name": "Linux",
    "os_version": "6.6.29-haos",
    "supervisor": "2024.06.0",
    "host_os": "Home Assistant OS 12.3",
    "docker_version": "25.0.5",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "bambu_lab": {
      "documentation": "https://github.com/greghesp/ha-bambulab",
      "version": "2.0.21",
      "requirements": []
    },
    "deutschebahn": {
      "documentation": "https://github.com/faserf/ha-deutschebahn#readme",
      "version": "2.2.1",
      "requirements": [
        "schiene==0.26"
      ]
    },
    "waste_collection_schedule": {
      "documentation": "https://github.com/mampfes/hacs_waste_collection_schedule#readme",
      "version": "1.48.0",
      "requirements": [
        "icalendar",
        "recurring_ical_events",
        "icalevents",
        "beautifulsoup4",
        "lxml"
      ]
    },
    "ics_calendar": {
      "documentation": "https://github.com/franc6/ics_calendar",
      "version": "4.2.0",
      "requirements": [
        "ics>=0.7.2",
        "recurring_ical_events>=2.0.2",
        "icalendar>=5.0.4"
      ]
    },
    "hacs": {
      "documentation": "https://hacs.xyz/docs/configuration/start",
      "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.21",
    "is_built_in": false
  },
  "data": {
    "config_entry": {
      "entry_id": "bd4e771d2931fcf396dcb3df6443545f",
      "version": 2,
      "minor_version": 1,
      "domain": "bambu_lab",
      "title": "**REDACTED**",
      "data": {
        "device_type": "A1MINI",
        "serial": "**REDACTED**"
      },
      "options": {
        "region": "",
        "email": "",
        "username": "",
        "name": "",
        "host": "10.204.28.7",
        "local_mqtt": true,
        "auth_token": "",
        "access_code": "**REDACTED**",
        "usage_hours": 15.099999999999998
      },
      "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": "1080p",
        "tutk_server": "disable",
        "mode_bits": 3
      },
      "upload": {
        "status": "idle",
        "progress": 0,
        "message": ""
      },
      "nozzle_temper": 215.125,
      "nozzle_target_temper": 215,
      "bed_temper": 64.65625,
      "bed_target_temper": 65,
      "chamber_temper": 5,
      "mc_print_stage": "1",
      "heatbreak_fan_speed": "10",
      "cooling_fan_speed": "0",
      "big_fan1_speed": "0",
      "big_fan2_speed": "0",
      "mc_percent": 4,
      "mc_remaining_time": 138,
      "ams_status": 0,
      "ams_rfid_status": 0,
      "hw_switch_state": 1,
      "spd_mag": 100,
      "spd_lvl": 2,
      "print_error": 50348044,
      "lifecycle": "product",
      "wifi_signal": "-47dBm",
      "gcode_state": "FAILED",
      "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": "Pencil_holder.gcode.3mf",
      "gcode_file": "",
      "stg": [],
      "stg_cur": 0,
      "print_type": "idle",
      "home_flag": 859325847,
      "mc_print_line_number": "1216",
      "mc_print_sub_stage": 0,
      "sdcard": true,
      "force_upgrade": false,
      "mess_production_state": "active",
      "layer_num": 1,
      "total_layer_num": 501,
      "s_obj": [],
      "filam_bak": [],
      "fan_gear": 0,
      "nozzle_diameter": "0.4",
      "nozzle_type": "stainless_steel",
      "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": 0,
        "new_ver_list": []
      },
      "hms": [],
      "online": {
        "ahb": false,
        "rfid": false,
        "version": 429036585
      },
      "ams": {
        "ams": [],
        "ams_exist_bits": "0",
        "tray_exist_bits": "0",
        "tray_is_bbl_bits": "0",
        "tray_tar": "255",
        "tray_now": "254",
        "tray_pre": "254",
        "tray_read_done_bits": "0",
        "tray_reading_bits": "0",
        "version": 2,
        "insert_flag": true,
        "power_on_flag": false
      },
      "vt_tray": {
        "id": "254",
        "tag_uid": "0000000000000000",
        "tray_id_name": "",
        "tray_info_idx": "GFL99",
        "tray_type": "PLA",
        "tray_sub_brands": "",
        "tray_color": "000000FF",
        "tray_weight": "0",
        "tray_diameter": "0.00",
        "tray_temp": "0",
        "tray_time": "0",
        "bed_temp_type": "0",
        "bed_temp": "0",
        "nozzle_temp_max": "240",
        "nozzle_temp_min": "190",
        "xcam_info": "000000000000000000000000",
        "tray_uuid": "00000000000000000000000000000000",
        "remain": 0,
        "k": 0.019999999552965164,
        "n": 1
      },
      "lights_report": [
        {
          "node": "chamber_light",
          "mode": "on"
        }
      ],
      "xcam": {
        "buildplate_marker_detector": true
      },
      "command": "push_status",
      "msg": 0,
      "sequence_id": "260"
    },
    "get_version": {
      "command": "get_version",
      "sequence_id": "0",
      "module": [
        {
          "name": "ota",
          "project_name": "N1",
          "sw_ver": "01.02.00.00",
          "hw_ver": "OTA",
          "sn": "**REDACTED**",
          "flag": 3
        },
        {
          "name": "esp32",
          "project_name": "N1",
          "sw_ver": "01.08.25.58",
          "hw_ver": "AP05",
          "sn": "**REDACTED**",
          "flag": 0
        },
        {
          "name": "mc",
          "project_name": "N1",
          "sw_ver": "00.00.23.13",
          "loader_ver": "00.00.00.32",
          "hw_ver": "MC02",
          "sn": "**REDACTED**",
          "flag": 0
        },
        {
          "name": "th",
          "project_name": "N1",
          "sw_ver": "00.00.07.69",
          "loader_ver": "00.00.00.26",
          "hw_ver": "TH03",
          "sn": "**REDACTED**",
          "flag": 0
        }
      ],
      "result": "success",
      "reason": ""
    }
  }
}

Log Extracts

No response

Other Information

No response