Changing LED bar for notifications in HomeAssistant

Guys, use the device actions in your automations… much cleaner than the service:

1 Like

As of the time of my post, the device action was not working to change led color. I just posted the yaml of the action because it is easier to see the whole picture

I am using 2.07 and ZHA on home assistant and the device action is still not working (gives an error) for all LED’s or for single LED’s. The cluster command does work.

Is it working for anyone else on ZHA?

1 Like

Yep, I have it working fine on the two switches I have installed.

1 Like

Weird, anyone have any thoughts on why its not working for me? Screenshots and logs below.

Logger: homeassistant.components.websocket_api.http.connection
Source: components/zha/core/channels/base.py:78
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: November 8, 2022 at 10:47:24 PM (5 occurrences)
Last logged: 8:39:29 AM

[139787516543376] Error handling message: Unknown error (unknown_error) from 192.168.1.156 (Mozilla/5.0 (Linux; Android 12; Pixel 5a Build/SQ3A.220705.003.A1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/107.0.5304.105 Mobile Safari/537.36 Home Assistant/2022.10.2-2770 (Android 12; Pixel 5a))
[139787478063840] Error handling message: Unknown error (unknown_error) from 192.168.1.156 (Mozilla/5.0 (Linux; Android 12; Pixel 5a Build/SQ3A.220705.003.A1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/107.0.5304.105 Mobile Safari/537.36 Home Assistant/2022.10.2-2770 (Android 12; Pixel 5a))
[139787516343008] Error handling message: Unknown error (unknown_error) from 192.168.1.1 (Mozilla/5.0 (Linux; Android 12; Pixel 5a Build/SQ3A.220705.003.A1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/107.0.5304.105 Mobile Safari/537.36 Home Assistant/2022.10.2-2770 (Android 12; Pixel 5a))
[139786963573760] Error handling message: Unknown error (unknown_error) from 192.168.1.101 (Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0)
Traceback (most recent call last):
File “/usr/local/lib/python3.10/site-packages/zigpy/types/struct.py”, line 39, in _convert_type
return self.type(value)
File “/usr/local/lib/python3.10/site-packages/zigpy/types/basic.py”, line 91, in new
n = super().new(cls, *args, **kwargs)
ValueError: invalid literal for int() with base 10: ‘Fast_Blink’

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

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 “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 646, in handle_execute_script
await script_obj.async_run(msg.get(“variables”), context=context)
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 1524, in async_run
await asyncio.shield(run.async_run())
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 409, in async_run
await self._async_step(log_exceptions=False)
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 453, in _async_step
self._handle_exception(
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 476, in _handle_exception
raise exception
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 451, in _async_step
await getattr(self, handler)()
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 692, in _async_device_step
await device_action.async_call_action_from_config(
File “/usr/src/homeassistant/homeassistant/components/device_automation/action.py”, line 76, 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 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 237, 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=‘Fast_Blink’ from type <class ‘str’> to <class ‘zigpy.types.basic.uint8_t’>

Logger: homeassistant.helpers.script.websocket_api_script
Source: components/zha/core/channels/base.py:78
First occurred: November 8, 2022 at 10:47:24 PM (5 occurrences)
Last logged: 8:39:29 AM

websocket_api script: Error executing script. Unexpected error for device at pos 1: Failed to convert led_effect=‘Fast_Blink’ from type <class ‘str’> to <class ‘zigpy.types.basic.uint8_t’>
websocket_api script: Error executing script. Unexpected error for device at pos 1: Failed to convert led_effect=‘Open_Close’ from type <class ‘str’> to <class ‘zigpy.types.basic.uint8_t’>
Traceback (most recent call last):
File “/usr/local/lib/python3.10/site-packages/zigpy/types/struct.py”, line 39, in _convert_type
return self.type(value)
File “/usr/local/lib/python3.10/site-packages/zigpy/types/basic.py”, line 91, in new
n = super().new(cls, *args, **kwargs)
ValueError: invalid literal for int() with base 10: ‘Fast_Blink’

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 451, in _async_step
await getattr(self, handler)()
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 692, in _async_device_step
await device_action.async_call_action_from_config(
File “/usr/src/homeassistant/homeassistant/components/device_automation/action.py”, line 76, 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 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 237, 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=‘Fast_Blink’ from type <class ‘str’> to <class ‘zigpy.types.basic.uint8_t’>

What is the version of HA, what is your installation method?

Also, do me a favor and try in just an automation and not a script please. I’m thinking something with scripts may not be handling device action schema conversion correctly…

I am running HA OS on a virtual machine. Fully up to date.
image

I am not using a script, I am just using an automation. The script I pasted above is just the data from the error logs after I run the automation. Here’s the steps I am following: Create automation–Start with an empty automation–add action-select device–leave action at default of issue effect for all led’s–select effect type (doesnt seem to matter what I pick)–select a color-select level-select duration–click save–click run action Then I get the error.

I should add that other actions (such as toggle the light) work without errors when using the same steps.

After I create the action using the visual editor, here is what the edit in yaml shows.

Can you save the automation (pick any trigger for now) then run the entire automation from the 3 dots menu on the main automation list? I know it’s a weird request but humor me.

That actually worked! Is there a reason why that works?

If running the code works via the three dots, it sounds like whatever trigger you are using in your automation isn’t activating the action.

Yeah, running the automation works, running the action doesnt. Weird.

Have you tried using a known working trigger and injecting the LED action into the end of it?

@dan4 I think we might be talking about different things - I don’t think it’s related to the trigger. The issue we’ve identified with zha seems that when you try running/testing the action inside the automation by clicking the three dots next to the specific action and clicking run: the led action fails. But when you step out of the automation and are in HA main automation page and click run on the automation, the led action works fine.

Ah, that is strange. Hopefully @dmulcahey can chime in with more. I just tested the exact code with a time trigger. It worked perfectly as an automation, running from the automation page, and running from within the action page itself.

Running 2022.11.2 with ZHA. Tested on both the switches I have.

It looks like running just the action uses the script engine in HA and there is something wrong with type conversion. It is in the full error that you posted. That’s why I wanted you to try this. Thanks for the testing!! I need to look closer at it when I have time but it may be an issue in core itself (or there is a hook that I was supposed to implement and didn’t). It shouldn’t work differently based on where it’s called from.

Any luck with notifying multiple switches? I’m having the same problem mentioned in this post, where issuing a cluster command to a switch (or using the Issue effect action) works fine, but issue_zigbee_group_command gives an “Unknown error”:

service: zha.issue_zigbee_group_command
data:
  group: "2"
  cluster_id: 64561
  cluster_type: in
  command: 3
  args:
    - 6
    - 1
    - 95
    - 100
    - 10
  manufacturer: "4655"

I notice that for issue_zigbee_cluster_command, there’s a command_type: server, but that doesn’t seem to be present/allowed for issue_zigbee_group_command.

I see in the automation trace “Unsupported 0xfc31 cluster id for groups”

I just noticed that after creating a group containing all of my switches, I now have a light entity and a switch entity, both named “Texas Instruments CC1352/CC2652, Z-Stack 3.30+ (build 20220928) All inovelli_zha_group_0x0002”. And if I turn the switch entity on/off, it controls all the switches, so that seemed promising. However, if I add it to an automation Device action, “Issue effect …” isn’t one of the available actions. I can only do the basic dimmer actions like turn on, turn off, toggle, increase, decrease, etc…