core icon indicating copy to clipboard operation
core copied to clipboard

Cast Error using Device Action "Issue effect for all LEDs" w/ Inovelli Blue Switches

Open tterrag1098 opened this issue 2 years ago • 10 comments
trafficstars

The problem

Steps to reproduce:

  • Create an action in an automation or script for a device
  • Choose an inovelli blue (zigbee) switch
  • Choose the "issue effect for all LEDs" action and select any values
  • Test that action (not the entire script/automation)

"Unknown error" will be shown. Checking the core logs shows this stacktrace: https://pastebin.com/bBfLLLB5

What version of Home Assistant Core has the issue?

2022.12.8

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

ZHA

Link to integration documentation on our website

https://www.home-assistant.io/integrations/zha

Diagnostics information

zha-9fd41b61b98cf009614bbc0608b4367d-Inovelli VZM31-SN-2c43a32ccc1959fa988bec13a4bac529.json.txt

Example YAML snippet

type: issue_all_led_effect
domain: zha
device_id: 2c43a32ccc1959fa988bec13a4bac529
effect_type: Solid
duration: 132
level: 1
color: 192

Anything in the logs that might be useful for us?

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
    await func(hass, connection, msg)
  File "/config/custom_components/nodered/websocket.py", line 84, in websocket_device_action
    await platform.async_call_action_from_config(hass, msg["action"], {}, context)
  File "/usr/src/homeassistant/homeassistant/components/zha/device_action.py", line 125, in async_call_action_from_config
    await ZHA_ACTION_TYPES[DEVICE_ACTION_TYPES[config[CONF_TYPE]]](
  File "/usr/src/homeassistant/homeassistant/components/zha/device_action.py", line 221, in _execute_channel_command_based_action
    await getattr(action_channel, action_type)(**config)
  File "/usr/src/homeassistant/homeassistant/components/zha/core/channels/manufacturerspecific.py", line 253, in issue_all_led_effect
    await self.led_effect(effect_type, color, level, duration, expect_reply=False)
  File "/usr/src/homeassistant/homeassistant/components/zha/core/channels/base.py", line 78, in wrapper
    result = await command(*args, **kwds)
  File "/usr/local/lib/python3.10/site-packages/zigpy/quirks/__init__.py", line 180, in command
    return await self.request(
  File "/usr/local/lib/python3.10/site-packages/zigpy/zcl/__init__.py", line 304, in request
    hdr, request = self._create_request(
  File "/usr/local/lib/python3.10/site-packages/zigpy/zcl/__init__.py", line 265, in _create_request
    request = schema(*args, **kwargs)  # type:ignore[operator]
  File "/usr/local/lib/python3.10/site-packages/zigpy/types/struct.py", line 115, in __new__
    setattr(instance, name, field._convert_type(value))
  File "/usr/local/lib/python3.10/site-packages/zigpy/types/struct.py", line 41, in _convert_type
    raise ValueError(
ValueError: Failed to convert led_effect='Solid' from type <class 'str'> to <class 'zigpy.types.basic.uint8_t'>

Additional information

No response

tterrag1098 avatar Jan 08 '23 20:01 tterrag1098

Hey there @dmulcahey, @adminiuga, @puddly, mind taking a look at this issue as it has been labeled with an integration (zha) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of zha can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign zha Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


zha documentation zha source (message by IssueLinks)

home-assistant[bot] avatar Jan 08 '23 20:01 home-assistant[bot]

For effect_type you need to use an integer, not a string literal.

Adminiuga avatar Jan 08 '23 22:01 Adminiuga

Here's the mapping btw: https://github.com/zigpy/zha-device-handlers/blob/22968954cacaff4fc2b00e02ca1bd5622f637393/zhaquirks/inovelli/types.py#L32-L44

TheJulianJES avatar Jan 08 '23 22:01 TheJulianJES

I think you misunderstand, this is not a choice I made. The action was configured from the UI, "Solid" comes from the drop-down. Additionally, it works fine when not running the action by itself, so it must be more complex than just "wrong type".

tterrag1098 avatar Jan 08 '23 23:01 tterrag1098

What happens when you edit the automation (you can switch to YAML mode) and change Solid to 1 and the re-run it?

And, if the whole automation is run, the same exact automation action just works successfully?

TheJulianJES avatar Jan 08 '23 23:01 TheJulianJES

Yes, that works. And yes to your second question as well. The problem with that workaround is that it's not possible to manually rewrite the value for something like Node-Red, and it's still a bug that should be fixed.

tterrag1098 avatar Jan 09 '23 02:01 tterrag1098

Any updates on this? Anything else I can do to help troubleshoot?

tterrag1098 avatar Jan 28 '23 04:01 tterrag1098

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

This is not a stale issue. I just ran into the same problem. ZHA with Skyconnect and Inovelli testing yields an error, running the automation does not

fat227stuff avatar Apr 30 '23 19:04 fat227stuff

It doesn't work when I test the action or when the automation runs:

type: issue_all_led_effect
domain: zha
device_id: 39d6cb9b73b6637354d3116042b6f13d
effect_type: Fast_Falling
color: 171
level: 100
duration: 10

This is YAML the UI wrote, so I would expect it to work.

owen2 avatar May 01 '23 14:05 owen2

I have the same issue. The automation sets the LED effect just fine, but if you test only the action of the automation it gives an Error Running Action: Unknown Error message. I'm running HA 2023.5.4 and using ZHA to connect to my Inovelli switch.

dbs179 avatar May 25 '23 12:05 dbs179

This appears to be fixed in 2023.8.0 (possibly earlier?)

owen2 avatar Aug 16 '23 15:08 owen2

Perhaps there was a regression. On 2023.8.3 and I'm seeing the same errors, where was just working previously. Using the value in the drop down.

Error: Failed to convert led_effect='Fast_Chase' from type <class 'str'> to <class 'zigpy.types.basic.uint8_t'>

kividid avatar Aug 19 '23 13:08 kividid

Been doing some debugging.

Had two automations set up using the GUI to trigger the issue_all_led_effect. One to set an alert, one to clear the alert. Set both up less than a week ago, and they worked as expected initially. Noticed yesterday neither was working when the automation was triggered. The trigger would fire, and other actions would run, but I saw the following error in the trace for the Inovelli LED effect:

Error: Failed to convert led_effect='Fast_Chase' from type <class 'str'> to <class 'zigpy.types.basic.uint8_t'>

In this state I saw the following:

  • Running the automation from the menu on the Automation Dashboard, or on the top right of the automation page would result in the same error behavior. Other actions (push notifications) would fire as expected, but error on the LED effect.
  • Running the individual action from the menu on the action row would trigger the LED effect reliably.

I was able to fix this by changing the effect_type from Fast_Chase to Solid and then saving the automation. Running the whole automation now correctly changed the LED effect. Changing the effect back to Fast_Chase also now works. Thinking perhaps it was an error with some effect types, I went through the whole list of effects and they all work as expected.

I'm not able to reproduce the error state again. Will keep poking at it.

kividid avatar Aug 19 '23 13:08 kividid

Able to reproduce behavior. Happens on restart.

  • Create automation with the issue_all_led_effect. Example automation below.
  • Confirm running automation manually triggers effect
  • Restart Home Assistant
  • Trigger automation manually after restart - effect does not appear
  • Run action from action row in Automation GUI - effect works
  • Change effect_type of action
  • Save automation
  • Trigger automation - effect appears

Possibly related: after rebooting and waiting for "Home Assistant has started!" message, viewing the effect in the automation will show "Unknow action" instead of "Issue effect for all LEDs". Waiting a minute or two and reloading fixes this.

image

Example automation

alias: Test
description: ""
trigger:
  - platform: time_pattern
    hours: "*"
condition: []
action:
  - type: issue_all_led_effect
    domain: zha
    device_id: 9af7814d7b27ce71f7a23256d7ed0732
    effect_type: Slow_Falling
    color: 6
    level: 100
    duration: 5
mode: single

Error after reboot and running automation

Logger: homeassistant.components.automation.test
Source: components/zha/core/cluster_handlers/__init__.py:64
Integration: Automation (documentation, issues)
First occurred: 10:28:23 AM (2 occurrences)
Last logged: 10:28:23 AM

Test: Error executing script. Unexpected error for device at pos 1: Failed to convert led_effect='Slow_Falling' from type <class 'str'> to <class 'zigpy.types.basic.uint8_t'>
While executing automation automation.test
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/zigpy/types/struct.py", line 39, in _convert_type
    return self.type(value)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/types/basic.py", line 91, in __new__
    n = super().__new__(cls, *args, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'Slow_Falling'

The above exception was the direct cause of the following exception:

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 719, in _async_device_step
    await device_action.async_call_action_from_config(
  File "/usr/src/homeassistant/homeassistant/components/device_automation/action.py", line 71, in async_call_action_from_config
    await platform.async_call_action_from_config(hass, config, variables, context)
  File "/usr/src/homeassistant/homeassistant/components/zha/device_action.py", line 128, in async_call_action_from_config
    await ZHA_ACTION_TYPES[DEVICE_ACTION_TYPES[config[CONF_TYPE]]](
  File "/usr/src/homeassistant/homeassistant/components/zha/device_action.py", line 226, in _execute_cluster_handler_command_based_action
    await getattr(action_cluster_handler, action_type)(**config)
  File "/usr/src/homeassistant/homeassistant/components/zha/core/cluster_handlers/manufacturerspecific.py", line 302, in issue_all_led_effect
    await self.led_effect(effect_type, color, level, duration, expect_reply=False)
  File "/usr/src/homeassistant/homeassistant/components/zha/core/cluster_handlers/__init__.py", line 64, in wrapper
    return await RETRYABLE_REQUEST_DECORATOR(func)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/util.py", line 132, in retry
    return await func()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/quirks/__init__.py", line 199, in command
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/zcl/__init__.py", line 355, in request
    hdr, request = self._create_request(
                   ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/zcl/__init__.py", line 317, in _create_request
    request = schema(*args, **kwargs)  # type:ignore[operator]
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/types/struct.py", line 108, in __new__
    setattr(instance, name, field._convert_type(value))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/zigpy/types/struct.py", line 41, in _convert_type
    raise ValueError(
ValueError: Failed to convert led_effect='Slow_Falling' from type <class 'str'> to <class 'zigpy.types.basic.uint8_t'>

kividid avatar Aug 21 '23 15:08 kividid

More unexpected behavior on restart:

Set up an automation to trigger a scene when the Config button is pressed on the switch. Works until restart. Getting it to work again requires changing the trigger in the GUI, saving the automation, and then switching it back.

kividid avatar Aug 26 '23 13:08 kividid

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.