I had some interest and questions about this topic … there is a step-by-step guide including the code.
Prerequisites
- Visual Code Server Add-on:
It is recommended to install and use the Visual Code Server add-on for editing files. This add-on provides an integrated development environment within Home Assistant, making it easier to manage your configuration files.
Step-by-Step Guide
- Create the Directory
In your Home Assistant CONFIG
directory, create a new folder named custom_zha_quirks
.
2.Note:* If you already have a folder for custom quirks, you can skip this step and adjust the configuration in the next step accordingly.
- Update the Configuration
Open your configuration.yaml
file and add the following lines to tell Home Assistant where to find your custom quirks:
zha:
custom_quirks_path: /config/custom_zha_quirks/
- Initialize the Python Package
Inside the custom_zha_quirks
directory, create a file named __init__.py
. This file can remain empty, but it is required to mark the directory as a Python package.
- Copy the Quirk Code
Create a new file named phoscon_hive_quirk.py
in the custom_zha_quirks
directory and copy the following code into it:
Code phoscon_hive_quirk.py
:
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, PowerConfiguration, Identify, Groups, Scenes, OnOff, LevelControl, Ota, GreenPowerProxy
from zigpy.zcl.clusters.lighting import Color
class PhosconHive(CustomDevice):
"""Custom device representing Phoscon Hive."""
signature = {
"models_info": [("Phoscon", "Hive")],
"endpoints": {
1: {
"profile_id": 0x0104,
"device_type": 0x010d,
"input_clusters": [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id
],
"output_clusters": [
Ota.cluster_id,
],
},
242: {
"profile_id": 0xA1E0,
"device_type": 0x0061,
"input_clusters": [],
"output_clusters": [
GreenPowerProxy.cluster_id,
],
},
},
}
replacement = {
"endpoints": {
1: {
"profile_id": 0x0104,
"device_type": 0x010d,
"input_clusters": [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id
],
"output_clusters": [
Ota.cluster_id,
],
},
242: {
"profile_id": 0xA1E0,
"device_type": 0x0061,
"input_clusters": [],
"output_clusters": [
GreenPowerProxy.cluster_id,
],
},
},
}
def __init__(self, *args, **kwargs):
"""Initialize the device."""
super().__init__(*args, **kwargs)
self.node_desc.mac_capability_flags &= ~0b00000100 # Clear the mains powered bit
- Restart Home Assistant
After saving the changes, restart Home Assistant so that the new configuration is loaded and your custom quirk is applied.