Skip to content

Commit

Permalink
Add IEKA Symfonisk Gen2 v1/v2 support (#2273)
Browse files Browse the repository at this point in the history
* Update __init__.py

* Update const.py

* Add files via upload

* Update __init__.py

* Update __init__.py

* Update symfonisk2.py

* Update __init__.py

* Update symfonisk2.py

* Update __init__.py

* Anti Pasta

* Use new IKEA power configuration clusters

* Remove stale import

* Rename constants, minor changes

* Remove `name` attribute from shortcut clusters

* Change quirk class names

---------

Co-authored-by: TheJulianJES <TheJulianJES@users.noreply.github.com>
  • Loading branch information
MattWestb and TheJulianJES authored Mar 25, 2023
1 parent deb0fd5 commit 38f6362
Show file tree
Hide file tree
Showing 3 changed files with 446 additions and 1 deletion.
9 changes: 9 additions & 0 deletions zhaquirks/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
COMMAND_FURIOUS = "furious"
COMMAND_HOLD = "hold"
COMMAND_ID = "command_id"
COMMAND_M_INITIAL_PRESS = "initial_press"
COMMAND_M_LONG_PRESS = "long_press"
COMMAND_M_LONG_RELEASE = "long_release"
COMMAND_M_MULTI_PRESS_COMPLETE = "multi_press_complete"
COMMAND_M_MULTI_PRESS_ONGOING = "multi_press_ongoing"
COMMAND_M_SHORT_RELEASE = "short_release"
COMMAND_M_SWLATCHED = "switch_latched"
COMMAND_MOVE = "move"
COMMAND_MOVE_COLOR_TEMP = "move_color_temp"
COMMAND_MOVE_ON_OFF = "move_with_on_off"
Expand Down Expand Up @@ -89,6 +96,7 @@
OUTPUT_CLUSTERS = SIG_EP_OUTPUT
PARAMS = "params"
PRESS_TYPE = "press_type"
PRESSED = "initial_switch_press"
PROFILE_ID = SIG_EP_PROFILE
QUADRUPLE_PRESS = "remote_button_quadruple_press"
QUINTUPLE_PRESS = "remote_button_quintuple_press"
Expand All @@ -103,6 +111,7 @@
ALT_SHORT_PRESS = "remote_button_alt_short_press"
SKIP_CONFIGURATION = SIG_SKIP_CONFIG
SHORT_RELEASE = "remote_button_short_release"
TOGGLE = "toggle"
TRIPLE_PRESS = "remote_button_triple_press"
TURN_OFF = "turn_off"
TURN_ON = "turn_on"
Expand Down
91 changes: 90 additions & 1 deletion zhaquirks/ikea/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
from zigpy.zcl.clusters.general import PowerConfiguration, Scenes
from zigpy.zcl.clusters.lightlink import LightLink

from zhaquirks import DoublingPowerConfigurationCluster
from zhaquirks import DoublingPowerConfigurationCluster, EventableCluster

_LOGGER = logging.getLogger(__name__)

IKEA = "IKEA of Sweden"
IKEA_CLUSTER_ID = 0xFC7C # decimal = 64636
WWAH_CLUSTER_ID = 0xFC57 # decimal = 64599 ('Works with all Hubs' cluster)

IKEA_SHORTCUT_CLUSTER_V1_ID = 0xFC7F # decimal = 64639 Shortcut V1 commands
IKEA_MATTER_SWITCH_CLUSTER_ID = 0xFC80 # decimal = 64640 Shortcut V2 commands
COMMAND_SHORTCUT_V1 = "shortcut_v1_events"

# PowerConfiguration cluster attributes
BATTERY_VOLTAGE = PowerConfiguration.attributes_by_name["battery_voltage"].id
BATTERY_SIZE = PowerConfiguration.attributes_by_name["battery_size"].id
Expand Down Expand Up @@ -81,6 +85,91 @@ class ScenesCluster(CustomCluster, Scenes):
)


class ShortcutV1Cluster(EventableCluster):
"""Ikea Shortcut Button Cluster Variant 1."""

cluster_id = IKEA_SHORTCUT_CLUSTER_V1_ID

server_commands = {
0x01: foundation.ZCLCommandDef(
COMMAND_SHORTCUT_V1,
{
"shortcut_button": t.int8s,
"shortcut_event": t.int8s,
},
False,
is_manufacturer_specific=True,
),
}


class ShortcutV2Cluster(EventableCluster):
"""Ikea Shortcut Button Cluster Variant 2."""

cluster_id = IKEA_MATTER_SWITCH_CLUSTER_ID

server_commands = {
0x00: foundation.ZCLCommandDef(
"switch_latched",
{
"new_position": t.int8s,
},
False,
is_manufacturer_specific=True,
),
0x01: foundation.ZCLCommandDef(
"initial_press",
{
"new_position": t.int8s,
},
False,
is_manufacturer_specific=True,
),
0x02: foundation.ZCLCommandDef(
"long_press",
{
"previous_position": t.int8s,
},
False,
is_manufacturer_specific=True,
),
0x03: foundation.ZCLCommandDef(
"short_release",
{
"previous_position": t.int8s,
},
False,
is_manufacturer_specific=True,
),
0x04: foundation.ZCLCommandDef(
"long_release",
{
"previous_position": t.int8s,
},
False,
is_manufacturer_specific=True,
),
0x05: foundation.ZCLCommandDef(
"multi_press_ongoing",
{
"new_position": t.int8s,
# "current_number_of_presses_counted": t.int8s, # not implemented
},
False,
is_manufacturer_specific=True,
),
0x06: foundation.ZCLCommandDef(
"multi_press_complete",
{
"previous_position": t.int8s,
"total_number_of_presses_counted": t.int8s,
},
False,
is_manufacturer_specific=True,
),
}


# ZCL compliant IKEA power configuration clusters:
class PowerConfig2AAACluster(CustomCluster, PowerConfiguration):
"""Updating power attributes: 2 AAA."""
Expand Down
Loading

0 comments on commit 38f6362

Please sign in to comment.