Overview
When using a Shelly Wave i4 or another Shelly Wave device that sends scene events in Home Assistant, an automation may not trigger correctly if it checks the stored state of the event entity.
The device may still send the scene events correctly, but the automation may not react as expected.
This can happen when the automation checks the last stored event state instead of checking which event actually triggered the automation.
Affected setup
This article applies to setups using:
Shelly Wave i4
Shelly Wave devices with scene event support
Home Assistant
Z-Wave JS / Z-Wave JS UI
Automations using event entities
Momentary switches or push buttons connected to SW inputs
Typical symptoms
The following behavior may be observed:
Single press works the first time but does not always work again.
Double press works only after another event type was received.
Repeated same button presses do not always trigger the automation.
One input appears to trigger the action of another input.
The device events are visible, but the automation does not run correctly.
Home Assistant may show that a condition did not pass.
The device itself appears to report the button press correctly.
Example behavior:
| Physical action | Event type | Automation result |
|---|---|---|
| First single press | KeyPressed | Triggers |
| Second single press | KeyPressed | May not trigger |
| Third single press | KeyPressed | May not trigger |
| First double press | KeyPressed2x | Triggers |
| Second double press | KeyPressed2x | May not trigger |
| Next single press | KeyPressed | Triggers again |
This can make it look like the device is sending the wrong input event, but the issue may be in the automation logic.
Why this happens
In Home Assistant, scene events from Z-Wave devices can be represented as event entities. If the automation uses a state condition to check the event entity attribute, it may check the stored state of the entity instead of the new event that started the automation. This means the automation may compare old event data and not the actual trigger. Because of this, repeated events of the same type may not be processed correctly.
Incorrect automation logic
The problem is commonly caused by automations that use a general event trigger and then check event entities with state conditions.
Example of problematic logic:
triggers:
- trigger: event.received
target:
device_id: DEVICE_ID
options:
event_type:
- KeyPressed
- KeyPressed2x
- KeyHeldDown
- KeyReleased
actions:
- choose:
- conditions:
- condition: state
entity_id: event.input_1_scene
state:
- KeyPressed
attribute: event_type
sequence:
- action: light.toggle
target:
entity_id: light.example_light_1
- conditions:
- condition: state
entity_id: event.input_2_scene
state:
- KeyPressed
attribute: event_type
sequence:
- action: light.toggle
target:
entity_id: light.example_light_2This type of automation can fail because the choose conditions check the stored event entity state, not necessarily the event that triggered the automation.
Recommended solution
Use separate triggers for each input and event type. Each trigger should have its own trigger ID. Then, in the action section, use a trigger condition to decide which action must run. This makes the automation react to the actual event that triggered it.
Correct automation example
The example below uses general names and can be adapted to your own devices and entities.
alias: Shelly Wave i4 Scene Control
description: ""
triggers:
- trigger: event.received
id: input_1_single
target:
entity_id: event.input_1_scene
options:
event_type:
- KeyPressed
- trigger: event.received
id: input_2_single
target:
entity_id: event.input_2_scene
options:
event_type:
- KeyPressed
- trigger: event.received
id: input_1_double
target:
entity_id: event.input_1_scene
options:
event_type:
- KeyPressed2x
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id: input_1_single
sequence:
- action: light.toggle
target:
entity_id: light.example_light_1
data:
brightness_pct: 50
transition: 1
- conditions:
- condition: trigger
id: input_2_single
sequence:
- action: light.toggle
target:
entity_id: light.example_light_2
data:
brightness_pct: 50
transition: 1
- conditions:
- condition: trigger
id: input_1_double
sequence:
- action: light.turn_on
target:
entity_id: light.example_light_1
data:
transition: 2
brightness_pct: 100
mode: singleWhy this solution works
This automation does not check the old stored state of the event entity. Instead, it checks the trigger ID.
For example:
If input 1 sends a single press, the trigger ID is
input_1_single.If input 2 sends a single press, the trigger ID is
input_2_single.If input 1 sends a double press, the trigger ID is
input_1_double.
The action then runs based on the exact trigger that started the automation. This makes the automation more reliable and avoids confusion between inputs or repeated event types.
How to adapt the example
Replace the following values with your own Home Assistant entities:
| Example value | Replace with |
|---|---|
| event.input_1_scene | Event entity for input 1 |
| event.input_2_scene | Event entity for input 2 |
| light.example_light_1 | Device or light controlled by input 1 |
| light.example_light_2 | Device or light controlled by input 2 |
You can add more triggers for other event types, such as:
KeyPressed
KeyPressed2x
KeyPressed3x
KeyHeldDown
KeyReleased
Each event type should have its own trigger ID.
Example with more inputs
For devices with more inputs, such as SW3 or SW4, add more triggers.
Example:
- trigger: event.received
id: input_3_single
target:
entity_id: event.input_3_scene
options:
event_type:
- KeyPressed
Then add the matching action:
- conditions:
- condition: trigger
id: input_3_single
sequence:
- action: switch.toggle
target:
entity_id: switch.example_output_3Recommended troubleshooting steps
If the automation does not work correctly, check the following:
Confirm that the device is included correctly in Home Assistant.
Confirm that the event entities are created for the inputs.
Press each physical input and check which event entity changes.
Check the event type, such as KeyPressed or KeyPressed2x.
Avoid using stored state conditions for scene event decisions.
Use separate
event.receivedtriggers with trigger IDs.Use
condition: triggerin the choose action.Test one input and one event type first.
Add more inputs and event types after the first test works.
How to confirm that the device reports correctly
To check if the Shelly Wave device sends the correct events:
Open Home Assistant.
Go to Developer Tools.
Open Events or States, depending on your setup.
Press the physical button connected to the Shelly Wave input.
Check if the correct event entity and event type are shown.
If the correct event is shown, but the automation does not run correctly, the issue is most likely in the automation logic.
Important note
This issue does not always mean that the Shelly Wave device is sending the wrong input. In many cases, the device sends the scene event correctly, but the automation reads the stored event entity state in a way that causes wrong or missed actions. Using trigger IDs is the recommended method because it reacts to the actual event that started the automation.
Summary
When using Shelly Wave i4 scene events in Home Assistant, avoid using state conditions to check the stored event entity attribute. Instead, create a separate event.received trigger for each input and event type. Then use condition: trigger with trigger IDs in the choose action. This makes the automation more stable and prevents repeated button events or different inputs from being processed incorrectly.