Andre0512 / hon

Home Assistant integration for Haier hOn: support for Haier/Candy/Hoover home appliances like washing machines and air conditioners in 28 languages.
MIT License
1.3k stars 2.46k forks source link

"ValueError: invalid literal for int() with base 10: 'false'" after reconnecting tumble dryer #171

Open mmalolepszy opened 9 months ago

mmalolepszy commented 9 months ago

Describe the bug Yesterday most of entities provided by hOn integration have disappeared and the following error started to spam HA logs:

2024-02-14 12:11:37.272 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 243, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 399, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 182, in async_update_listeners
    update_callback()
  File "/config/custom_components/hon/hon.py", line 107, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 945, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1066, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1002, in __async_calculate_state
    available = self.available  # only call self.available once per update cycle
                ^^^^^^^^^^^^^^
  File "/config/custom_components/hon/switch.py", line 489, in available
    and int(self._device.get("remoteCtrValid", 1)) == 1
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'false'

I'm not sure what exactly might have caused that but my suspicions are directed towards my HD80-A3959 tumble dryer (device log attached) as I reconnected it after a couple of months of not being used, around the time of the first log entry appeared. However I haven't seen this error before the dryer was disconnected.

I've changed the line indicated by the exception to

and self._device.get("remoteCtrValid")

and it fixed the issue but I'm not pushing this change as a PR to the repo because I'm not sure it won't break something else.

Expected behavior No error in the logs and all entities available.

Environment:

Device Log

data:
  additional_data:
    dictionaryId: 203
    options: hybrid
  appliance:
    PK: user#eu-west-1:c2aa9924-a827-4a59-8691-fb34d64aee30
    SK: app#xx-xx-xx-xx-xx-xx
    applianceId: xx-xx-xx-xx-xx-xx#1970-01-01T00:00:00.0Z
    applianceModelId: 1010
    applianceStatus: 1
    applianceTypeId: 8
    applianceTypeName: TD
    attributes:
      acuVersion: 0.0.0
      chipset: 1
      dictionaryId: 203
      eppParserSet: 1
      fwLabel: iotfw_epp
      idfVersion: 4.4.4
      kernelVersion: 10.4.3
      lang: it-IT
      uiVersion: ..
    brand: haier
    code: CF067YE0100
    connectivity: wifi|ble
    defaultWarrantyYears: 2
    eepromId: 41
    eepromName: no_eeprom
    enrollmentDate: 1970-01-01T00:00:00.0Z
    firstEnrollment: True
    firstEnrollmentTBC: True
    fwVersion: 5.15.0
    id: 1010
    lastUpdate: 1970-01-01T00:00:00.0Z
    macAddress: xx-xx-xx-xx-xx-xx
    modelName: HD80-A3959 INT
    nickName: Suszarka bębnowa
    purchaseDate: 1970-01-01T00:00:00.0Z
    sections:
      chatbot: True
      demo: True
      double_pairing_hidden: True
      ecoDelayStart: True
      epp_enabled: False
      guided_washing: True
      snap_and_dry: False
      snap_wash: True
    series: 959
    structure: heatpump
    topics:
      publish:
      subscribe:
        - $aws/events/presence/disconnected/xx-xx-xx-xx-xx-xx
        - $aws/events/presence/connected/xx-xx-xx-xx-xx-xx
        - haier/things/xx-xx-xx-xx-xx-xx/event/appliancestatus/update
        - haier/things/xx-xx-xx-xx-xx-xx/event/discovery/update
  attributes:
    active: False
    activity:
    lastConnEvent:
      category: DISCONNECTED
      instantTime: 1970-01-01T00:00:00.0Z
      macAddress: xx-xx-xx-xx-xx-xx
      timestampEvent: 1707909986760
    parameters:
      airWashMode: 1
      airwashSprayTime: 0
      anionStatus: false
      antiCreaseTime: 0
      buzzerDisabled: false
      cloudProgId: 0
      cloudProgSrc: 2
      debugEnabled: 0
      delayTime: 0
      delicateStatus: false
      doorStatus: false
      dryLevel: 3
      dryMode: 1
      dryTimeMM: 270
      errors: 00
      fastDryStatus: false
      forceDelete: false
      highTransRate: 1
      ironRemindStatus: false
      ironingStatus: 0
      lockStatus: false
      machMode: 0
      message: 0
      mitesRemovalStatus: false
      onOffStatus: true
      pause: 2
      prCode: 42
      prPhase: 0
      programClass: 1
      remainingStandbyTime: 1436
      remainingTimeMM: 270
      remoteCtrValid: false
      statusSyncRate: 1440
      stdTransRate: 1
      sterilizationStatus: false
      tempLevel: 4
      texture: 0
      transMode: 0
    pause: False
    programName: No Program
    resultCode: 0
  pauseProgram:
    parameters:
      pause: 1
  resumeProgram:
    parameters:
      pause: 0
  settings:
    custom:
      category: setConfig
    parameters:
      httpEndpoint: 0
      mqttEndpoint: 0
  startProgram:
    ancillaryParameters:
      energyLabel: 2
      prPosition: 8
      programCluster: specialCare
      programFamily: [guided|auto]
      programType: D
      remoteActionable: 1
      remoteVisible: 0
      suggestedLoadD: 4
      tumblingStatus: 0
    custom:
      program: iot_dry_baby
    parameters:
      airWashMode: 1
      airwashSprayTime: 0
      anionStatus: 0
      antiCreaseTime: 0
      buzzerDisabled: 1
      cloudProgId: 0
      cloudProgSrc: 2
      delayTime: 0
      delicateStatus: 0
      dryLevel: 14
      dryMode: 1
      dryTimeMM: 0
      fastDryStatus: 0
      ironRemindStatus: 1
      lockStatus: 0
      mitesRemovalStatus: 0
      onOffStatus: 1
      operationName: grDryCloudProg
      pause: 0
      prCode: 69
      programClass: 1
      sterilizationStatus: 0
      tempLevel: 4
      texture: 47
  statistics:
    drumCleaning:
      count: 0
      percentage: 0
      remaining: 100
      tot: 100
    filterCleaning:
      count: 0
      percentage: 0
      remaining: 15
      tot: 15
    lastCheckup: None
    mostUsedPrograms:
    programsCounter: 0
    resultCode: 0
    sprayArmsCleaning: 0
  stopProgram:
    parameters:
      returnStandby: 1
