Changing LED bar for notifications in HomeAssistant

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?

1 Like

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…

Sorry to bring this one back up, but I’m getting the same “unknown error” when trying to run the action.

type: issue_all_led_effect
domain: zha
device_id: 0202550d248353a14c13c671985a48b1
effect_type: Solid
color: 25
level: 50
duration: 117

image

image

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

zha:
  zigpy_config:
    ota:
      ikea_provider: true                        # Auto update Trådfri devices
      ledvance_provider: true                    # Auto update LEDVANCE/OSRAM devices
      salus_provider: true                       # Auto update SALUS/Computime devices
      inovelli_provider: true                    # Auto update INOVELLI devices
      thirdreality_provider: true                # Auto update 3REALITY devices
      otau_directory: /zha/zigpy_config/ota/     # Utilize .ota files to update everything else

zha_toolkit:

logger:
    default: info
    logs:
      zigpy.ota: debug
      homeassistant.core: info
      homeassistant.components.zha: debug
      bellows.zigbee.application: info
      bellows.ezsp: info
      zigpy: info
      zigpy_deconz.zigbee.application: info
      zigpy_deconz.api: info
      zigpy_xbee.zigbee.application: info
      zigpy_xbee.api: info
      zigpy_zigate: info
      zigpy_znp: info
      zhaquirks: info
      custom_components.zha_toolkit: info

Ok, now that I read through this thread more closely, I noticed this is the answer to the problem I was having:

Need to use the Automation Three Dots and not the Action Three Dots.

Going to post this on the Home Assistant forums tomorrow (I’ve been up way too late working on this), but I made a script blueprint that allows you to pass in all the variables at call-time, rather than at config-time.

The existing issue_all_led_effect requires users to define the device_id at config time, making it difficult to re-use the same color-effect-duration-intensity combo for a different device. The issue_all_led_effect action can also only be called via an automation/script (see the confusion others have had in here about triggering it via directly calling the action versus calling the encompassing automation).

So, I wanted to make a script that a) could be called anywhere, especially in Developer Tools, and b) could have all the variables, including the target device, passed into it as call-time rather than needing to be pre-configured.

And here it is:

# This blueprint will allow you to make one generic script, and pass in all variables, including target switch, effect, colors, etc. on each call.
# Users do NOT need to set up a per-device copy of this script.

blueprint:
  name: Inovelli VZM31-SN Notification LED (ZHA)
  description: >-
    A script that sets the notification LED bar of an Inovelli light switch.
  source_url: https://raw.githubusercontent.com/nwithan8/configs/main/home_assistant/blueprints/scripts/inovelli_vzm31-sn_notification_led_zha.yaml
  domain: script
fields:
  switch:
    name: Inovelli VZM31-SN
    description: Which light switch to program
    required: true
    selector:
      device:
        integration: zha
        manufacturer: Inovelli
        model: VZM31-SN
  effect:
    name: Effect
    description: Effect to use
    required: true
    selector:
      select:
        options:
          - "Off"
          - "Clear"
          - "Solid"
          - "Fast Blink"
          - "Slow Blink"
          - "Pulse"
          - "Chase"
          - "Open-Close"
          - "Small-Big"

  duration:
    name: Duration
    description: How long the effect should last, in seconds (1-254, 255 for indefinite)
    required: true
    selector:
      number:
        min: 1
        max: 255
  level:
    name: Intensity
    description: How intense the light should be, percentage (0-100)
    required: true
    selector:
      number:
        min: 0
        max: 100
  color:
    name: Color
    description: The color the light should be, (0-254, 255 for white)
    required: true
    selector:
      number:
        min: 0
        max: 255

