Changing LED bar for notifications in HomeAssistant

Additionally, change the command to 3 and add an extra arg at the start for LED# for per-LED effects :slight_smile:

1 Like

Do you know what command will clear the notification?

I believe effect 255 is clear, otherwise double tapping the config button clears it as well if you prefer that approach.

1 Like

@chack, one more Question :slight_smile: The script works as intended, but it does throw a timeout exception ~10s after running. It doesn’t seem to be causing any problems though. Have you seen this behavior?

Ah yeah, like you said, it gives an error but still works. It is planned to be addressed with the manufacturer and hopefully fixed in a later firmware release.

@chack , can this be done for Zigbee groups as well in ZHA? I got the solution working for an individual switch, but I can’t seem to get it working for a Zigbee group.

service: zha.issue_zigbee_group_command
data:
  group: 4                 # My group id
  cluster_id: 64561        # Not sure where this comes from, but copied from above
  cluster_type: server
  command: 3
  args:
    - 7                    # Trying to turn LED #7 solid greenish for every switch in the group
    - 1
    - 95
    - 100
    - 255
  manufacturer: '4655'

I haven’t tried a group so let me know! For led#7 you’ll want to use 6 as the range is 0-6 :slight_smile:

1 Like

Anyone got this working for multiple switches? I can get an individual switch to work but when having multiple switches in a script only the first one in the script will run. I’m assuming the time out error message is causing it?

@huynh.kong , I’m having the same issue. Timeout breaks the script. Is the timeout a known issue? @chack , you had mentioned it might be fixed in a later firmware update? Is there a way for us to track that?

It should be in the next firmware release, but I can’t speak to the timeline for release. I’ll just tag @EricM_Inovelli to speak to that :slight_smile:

1 Like

I did not see this in the firmware notes, but I believe it may be fixed in v2.05. Keep an eye here:

2 Likes

Looks like it’s fixed. Updating a couple of switches now, and I’m no longer getting a timeout on one of the switches!

1 Like

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.