Open phbasler opened 1 year ago
I managed to activatee the candle effect using the ZCL command documented on here, on the following bulbs:
The following light does not seem to support the effect (tested with Hue app):
I could give it a go to develop a quirk, but it would be helpful if someone could point me to one (for other things) that also add an effect.
(the firmware versions are actually also documented here ... )
Perhaps these issues would contain code that could be a good start? https://github.com/zigpy/zha-device-handlers/pull/993 https://github.com/zigpy/zha-device-handlers/issues/769 I've never written a quirk so I'm not really sure. I did test out the ZCL command on my LCA006 bulb with firmware 1.104.2 and it worked great. It would be nice to also have fireplace. I believe there's a number of other ones as well.
Ah cool, thanks, will have a look at it.
Next to the candle effect, there is fireplace and "prism", which is basically color loop. They are documented here as well: https://github.com/Koenkk/zigbee2mqtt/issues/15699. Others are not available even in the Hue app.
Regarding the ZCL command, @BenJamesAndo, did you use the built-in zha.issue_zigbee_cluster_command or zha_toolkit.zcl_cmd, provided by zha_toolkit? Because the former didn't work for me.
I used zha_toolkit.zcl_cmd. I tried zha.issue_zigbee_cluster_command just now but I got an Unknown error.
I used zha_toolkit.zcl_cmd. I tried zha.issue_zigbee_cluster_command just now but I got an Unknown error.
I also got an "Unknown error" using the zha.issue_zigbee_cluster_command
, but I was able to issue an identify command for the light using the same, so I wonder if I got some parameters wrong. I've used:
IEEE: Copied from Device page Endpoint ID: 11 (Copied from Manage zigbee device dialog) Cluster ID: 64515 (decimal for 0xfc03) Cluster Type: in Command: 0 (can be seen on the capture here) Command Type: Server (this is the correct one that worked with identify)
And then I couldn't figure out Args
or Params
. I've used couple thing in Params
, such as {multicolor: 0x21000101}
, {multicolor: 21000101}
or {multicolor: "21000101"}
, trying to emulate what people did with zigbee2mqtt, but none of those worked.
I was wondering if you (@BenJamesAndo) have figured out what to put there, since you say you tested the ZCL command and it worked for you, even though using zha_toolkit.
I unfortunately didn't make any progress beyond what anyone else has done. I only got zha_toolkit.zcl_cmd
to work as others have, and never got anything out of zha.issue_zigbee_cluster_command
.
I only got zha_toolkit.zcl_cmd to work as others have
Could you point me to where this was described originally then? Because I either can't find it or am overlooking it.
service: zha_toolkit.zcl_cmd
data:
manf: 4107
ieee: light.philips_go_light
endpoint: 11
cluster: 0xfc03
dir: 0
cmd: 0x00
args:
- 0x21
- 0x00
- 0x01
- 0x01
Change IEEE to your device. The below code is what I used to active Candle effect.
service: zha_toolkit.zcl_cmd
data:
ieee: light.signify_netherlands_b_v_lca006_light
manf: 4107
endpoint: 11
cluster: 64515
dir: 0
cmd: 0
args:
- 33
- 0
- 1
- 1
It doesn't seem to work with zha.issue_zigbee_cluster_command
. My wild guess is that it has to do with the manf
argument. Using zha_toolkit.zcl_cmd
, it only works with this argument, and not without. If I use zha.issue_zigbee_cluster_command
in the development page, it always converts the manf
value to a string, which may not be what's expected.
I've tracked down why this doesn't work with zha.issue_zigbee_cluster_command
with help of logs. The thing tries to use the command
as index to the commands
hash-table but it doesn't know about any commands (otherwise I'd just use the "Manage Zigbee Device" dialog to issue a command). So it fails with error:
File "/usr/src/homeassistant/homeassistant/components/zha/core/device.py", line 824, in issue_cluster_command
[field.name for field in commands[command].schema.fields],
~~~~~~~~^^^^^^^^^
KeyError: 1
Unfortunately unless ZHA is made aware of the possibility to send command to that cluster, it is not possible to use it. The difference with zha_toolkit
is that it probably just fires away and hopes for the best.
Ah cool, interesting. This probably brings us back to the quirk we need ...
I've successfully created a quirk that works with Philips Go to set the candlelight and fireplace effects, though I still have to find how to make it more user friendly (preset values, even getting it to the effect dropdown). For now I was testing it just by editing files in my docker deployment under /usr/local/lib/python3.11/site-packages/zhaquirks/philips
(requires HA restart afterwards).
In __init.py__
goes:
class PhilipsEffectCluster(CustomCluster):
"""PhilipsEffectCluster."""
cluster_id = 0xFC03
ep_attribute = "philips_effect"
name = "PhilipsEffect"
server_commands = {
0x00: foundation.ZCLCommandDef(
"set_effect",
schema={
"param1": t.uint8_t,
"param2": t.uint8_t,
"param3": t.uint8_t,
"param4": t.uint8_t,
},
direction=foundation.Direction.Client_to_Server,
is_manufacturer_specific=True,
)
}
and then created new file 7602031P7.py
:
"""Philips Go 7602031P7 device."""
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
Scenes,
)
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.philips import (
PHILIPS,
PhilipsEffectCluster,
)
class Philips7602031P7(CustomDevice):
"""Philips 7602031P7 device."""
signature = {
MODELS_INFO: [
(PHILIPS, "7602031P7"),
],
ENDPOINTS: {
11: {
# SizePrefixedSimpleDescriptor(endpoint=11, profile=260, device_type=268, device_version=1, input_clusters=[0, 3, 4, 5, 6, 8, 768, 4096, 64513, 64515], output_clusters=[25])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.EXTENDED_COLOR_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
LightLink.cluster_id,
64513,
64515,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
# SizePrefixedSimpleDescriptor(endpoint=242, profile=41440, device_type=97, device_version=0, input_clusters=[], output_clusters=[33])
242: {
PROFILE_ID: 41440,
DEVICE_TYPE: 97,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
11: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.EXTENDED_COLOR_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
LightLink.cluster_id,
64513,
PhilipsEffectCluster,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
242: {
PROFILE_ID: 41440,
DEVICE_TYPE: 97,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
}
}
which gets you something like this, where you can set the 4 numbers from args per parameter (33, 0, 1, 1) and send the command.
So if I understand this correctly, making HA understand that there's a command in the cluster is as far as zigpy can take things. To be able to set the effect via dropdown in the HA UI, one would need to implement special class of LightEntity for HA (link).
Currently, Philips Go (and I'm not sure there's example of a Zigbee bulb that does so differently) will register as Light class defined here, which is a subclass of BaseLight defined here, which finally implements the LightEntity mentioned above.
The Light class currently doesn't support any other effects other than colorloop
added here.
But what may be interesting is few lines of code almost obscured by all the other code. This looks like a further subclass of the Light
class that is applied only based on some exact match of clusters and manufacturers. I wonder if we would be able to implement another such subclass, that would only match when PhilipsEffectCluster
implemented in previous comment is present. There we could insert the additional effects to effect_list. That would take care of at least the UI side, now just missing the linking piece where setting the effect would trigger ZHA command with exact arguments 🤔
Think I found the missing link. Just going to write it all out here in case I forget, or somebody wants to do this before I have time :).
For a second, I'll use occupancy sensor as cluster example since it's much easier to search for across repositories than light bulb. In this repo, with zhaquirks, custom cluster PhilipsOccupancySensing is defined. Important is what's stored in ep_attribute = "philips_occupancy"
. This is then matched on the HA side with CLUSTER_HANDLER constant. Finally, this can be then used to implement the new class matching the cluster.
Then, back to light as example, one can get the cluster handler like this. The cluster handler is another class, specifically for the CLUSTER_HANDLER_COLOR
it's this one. I've linked the color_loop_supported
on purpose, since it is exactly the condition I've linked in previous comment where colorloop
is added, confirming we are looking at the correct thing. But now a big assumption - I think we don't need to write our own cluster handler, it should exist based on the quirk we defined earlier, otherwise it's a strange duplication.
The last step is figuring out what's the interface to issue the set_effect
command we defined on our cluster and pass the arguments, but I think I'll have to do some live debugging to answer that.
The assumption regarding cluster being automatically created for us is correct. But the cluster is only passed in cluster_handlers
when it is explicitly being matched against. Also thanks to the existing HueLight
class, we need to specify the manufacturer, otherwise the HueLight
match gets precedence (the logic is here).
So far I have hacked this into my HA zha/light.py
:
@STRICT_MATCH(
cluster_handler_names=CLUSTER_HANDLER_ON_OFF,
aux_cluster_handlers={CLUSTER_HANDLER_COLOR, CLUSTER_HANDLER_LEVEL, "philips_effect"},
manufacturers={"Philips", "Signify Netherlands B.V."},
)
class EffectHueLight(Light):
"""Representation of a HUE light with effects."""
def __init__(
self, unique_id, zha_device: ZHADevice, cluster_handlers, **kwargs
) -> None:
"""Initialize the ZHA light."""
super().__init__(unique_id, zha_device, cluster_handlers, **kwargs)
h = self.cluster_handlers.get("philips_effect")
self.error("Effect Handler: %s, %s", str(h), dir(h))
The cluster definition looks like this:
2024-02-16 18:17:22.824 ERROR (MainThread) [homeassistant.components.zha.entity] None: Effect Handler: <homeassistant.components.zha.core.cluster_handlers.ClusterHandler object at 0x7f6c01a3e0d0>, ['BIND', 'REPORT_CONFIG', 'ZCL_INIT_ATTRS', '__annotations__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_cluster', '_configure_reporting_status', '_endpoint', '_generic_id', '_get_attribute_name', '_get_attributes', '_id', '_status', '_unique_id', 'async_configure', 'async_initialize', 'async_send_signal', 'async_update', 'attribute_updated', 'bind', 'cluster', 'cluster_command', 'configure_reporting', 'data_cache', 'debug', 'error', 'generic_id', 'get_attribute_value', 'get_attributes', 'id', 'info', 'log', 'matches', 'name', 'status', 'unique_id', 'warning', 'write_attributes_safe', 'zdo_command', 'zha_send_event']
I'm thinking h.zha_send_event("set_effect", [33, 0, 1, 1])
should work. Not sure if it's correct though, as the function is decorated as callback.
Got a working prototype, I'll try to open up PRs both on zigpy and HA sides to integrate this in:
Just found out interesting information playing with the new quirk.
param1
is set to 33
, param3
controls on(1)/off(0) and param4
is effect ID that seems to go until 8 - funny because Philips app exposes only 3 effect - candle(1), fireplace(2) and prism(3). 8 is another candle-like effect, the 4,5,6,7 are some specific color tranisitions, like warm tones, cold tones,...param1
to 34
instead of 33
, then param3
controls brightness (cannot be 0), param4
same as before effect ID.I managed to activatee the candle effect using the ZCL command documented on here, on the following bulbs:
* LCT015, with bulb firmware 1.108.7, but not with 1.101.2 * LCT012, with bulb firmware 1.108.7, but not with 1.88.1 * LTO001, with bulb firmware 1.104.2 * 440400982842 (Playbar), with firmware 1.104.2 * LLC020, with firmware 67.101.2 * 1742830P7 (Lily), with 1.104.2, but not with 1.82.10 * LCL003 (Outdoor Lightstrip), with 1.93.7, but not 1.66.6
The following light does not seem to support the effect (tested with Hue app):
* LST002 (light strip), with firmware: 1.101.2 * LCT024 (Playbar), with firmware 1.108.5
I could give it a go to develop a quirk, but it would be helpful if someone could point me to one (for other things) that also add an effect.
(the firmware versions are actually also documented here ... )
Sorry for ping, facing same issue with fireplace after having 20 of the Playbars in my home. It is nice to have effect. I have Playbar with firmware "[1.104.2]" which support Fireplace..
Is there any way to downgrade the firmware ?
Wouldn't that be an upgrade? From 1.104.2 to 1.108.5?
Seen that the pull request didn't get anywhere and any help from that perspective is beyond me but would really like to see this implemented.
Problem description
I have two Hue Go here which have a built in canlde effect. According to https://github.com/Koenkk/zigbee2mqtt/issues/15699 it is possible to start this by sending certain commands to the cluster
0xfc03
.This cluster supports the Canlde effect, the fireplace effect and also the color loop. On my device page for the light I can only see the color loop effect.
If I go to manage zigbee device from the device page, then I don't have this cluster, only
0xfc01
in that range. Is there a possibility to add these effects to zha so that we can call them from Home Assistant?Solution description
Some possibility to trigger the candle effect of the hue go through a script.
Screenshots/Video
Screenshots/Video
![image](https://github.com/zigpy/zha-device-handlers/assets/28863303/d2c3cf8c-40ac-43c3-931a-9f5c70e2f5f0)Device signature
Device signature
```json { "node_descriptor": "NodeDescriptor(logical_type=Diagnostic information
Diagnostic information
```json { "home_assistant": { "installation_type": "Home Assistant Container", "version": "2023.8.1", "dev": false, "hassio": false, "virtualenv": false, "python_version": "3.11.4", "docker": true, "arch": "aarch64", "timezone": "Europe/Berlin", "os_name": "Linux", "os_version": "6.1.21-v8+", "run_as_root": true }, "custom_components": { "cryptoinfo": { "version": "0.1.7", "requirements": [] }, "hacs": { "version": "1.32.1", "requirements": [ "aiogithubapi>=22.10.1" ] }, "thermal_comfort": { "version": "2.1.1", "requirements": [] }, "xiaomi_miio_airpurifier": { "version": "2023.6.0.0", "requirements": [ "construct==2.10.56", "python-miio>=0.5.12" ] }, "blitzortung": { "version": "1.0.1", "requirements": [ "paho-mqtt>=1.5.0" ] }, "babybuddy": { "version": "v0.0.0", "requirements": [] }, "philips_airpurifier_coap": { "version": "0.10.8", "requirements": [ "aioairctrl==0.2.4" ] }, "ytube_music_player": { "version": "20230321.01", "requirements": [ "ytmusicapi==0.25.0", "pytube==10.5.1", "integrationhelper==0.2.2" ] }, "powercalc": { "version": "v1.8.8", "requirements": [ "numpy>=1.21.1" ] } }, "integration_manifest": { "domain": "zha", "name": "Zigbee Home Automation", "after_dependencies": [ "onboarding", "usb" ], "codeowners": [ "@dmulcahey", "@adminiuga", "@puddly" ], "config_flow": true, "dependencies": [ "file_upload" ], "documentation": "https://www.home-assistant.io/integrations/zha", "iot_class": "local_polling", "loggers": [ "aiosqlite", "bellows", "crccheck", "pure_pcapy3", "zhaquirks", "zigpy", "zigpy_deconz", "zigpy_xbee", "zigpy_zigate", "zigpy_znp" ], "requirements": [ "bellows==0.35.8", "pyserial==3.5", "pyserial-asyncio==0.6", "zha-quirks==0.0.102", "zigpy-deconz==0.21.0", "zigpy==0.56.4", "zigpy-xbee==0.18.1", "zigpy-zigate==0.11.0", "zigpy-znp==0.11.4" ], "usb": [ { "vid": "10C4", "pid": "EA60", "description": "*2652*", "known_devices": [ "slae.sh cc2652rb stick" ] }, { "vid": "1A86", "pid": "55D4", "description": "*sonoff*plus*", "known_devices": [ "sonoff zigbee dongle plus v2" ] }, { "vid": "10C4", "pid": "EA60", "description": "*sonoff*plus*", "known_devices": [ "sonoff zigbee dongle plus" ] }, { "vid": "10C4", "pid": "EA60", "description": "*tubeszb*", "known_devices": [ "TubesZB Coordinator" ] }, { "vid": "1A86", "pid": "7523", "description": "*tubeszb*", "known_devices": [ "TubesZB Coordinator" ] }, { "vid": "1A86", "pid": "7523", "description": "*zigstar*", "known_devices": [ "ZigStar Coordinators" ] }, { "vid": "1CF1", "pid": "0030", "description": "*conbee*", "known_devices": [ "Conbee II" ] }, { "vid": "10C4", "pid": "8A2A", "description": "*zigbee*", "known_devices": [ "Nortek HUSBZB-1" ] }, { "vid": "0403", "pid": "6015", "description": "*zigate*", "known_devices": [ "ZiGate+" ] }, { "vid": "10C4", "pid": "EA60", "description": "*zigate*", "known_devices": [ "ZiGate" ] }, { "vid": "10C4", "pid": "8B34", "description": "*bv 2010/10*", "known_devices": [ "Bitron Video AV2010/10" ] } ], "zeroconf": [ { "type": "_esphomelib._tcp.local.", "name": "tube*" }, { "type": "_zigate-zigbee-gateway._tcp.local.", "name": "*zigate*" }, { "type": "_zigstar_gw._tcp.local.", "name": "*zigstar*" }, { "type": "_slzb-06._tcp.local.", "name": "slzb-06*" } ], "is_built_in": true }, "data": { "ieee": "**REDACTED**", "nwk": 14994, "manufacturer": "Philips", "model": "LCT026", "name": "Philips LCT026", "quirk_applied": false, "quirk_class": "zigpy.device.Device", "manufacturer_code": 4107, "power_source": "Mains", "lqi": 136, "rssi": -66, "last_seen": "2023-08-09T10:44:37", "available": true, "device_type": "Router", "signature": { "node_descriptor": "NodeDescriptor(logical_type=Logs
Logs
```python [Paste the logs here] ```Custom quirk
Custom quirk
```python [Paste your custom quirk here] ```Additional information
No response