commands:
  settings:
    category:
      - setConfig
  startProgram:
    antiCreaseTime:
      max: 360
      min: 0
      step: 360
    delayTime:
      max: 1410
      min: 0
      step: 30
    dryLevel:
      max: 14
      min: 12
      step: 1
    dryTimeMM:
      - 15
      - 20
      - 25
      - 30
      - 35
      - 40
    energyLabel:
      max: 5
      min: 1
      step: 1
    program:
      - hqd_baby_care
      - hqd_bath_towel
      - hqd_bed_sheets
      - hqd_bulky
      - hqd_casual
      - hqd_cold_wind_timing
      - hqd_cotton
      - hqd_curtain
      - hqd_delicate
      - hqd_duvet
      - hqd_feather
      - hqd_hot_wind_timing
      - hqd_hygienic
      - hqd_i_refresh
      - hqd_jacket
      - hqd_jeans
      - hqd_mix
      - hqd_night_dry
      - hqd_outdoor
      - hqd_precious_cure
      - hqd_quick_30
      - hqd_quick_dry
      - hqd_quilt
      - hqd_refresh
      - hqd_shirt
      - hqd_shoes
      - hqd_silk
      - hqd_sports
      - hqd_synthetics
      - hqd_timer
      - hqd_underwear
      - hqd_wool
      - hqd_working_suit
      - iot_dry_baby
      - iot_dry_backpacks
      - iot_dry_bathrobe
      - iot_dry_bed_linen
      - iot_dry_cotton
      - iot_dry_cuddly_toys
      - iot_dry_curtains
      - iot_dry_delicates
      - iot_dry_denim_jeans
      - iot_dry_down_jacket
      - iot_dry_duvet
      - iot_dry_gym_fit
      - iot_dry_lingerie
      - iot_dry_mixed
      - iot_dry_pet_accessories
      - iot_dry_pet_hair_removal
      - iot_dry_rapid_30
      - iot_dry_rapid_59
      - iot_dry_shirts
      - iot_dry_swimsuits_and_bikinis
      - iot_dry_synthetics
      - iot_dry_tablecloths
      - iot_dry_technical_fabrics
      - iot_dry_wool
    programFamily:
      - wmsync
      - guided
      - voice
      - care
      - auto
      - wmsync_guided_voice_care_auto
    sterilizationStatus:
      max: 1
      min: 0
      step: 1
    tempLevel:
      max: 4
      min: 1
      step: 1
    tumblingStatus:
      max: 1
      min: 0
      step: 1
versions:
  hon: 0.13.0
  pyhOn: 0.16.0