Bug - Philips Dimmer V2 Restart Option Breaks With ZHA
Introduction
The Philips Dimmer v2 is a popular smart lighting device that integrates seamlessly with Home Assistant (HA) using the Zigbee Home Automation (ZHA) integration. However, a recent change in the ZHA device handlers has caused a bug that affects the restart option of the Philips Dimmer v2. In this article, we will delve into the issue, provide a detailed explanation, and offer a solution to resolve the problem.
Background
The Philips Dimmer v2 is a highly rated smart lighting device that offers a range of features, including dimming, color changing, and scene control. The device is compatible with Home Assistant, which allows users to control and automate their lighting using a user-friendly interface. The ZHA integration is a crucial component of this compatibility, enabling seamless communication between the Philips Dimmer v2 and Home Assistant.
The Bug
The bug in question is related to the restart option of the Philips Dimmer v2. Since the introduction of the ZHA device handlers' pull request #2340, the ZHA integration has been sending two events in quick succession, which can cause the current execution to be killed. This, in turn, can lead to the restart option not functioning as expected.
Automation YAML Config
The automation YAML config provided in the issue report is a crucial piece of information that helps us understand the problem. The config is as follows:
alias: Télécommande chambre bureau
description: ""
use_blueprint:
path: EPMatt/philips_929002398602.yaml
input:
integration: ZHA
controller_device: 8fd0ea26a00acb14a6aede353f98c83c
helper_last_controller_event: input_text.telecommande_chambre_bureau
action_button_on_short:
- data: {}
action: light.toggle
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
action_button_on_long:
- target:
entity_id: scene.bonne_nuit
metadata: {}
action: scene.turn_on
data: {}
action_button_up_short:
- data:
transition: 0.5
brightness_step_pct: 15
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
action: light.turn_on
action_button_up_long:
- data:
transition: 0.5
brightness_step_pct: 15
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
action: light.turn_on
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
action_button_down_short:
- data:
transition: 0.5
brightness_step_pct: -15
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
action: light.turn_on
action_button_down_long:
- data:
transition: 0.5
brightness_step_pct: -15
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
action: light.turn_on
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
button_up_long_loop: true
button_down_long_loop: true
To Reproduce
To reproduce the issue, follow these steps:
- Ensure you have the latest version of Home Assistant installed.
- Interact with the light using any command.
Expected Behavior
The expected behavior is that the light should follow the commands.
Actual Behavior
However, the actual behavior is that some commands do not reach the network in time, resulting in no action being taken.
Solution
To resolve this issue, we need to filter the events we want to process instead of taking everything and using the restart
option at any event. This can be achieved by modifying the automation YAML config to include a filter that checks for the specific events we want to process.
Here is an updated version of the automation YAML config that includes a filter:
alias: Télécommande chambre bureau
description: ""
use_blueprint:
path: EPMatt/philips_929002398602.yaml
input:
integration: ZHA
controller_device: 8fd0ea26a00acb14a6aede353f98c83c
helper_last_controller_event: input_text.telecommande_chambre_bureau
action_button_on_short:
- data: {}
action: light.toggle
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
filter:
event: 'on_short'
action_button_on_long:
- target:
entity_id: scene.bonne_nuit
metadata: {}
action: scene.turn_on
data: {}
filter:
event: 'on_long'
action_button_up_short:
- data:
transition: 0.5
brightness_step_pct: 15
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
action: light.turn_on
filter:
event: 'up_short'
action_button_up_long:
- data:
transition: 0.5
brightness_step_pct: 15
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
action: light.turn_on
filter:
event: 'up_long'
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
action_button_down_short:
- data:
transition: 0.5
brightness_step_pct: -15
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
action: light.turn_on
filter:
event: 'down_short'
action_button_down_long:
- data:
transition: 0.5
brightness_step_pct: -15
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
action: light.turn_on
filter:
event: 'down_long'
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
button_up_long_loop: true
button_down_long_loop: true
By including a filter in the automation YAML config, we can ensure that only the specific events we want to process are executed, preventing the restart option from being triggered unnecessarily.
Conclusion
Frequently Asked Questions
Q: What is the Philips Dimmer v2?
A: The Philips Dimmer v2 is a popular smart lighting device that integrates seamlessly with Home Assistant (HA) using the Zigbee Home Automation (ZHA) integration.
Q: What is the issue with the Philips Dimmer v2 restart option?
A: The issue is that the restart option of the Philips Dimmer v2 breaks with ZHA due to a bug in the ZHA device handlers. This bug causes the current execution to be killed, resulting in the restart option not functioning as expected.
Q: What is the cause of the bug?
A: The bug is caused by the ZHA device handlers sending two events in quick succession, which can cause the current execution to be killed.
Q: How can I reproduce the issue?
A: To reproduce the issue, follow these steps:
- Ensure you have the latest version of Home Assistant installed.
- Interact with the light using any command.
Q: What is the expected behavior?
A: The expected behavior is that the light should follow the commands.
Q: What is the actual behavior?
A: The actual behavior is that some commands do not reach the network in time, resulting in no action being taken.
Q: How can I resolve the issue?
A: To resolve the issue, you need to filter the events you want to process instead of taking everything and using the restart
option at any event. This can be achieved by modifying the automation YAML config to include a filter that checks for the specific events you want to process.
Q: What is the updated automation YAML config?
A: The updated automation YAML config includes a filter that checks for the specific events you want to process. Here is an example of the updated config:
alias: Télécommande chambre bureau
description: ""
use_blueprint:
path: EPMatt/philips_929002398602.yaml
input:
integration: ZHA
controller_device: 8fd0ea26a00acb14a6aede353f98c83c
helper_last_controller_event: input_text.telecommande_chambre_bureau
action_button_on_short:
- data: {}
action: light.toggle
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
filter:
event: 'on_short'
action_button_on_long:
- target:
entity_id: scene.bonne_nuit
metadata: {}
action: scene.turn_on
data: {}
filter:
event: 'on_long'
action_button_up_short:
- data:
transition: 0.5
brightness_step_pct: 15
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
action: light.turn_on
filter:
event: 'up_short'
action_button_up_long:
- data:
transition: 0.5
brightness_step_pct: 15
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
action: light.turn_on
filter:
event: 'up_long'
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
action_button_down_short:
- data:
transition: 0.5
brightness_step_pct: -15
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
action: light.turn_on
filter:
event: 'down_short'
action_button_down_long:
- data:
transition: 0.5
brightness_step_pct: -15
target:
device_id: 42ffe63edad8ebe5459e37e4f3b670d6
action: light.turn_on
filter:
event: 'down_long'
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
button_up_long_loop: true
button_down_long_loop: true
Q: Can I help develop a fix for this issue?
A: Yes, you can help develop a fix for this issue. If you are interested in contributing to the Home Assistant project, please visit the Home Assistant GitHub repository and submit a pull request with your proposed fix.
Q: Where can I find more information about this issue?
A: You can find more information about this issue on the Home Assistant GitHub repository and on the Home Assistant community forums.