sequence:
  - choose:
      - conditions:
          - condition: template
            value_template: >
              {{ effect == "Off"}}
        sequence:
          - service: zha.issue_zigbee_cluster_command
            data:
              ieee: >
                {{ (device_attr(switch, "identifiers")|list).0.1 }}
              endpoint_id: 1
              cluster_id: 64561
              cluster_type: in
              command: 1
              command_type: server
              args:
                - 0
                - "{{ color }}"
                - "{{ level }}"
                - "{{ duration }}"
              manufacturer: 4655
      - conditions:
          - condition: template
            value_template: >
              {{ effect == "Clear"}}
        sequence:
          - service: zha.issue_zigbee_cluster_command
            data:
              ieee: >
                {{ (device_attr(switch, "identifiers")|list).0.1 }}
              endpoint_id: 1
              cluster_id: 64561
              cluster_type: in
              command: 1
              command_type: server
              args:
                - 255
                - "{{ color }}"
                - "{{ level }}"
                - "{{ duration }}"
              manufacturer: 4655
      - conditions:
          - condition: template
            value_template: >
              {{ effect == "Solid"}}
        sequence:
          - service: zha.issue_zigbee_cluster_command
            data:
              ieee: >
                {{ (device_attr(switch, "identifiers")|list).0.1 }}
              endpoint_id: 1
              cluster_id: 64561
              cluster_type: in
              command: 1
              command_type: server
              args:
                - 1
                - "{{ color }}"
                - "{{ level }}"
                - "{{ duration }}"
              manufacturer: 4655
      - conditions:
          - condition: template
            value_template: >
              {{ effect == "Fast Blink"}}
        sequence:
          - service: zha.issue_zigbee_cluster_command
            data:
              ieee: >
                {{ (device_attr(switch, "identifiers")|list).0.1 }}
              endpoint_id: 1
              cluster_id: 64561
              cluster_type: in
              command: 1
              command_type: server
              args:
                - 2
                - "{{ color }}"
                - "{{ level }}"
                - "{{ duration }}"
              manufacturer: 4655
      - conditions:
          - condition: template
            value_template: >
              {{ effect == "Slow Blink"}}
        sequence:
          - service: zha.issue_zigbee_cluster_command
            data:
              ieee: >
                {{ (device_attr(switch, "identifiers")|list).0.1 }}
              endpoint_id: 1
              cluster_id: 64561
              cluster_type: in
              command: 1
              command_type: server
              args:
                - 3
                - "{{ color }}"
                - "{{ level }}"
                - "{{ duration }}"
              manufacturer: 4655
      - conditions:
          - condition: template
            value_template: >
              {{ effect == "Pulse"}}
        sequence:
          - service: zha.issue_zigbee_cluster_command
            data:
              ieee: >
                {{ (device_attr(switch, "identifiers")|list).0.1 }}
              endpoint_id: 1
              cluster_id: 64561
              cluster_type: in
              command: 1
              command_type: server
              args:
                - 4
                - "{{ color }}"
                - "{{ level }}"
                - "{{ duration }}"
              manufacturer: 4655
      - conditions:
          - condition: template
            value_template: >
              {{ effect == "Chase"}}
        sequence:
          - service: zha.issue_zigbee_cluster_command
            data:
              ieee: >
                {{ (device_attr(switch, "identifiers")|list).0.1 }}
              endpoint_id: 1
              cluster_id: 64561
              cluster_type: in
              command: 1
              command_type: server
              args:
                - 5
                - "{{ color }}"
                - "{{ level }}"
                - "{{ duration }}"
              manufacturer: 4655
      - conditions:
          - condition: template
            value_template: >
              {{ effect == "Open-Close"}}
        sequence:
          - service: zha.issue_zigbee_cluster_command
            data:
              ieee: >
                {{ (device_attr(switch, "identifiers")|list).0.1 }}
              endpoint_id: 1
              cluster_id: 64561
              cluster_type: in
              command: 1
              command_type: server
              args:
                - 6
                - "{{ color }}"
                - "{{ level }}"
                - "{{ duration }}"
              manufacturer: 4655
      - conditions:
          - condition: template
            value_template: >
              {{ effect == "Small-Big"}}
        sequence:
          - service: zha.issue_zigbee_cluster_command
            data:
              ieee: >
                {{ (device_attr(switch, "identifiers")|list).0.1 }}
              endpoint_id: 1
              cluster_id: 64561
              cluster_type: in
              command: 1
              command_type: server
              args:
                - 7
                - "{{ color }}"
                - "{{ level }}"
                - "{{ duration }}"
              manufacturer: 4655

mode: single

This blueprint supports all the animations and settings indicated here, and best of all, only needs to be created once.


Since the script has no configuration variables, it’s a generic script that only needs to exist once.


Users can then indicate which switch they want to target with what effect, color, et. al on every call to the script.

6 Likes

Have made some updates to this blueprint, including adding single LED support, more effects and preset color profiles (e.g. rainbow). Since I can’t edit the post here, I’ll point you to the post on Home Assistant’s forum for the latest code: ZHA - Inovelli VZM31-SN Blue Series 2-1 Switch LED Notification Script - Blueprints Exchange - Home Assistant Community

1 Like