krahabb / meross_lan

Home Assistant integration for Meross devices
MIT License
417 stars 45 forks source link

Error when attempting to open or close Meross Garage Door #361

Closed sparment closed 8 months ago

sparment commented 8 months ago

Version of the custom_component

meross_lan v4.5.1 msg200 4.0.0 by Meross Firmware: 4.2.8 Hardware: 4.0.0

Describe the bug

Errors are recorded in the log when attempting to open or close Meross garage doors via service calls:

cover.open_cover
cover.close_cover

The garage doors still operate as expected with the service calls, but the errors are flashed on the HA screen and then recorded in the log.

Debug log


Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:238
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 5:18:11 PM (11 occurrences)
Last logged: 5:27:00 PM

[547867647808] list indices must be integers or slices, not str
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 238, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/meross_lan/cover.py", line 373, in async_open_cover
    await self.async_request_position(1)
  File "/config/custom_components/meross_lan/cover.py", line 397, in async_request_position
    self._open = p_state[mc.KEY_OPEN]
                 ~~~~~~~^^^^^^^^^^^^^
TypeError: list indices must be integers or slices, not str
jmcollin78 commented 8 months ago

Hello,

Same for me since 4.5.1 with a garage door also: msg200 4.0.0 or msg100 3.5.0.

EDIT: same issue with the 4.5.0 release. I will revert back to the previous 4.4 release. EDIT2: I can confirm that is it working normally with 4.4.1 release.

In my case, it is when I try to close all covers in a scene like this one:

- id: '1652856205684'
  name: Volets fermés
  entities:
    cover.volets_et_portes:
      current_position: 0
      entity_id:
      - cover.porte_garage_garage
      - cover.volet_roulant_sam
      - cover.volets_bureau
      - cover.volets_cuisine
      - cover.volets_entree
      - cover.volets_sam2
      - cover.volets_sam3
      - cover.volets_sdb
      assumed_state: true
      device_class: shutter
      icon: mdi:window-shutter
      friendly_name: Groupe volets et portes
      supported_features: 15
      state: closed
  icon: mdi:window-shutter
  metadata:
    cover.volets_et_portes:
      entity_only: true

Something have been broken. My logs (quite the same as above):

2024-01-01 23:59:57.455 ERROR (MainThread) [homeassistant.components.automation.bonjour_bonne_nuit] Bonjour Bonne nuit: Error executing script. Unexpected error for choose at pos 1: list indices must be integers or slices, not str
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 924, in _async_choose_step
    await self._async_run_script(script)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1069, in _async_run_script
    await self._async_run_long_action(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1578, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 420, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 470, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 493, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/scene/__init__.py", line 114, in _async_activate
    await self.async_activate(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/homeassistant/scene.py", line 375, in async_activate
    await async_reproduce_state(
  File "/usr/src/homeassistant/homeassistant/helpers/state.py", line 67, in async_reproduce_state
    await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/helpers/state.py", line 61, in worker
    await platform.async_reproduce_states(
  File "/usr/src/homeassistant/homeassistant/components/cover/reproduce_state.py", line 125, in async_reproduce_states
    await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/components/cover/reproduce_state.py", line 86, in _async_reproduce_state
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/group/cover.py", line 189, in async_close_cover
    await self.hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 903, in entity_service_call
    raise result from None
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1233, in async_request_call
    return await coro
           ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/meross_lan/cover.py", line 376, in async_close_cover
    await self.async_request_position(0)
  File "/config/custom_components/meross_lan/cover.py", line 397, in async_request_position
    self._open = p_state[mc.KEY_OPEN]
                 ~~~~~~~^^^^^^^^^^^^^
TypeError: list indices must be integers or slices, not str
krahabb commented 8 months ago

Ahh..well, This is interesting since it is very likely that previous versions had the same bug just they were silently discarding the exception. It looks like the device response is not as expected and you see the error because 4.5 is now stricter (this way, anything different from expected is raising this nice dump;) Another fix in the todo list

sparment commented 8 months ago

Fixed for me! Thanks for the quick response!!

jmcollin78 commented 8 months ago

Fixed for me too ! thank you