smartHomeHub / SmartIR

Integration for Home Assistant to control climate, TV and fan devices via IR/RF controllers (Broadlink, Xiaomi, MQTT, LOOKin, ESPHome)
MIT License
2.03k stars 1k forks source link

[custom_components.smartir.climate] string indices must be integers, not 'str' #1139

Open anthonws opened 1 year ago

anthonws commented 1 year ago

Home Assistant version Version 2023.9.3

SmartIR version Version 1.17.8

SmartIR configuration

  update_branch: rc

climate:
  - platform: smartir
    name: Office AC
    unique_id: office_ac
    device_code: 9999
    controller_data: remote.universal_remote_office_remote
    temperature_sensor: sensor.universal_remote_office_temperature
    humidity_sensor: sensor.universal_remote_office_humidity

  - platform: smartir
    name: Kids Bedroom AC
    unique_id: kids_ac
    device_code: 9999
    controller_data: remote.universal_remote_kids_bedroom_remote
    temperature_sensor: sensor.universal_remote_kids_bedroom_temperature
    humidity_sensor: sensor.universal_remote_kids_bedroom_humidity

  - platform: smartir
    name: Living Room AC
    unique_id: living_room_ac
    device_code: 9999
    controller_data: remote.universal_remote_living_room_remote
    temperature_sensor: sensor.awair_living_room_temp
    humidity_sensor: sensor.awair_living_room_humid

  - platform: smartir
    name: Master Bedroom AC
    unique_id: master_bedroom_ac
    device_code: 9999
    controller_data: remote.universal_remote_master_bedroom_remote
    temperature_sensor: sensor.awair_master_bedroom_temp
    humidity_sensor: sensor.awair_master_bedroom_humid

Add configuration here

Describe the bug

HA 2023.9.3. Spotted errors related to "string indices must be integers, not 'str'" when turning on the fan mode for my ACs (Midea).

Debug log



2023-09-29 12:23:44.167 DEBUG (MainThread) [custom_components.smartir.climate] loading json file /config/custom_components/smartir/codes/climate/9999.json

2023-09-29 12:23:44.168 DEBUG (MainThread) [custom_components.smartir.climate] /config/custom_components/smartir/codes/climate/9999.json file loaded

2023-09-29 12:23:44.168 DEBUG (MainThread) [custom_components.smartir.climate] SmartIRClimate init started for device Office AC supported models ['Unknown']

2023-09-29 12:23:44.172 DEBUG (MainThread) [custom_components.smartir.climate] Setting up the startir platform

2023-09-29 12:23:44.172 DEBUG (MainThread) [custom_components.smartir.climate] loading json file /config/custom_components/smartir/codes/climate/9999.json

2023-09-29 12:23:44.173 DEBUG (MainThread) [custom_components.smartir.climate] /config/custom_components/smartir/codes/climate/9999.json file loaded

2023-09-29 12:23:44.173 DEBUG (MainThread) [custom_components.smartir.climate] SmartIRClimate init started for device Kids Bedroom AC supported models ['Unknown']

2023-09-29 12:23:44.175 DEBUG (MainThread) [custom_components.smartir.climate] Setting up the startir platform

2023-09-29 12:23:44.176 DEBUG (MainThread) [custom_components.smartir.climate] loading json file /config/custom_components/smartir/codes/climate/9999.json

2023-09-29 12:23:44.176 DEBUG (MainThread) [custom_components.smartir.climate] /config/custom_components/smartir/codes/climate/9999.json file loaded

2023-09-29 12:23:44.178 DEBUG (MainThread) [custom_components.smartir.climate] SmartIRClimate init started for device Living Room AC supported models ['Unknown']

2023-09-29 12:23:44.179 DEBUG (MainThread) [custom_components.smartir.climate] async_added_to_hass <entity climate.office_ac=off> Office AC 9

2023-09-29 12:23:44.180 DEBUG (MainThread) [custom_components.smartir.climate] Setting up the startir platform

2023-09-29 12:23:44.181 DEBUG (MainThread) [custom_components.smartir.climate] loading json file /config/custom_components/smartir/codes/climate/9999.json

2023-09-29 12:23:44.181 DEBUG (MainThread) [custom_components.smartir.climate] /config/custom_components/smartir/codes/climate/9999.json file loaded

2023-09-29 12:23:44.182 DEBUG (MainThread) [custom_components.smartir.climate] SmartIRClimate init started for device Master Bedroom AC supported models ['Unknown']

2023-09-29 12:23:44.182 DEBUG (MainThread) [custom_components.smartir.climate] async_added_to_hass <entity climate.kids_bedroom_ac=off> Kids Bedroom AC 9

2023-09-29 12:23:44.185 DEBUG (MainThread) [custom_components.smartir.climate] async_added_to_hass <entity climate.living_room_ac=off> Living Room AC 9

2023-09-29 12:23:44.189 DEBUG (MainThread) [custom_components.smartir.climate] async_added_to_hass <entity climate.master_bedroom_ac=off> Master Bedroom AC 9

Add your logs here.

```2023-09-29 12:13:25.350 ERROR (MainThread) [custom_components.smartir.climate] string indices must be integers, not 'str'

Traceback (most recent call last):

  File "/config/custom_components/smartir/climate.py", line 383, in send_command

    self._commands[operation_mode][fan_mode][target_temperature])

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^

TypeError: string indices must be integers, not 'str'

2023-09-29 12:13:27.765 ERROR (MainThread) [custom_components.smartir.climate] string indices must be integers, not 'str'

Traceback (most recent call last):

  File "/config/custom_components/smartir/climate.py", line 383, in send_command

    self._commands[operation_mode][fan_mode][target_temperature])

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^

TypeError: string indices must be integers, not 'str'
litinoveweedle commented 6 months ago

To me it seems, that in the codes for your Midea device fan modes are missing. ;-)

anthonws commented 6 months ago

It is indeed missing the temperature(s) for the fan profile. I've open a discussion here (https://github.com/smartHomeHub/SmartIR/discussions/1222) but got no feedback. I've modified the code (for me only), which "fixes" this issue. I'll close this as it is indeed not an issue. Thanks!

litinoveweedle commented 6 months ago

I am trying to solve issue with any potential missing code. I did replied to you in your original discussion. I would keep this issue open, until I can provide PR solving it. ;-)

anthonws commented 6 months ago

Keeping this open based on your input. Thank you.

litinoveweedle commented 4 months ago

Hi, I merged proposed change into my https://github.com/litinoveweedle/SmartIR/pull/2 and I will release it soon. You can test it and report back.