Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IKEA Styrbar remote quirk #867

Merged
merged 3 commits into from
Aug 25, 2021
Merged

IKEA Styrbar remote quirk #867

merged 3 commits into from
Aug 25, 2021

Conversation

TheJulianJES
Copy link
Collaborator

@TheJulianJES TheJulianJES commented Apr 27, 2021

Fixes #863, fixes #975

Adds device automation triggers and doubles the power percentage.
Left/right click are apparently working now.

Like the IKEA shortcut button, this remote seems to generate multiple zha_events.
(At least for @MattWestb on a Silabs(?) coordinator. AFAIK, some people with a TI coordinator didn't have an issue with multiple events on the shortcut button.)
The "spamming" issue needs to be looked at later (for all newer IKEA remotes), but this isn't caused by the quirk.
(Reference: #967)

For now, this PR is ready for review.

More information:
#863 (comment)

@codecov-commenter
Copy link

codecov-commenter commented Apr 27, 2021

Codecov Report

Merging #867 (05c59d0) into dev (833c1b9) will increase coverage by 0.09%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #867      +/-   ##
==========================================
+ Coverage   82.50%   82.59%   +0.09%     
==========================================
  Files         185      190       +5     
  Lines        4589     4810     +221     
==========================================
+ Hits         3786     3973     +187     
- Misses        803      837      +34     
Impacted Files Coverage Δ
zhaquirks/ikea/fourbtnremote.py 100.00% <100.00%> (ø)
zhaquirks/xiaomi/mija/sensor_switch.py 58.69% <0.00%> (-12.28%) ⬇️
zhaquirks/const.py 100.00% <0.00%> (ø)
zhaquirks/lidl/cct.py 100.00% <0.00%> (ø)
zhaquirks/tuya/valve.py 95.52% <0.00%> (ø)
zhaquirks/tuya/ts0041.py 100.00% <0.00%> (ø)
zhaquirks/tuya/ts0601.py 100.00% <0.00%> (ø)
zhaquirks/philips/rwlfirstgen.py 100.00% <0.00%> (ø)
zhaquirks/tuya/thermostat_88teujp.py 53.94% <0.00%> (ø)
zhaquirks/tuya/ts0041_zemismart.py
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 833c1b9...05c59d0. Read the comment docs.

@coveralls
Copy link

coveralls commented Apr 27, 2021

Pull Request Test Coverage Report for Build 1075781775

  • 12 of 12 (100.0%) changed or added relevant lines in 1 file are covered.
  • 121 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.1%) to 82.599%

Files with Coverage Reduction New Missed Lines %
zhaquirks/xiaomi/mija/sensor_switch.py 16 58.7%
zhaquirks/tuya/init.py 105 72.43%
Totals Coverage Status
Change from base Build 788931381: 0.1%
Covered Lines: 3973
Relevant Lines: 4810

💛 - Coveralls

@Adminiuga
Copy link
Contributor

Is this still a draft?

@MattWestb
Copy link
Contributor

I have one in production and one in test system and the ground looks working OK for my = binding and reporting of light groups (great work @TheJulianJES !!).

Its spamming the network badly then setting up binding and reporting and perhaps need more default response for not doing that.

If binding one cluster = one unicast command sent.
If binding 3 cluster = 3 unicast commands sent.
Plus the broadcast to bonded group.

I think its more or less the same with Symphoisk sound controller and short cut button (newer SDK used then the "old" remotes).

I think the best was that you was having one for testing how its reacting for understanding the "personality" but if you like i can do all sniffing and config you need only saying wot you like to having.

@MattWestb
Copy link
Contributor

The commands for the next and privies scene is not working then they have changing the commands being sent and need being adopted for the automation part.
The new commands is in the #863.

@TheJulianJES
Copy link
Collaborator Author

Is this still a draft?

It's still unfinished. The left/right buttons aren't working apparently and I don't have one of these remotes (or time atm).
(The last commit 90bc62a doesn't seem to help.)

It can be directly bound to a device/group and I think the left/right arrow buttons might work when the "Zigbee scenes" are added to the device(?) (because only with the last commit the scenes cluster can be bound. Still not sure how much this helps)

I guess I could remove the device automation triggers for left/right arrow buttons, so users don't get confused why this functionality isn't working. Perhaps it could be merged to have a "basic implementation" for the device then. Left/right arrow buttons (and network spam) can be addressed later.

@MattWestb
Copy link
Contributor

The scenes buttons are working out of the box with CWS3 (they have different implanting of the default scenes) and very likely also if adding scenes to the "magic group" for older IKEA WS/CWS lights.

I have not testing binding the scene cluster to one group then i cant adding scenes in ZHA.

@MattWestb
Copy link
Contributor

By adding scene cluster (from IKEA quirk) like this in the replacement:

                OUTPUT_CLUSTERS: [
                    Identify.cluster_id,
                    ScenesCluster,
                    OnOff.cluster_id,
                    LevelControl.cluster_id,
                    Ota.cluster_id,
                    LightLink.cluster_id,
                ],

I starting getting real commands from the scenes buttons !!!
For the OnOff and level looks being OK with the imported one and for the scene its looks like:

right short
2021-07-15 13:11:46 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0005] ZCL request 0x0007: [256, 13, 0]
2021-07-15 13:11:46 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0005] No handler for cluster command 7

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "press",
        "args": [
            256,
            13,
            0
        ]
    },
	

Left short
2021-07-15 13:11:49 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0005] ZCL request 0x0007: [257, 13, 0]
2021-07-15 13:11:49 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0005] No handler for cluster command 7

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "press",
        "args": [
            257,
            13,
            0
        ]
    },
	

Right long
2021-07-15 13:20:13 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0005] ZCL request 0x0008: [3328, 0]
2021-07-15 13:20:13 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0005] No handler for cluster command 8

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "hold",
        "args": [
            3328,
            0
        ]
    },


Left long
2021-07-15 13:22:05 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0005] ZCL request 0x0008: [3329, 0]
2021-07-15 13:22:05 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0005] No handler for cluster command 8

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "hold",
        "args": [
            3329,
            0
        ]
    },

The IKEA scene is decoding the release OK as command 9 but with random parameters so not possible saying if right or left was released:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "release",
        "args": [
            327
        ]
    },

Its possible implanting logic for release right or left if ignoring the value 0x0000 that is sent for resetting the lights to default sens and light levels as is being done in the open/close button by remember that last long press command.

@TheJulianJES Is it one typo WWAH_CLUSTER_ID = 0xFC57 # decimal = 64599 or is it for not getting conflict with other IKEA devices that is using the normal IKEA cluster ?
I have testing with IKEA_CLUSTER_ID and its looks working OK.

@MattWestb
Copy link
Contributor

@Adminiuga I need help with the spamming from this remote ;-((
Its looks like this then sending one off command and have its configured and reporting attributes:

2021-07-15 14:59:57 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0006] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=False> manufacturer=None tsn=1 command_id=0>
2021-07-15 14:59:57 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0006] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=False> manufacturer=None tsn=1 command_id=0>
2021-07-15 14:59:57 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0006] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=False> manufacturer=None tsn=1 command_id=0>
2021-07-15 14:59:57 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0006] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=False> manufacturer=None tsn=1 command_id=0>
2021-07-15 14:59:57 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0006] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=False> manufacturer=None tsn=1 command_id=0>
2021-07-15 14:59:57 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0006] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=False> manufacturer=None tsn=1 command_id=0>

The hole sequenze looks like this for eatch command recived:

2021-07-15 14:59:57 DEBUG (MainThread) [bellows.ezsp.protocol] Application frame 69 (incomingMessageHandler) received: b'000401060001010001000031b8ca50eaffff0301010004'
2021-07-15 14:59:57 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=6, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY: 256>, groupId=0, sequence=49), 184, -54, 0xea50, 255, 255, b'\x01\x01\x00']
2021-07-15 14:59:57 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0006] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=False> manufacturer=None tsn=1 command_id=0>
2021-07-15 14:59:57 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0006] ZCL request 0x0000: []
2021-07-15 14:59:57 DEBUG (MainThread) [zigpy.zcl] [0xea50:1:0x0006] No handler for cluster command 0

So all transactions is with the same tsn !!
The remote is not bonded to one group then if its sending more commands to the group that is little bad for testing so only bonded to the coordinator for reporting = every bonded / attribute reporting cluster = one more set of commands is being sent.

Is the tuya version possible implanting and is the right way to going ?

"""Handle press_types command."""
# normally if default response sent, TS004x wouldn't send such repeated zclframe (with same sequence number),
# but for stability reasons (e. g. the case the response doesn't arrive the device), we can simply ignore it
if hdr.tsn == self.last_tsn:
_LOGGER.debug("TS004X: ignoring duplicate frame")
return
# save last sequence number
self.last_tsn = hdr.tsn
# send default response (as soon as possible), so avoid repeated zclframe from device
if not hdr.frame_control.disable_default_response:
self.debug("TS004X: send default response")
self.send_default_rsp(hdr, status=foundation.Status.SUCCESS)
# handle command
if hdr.command_id == 0xFD:
press_type = args[0]
self.listener_event(
ZHA_SEND_EVENT, self.press_type.get(press_type, "unknown"), []
)

Sorry for making more problems for you but its out of my (not very large) code knowledge but i think its many user that like getting this device being real supported (its working without quirk but not good and no device triggered ).

PS: i have not checking if the device is getting default response from the coordinator then my sniffer is running EZSP six ten for the moment.

@MattWestb
Copy link
Contributor

One new version if the quirk is posted here #863 (comment).

@Adminiuga
Copy link
Contributor

Make sure a default response is sent, which should be handled by zigpy, unless overriden by quirk

@MattWestb
Copy link
Contributor

MattWestb commented Jul 15, 2021

OK i downgrading one Billy for doing sniff with 15.4 support so being sure but its normal ZCL commands so shall being done buy the stack if not being disabled (that we dont have).

@MattWestb
Copy link
Contributor

I was wrong the remote was bonded to one group and was spamming the group like this:

No.	Time	Protocol	IEEE Src	IEEE Dst	Zigbee Src	Zigbee Dst	ZBN Dest	Group Nr	ZBN Seq	ZBA Seq	ZDP Seq	Nwk Seq	Info
1	14:07:37,319518	ZigBee HA	0xea50	0x881d	0xea50	0x0000	0x0000		85	87		244	ZCL OnOff: Off, Seq: 10
2	14:07:37,327777	ZigBee HA	0xea50	0x881d	0xea50	Broadcast	0xfffd	0xff09	86	88		245	ZCL OnOff: Off, Seq: 10
3	14:07:37,338411	ZigBee	0x881d	0x0000	0xea50	0x0000	0x0000		213			0	Route Record, Dst: 0x0000
4	14:07:37,347034	ZigBee HA	0xea50	0x881d	0xea50	Broadcast	0xfffd	0xff09	87	89		246	ZCL OnOff: Off, Seq: 10
5	14:07:37,356900	ZigBee HA	0x881d	0xffff	0xea50	Broadcast	0xfffd	0xff09	86	88		1	ZCL OnOff: Off, Seq: 10
6	14:07:37,369537	ZigBee HA	0xea50	0x881d	0xea50	0x0000	0x0000		89	90		247	ZCL OnOff: Off, Seq: 10
7	14:07:37,376642	ZigBee HA	0xae2b	0xffff	0xea50	Broadcast	0xfffd	0xff09	86	88		0	ZCL OnOff: Off, Seq: 10
8	14:07:37,387023	ZigBee HA	0xae2b	0xffff	0xea50	Broadcast	0xfffd	0xff09	87	89		1	ZCL OnOff: Off, Seq: 10
9	14:07:37,399306	ZigBee	0x881d	0x0000	0xea50	0x0000	0x0000		217			3	Route Record, Dst: 0x0000
10	14:07:37,408041	ZigBee HA	0xea50	0x881d	0xea50	0x0000	0x0000		93	92		249	ZCL OnOff: Off, Seq: 10
11	14:07:37,418950	ZigBee	0xefd5	0x0000	0xefd5	0x0000	0x0000		124			149	Route Record, Dst: 0x0000
12	14:07:37,431732	ZigBee	0x881d	0x0000	0xea50	0x0000	0x0000		219			4	Route Record, Dst: 0x0000
13	14:07:37,439525	ZigBee HA	0x881d	0x0000	0xea50	0x0000	0x0000		85	87		5	ZCL OnOff: Off, Seq: 10
14	14:07:37,451136	ZigBee	0x881d	0x0000	0xea50	0x0000	0x0000		221			6	Route Record, Dst: 0x0000
15	14:07:37,462851	ZigBee	0x881d	0x0000	0xea50	0x0000	0x0000		223			7	Route Record, Dst: 0x0000
16	14:07:37,471207	ZigBee HA	0xefd5	0x0000	0xefd5	0x0000	0x0000		123	230		151	ZCL: Report Attributes, Seq: 57
17	14:07:37,487133	ZigBee HA	0x881d	0x0000	0xea50	0x0000	0x0000		89	90		8	ZCL OnOff: Off, Seq: 10
18	14:07:37,490129	ZigBee HA	0xefd5	0xffff	0xea50	Broadcast	0xfffd	0xff09	87	89		152	ZCL OnOff: Off, Seq: 10
19	14:07:37,502755	ZigBee HA	0x5c1f	0x0000	0x5c1f	0x0000	0x0000		90	131		179	ZCL: Report Attributes, Seq: 25
20	14:07:37,509011	ZigBee HA	0x881d	0x0000	0xea50	0x0000	0x0000		91	91		9	ZCL OnOff: Off, Seq: 10
21	14:07:37,526704	ZigBee HA	0x5c1f	0xffff	0xea50	Broadcast	0xfffd	0xff09	87	89		180	ZCL OnOff: Off, Seq: 10
22	14:07:37,528998	ZigBee HA	0x881d	0x0000	0xea50	0x0000	0x0000		95	93		11	ZCL OnOff: Off, Seq: 10
23	14:07:37,536995	ZigBee HA	0x0000	0xefd5	0x0000	0xefd5	0xefd5		78	88		93	ZCL: Default Response, Seq: 57
24	14:07:37,553032	ZigBee	0xefd5	0x0000	0xefd5	0x0000	0x0000		125	88		153	APS: Ack, Dst Endpt: 1, Src Endpt: 1
25	14:07:37,608775	ZigBee	0xefd5	0xffff	0xefd5	Broadcast	0xfffc		126			154	Link Status
26	14:07:37,820070	ZigBee HA	0xae2b	0xffff	0xea50	Broadcast	0xfffd	0xff09	87	89		2	ZCL OnOff: Off, Seq: 10
27	14:07:37,842269	ZigBee HA	0x881d	0xffff	0xea50	Broadcast	0xfffd	0xff09	87	89		12	ZCL OnOff: Off, Seq: 10
28	14:07:37,853145	ZigBee HA	0x0000	0xffff	0xea50	Broadcast	0xfffd	0xff09	87	89		94	ZCL OnOff: Off, Seq: 10
29	14:07:37,862216	ZigBee HA	0x6701	0xffff	0xea50	Broadcast	0xfffd	0xff09	87	89		225	ZCL OnOff: Off, Seq: 10
30	14:07:37,910724	ZigBee HA	0x5c1f	0xffff	0xea50	Broadcast	0xfffd	0xff09	87	89		181	ZCL OnOff: Off, Seq: 10
31	14:07:38,302316	IEEE 802.15.4	0xea50	0x881d	0xea50	0x881d						251	Data Request
32	14:07:38,315059	ZigBee HA	0x0000	0xffff	0xea50	Broadcast	0xfffd	0xff09	87	89		95	ZCL OnOff: Off, Seq: 10
33	14:07:38,388950	ZigBee HA	0x5c1f	0xffff	0xea50	Broadcast	0xfffd	0xff09	87	89		182	ZCL OnOff: Off, Seq: 10
34	14:07:39,300055	IEEE 802.15.4	0xea50	0x881d	0xea50	0x881d						252	Data Request
35	14:07:39,805453	ZigBee	0x6701	0xffff	0x6701	Broadcast	0xfffc		205			226	Link Status
36	14:07:40,296227	IEEE 802.15.4	0xea50	0x881d	0xea50	0x881d						253	Data Request
37	14:07:41,587301	ZigBee HA	0x5c1f	0x0000	0x5c1f	0x0000	0x0000		93	132		183	ZCL: Report Attributes, Seq: 26
38	14:07:41,594223	ZigBee	0x0000	0x5c1f	0x0000	0x5c1f	0x5c1f		79	132		96	APS: Ack, Dst Endpt: 1, Src Endpt: 1

Then was resetting it and rejoining it was not spamming the group instead the coordinator that is not replaying with default response:

No.	Time	Protocol	IEEE Src	IEEE Dst	Zigbee Src	Zigbee Dst	ZBN Dest	Group Nr	ZBN Seq	ZBA Seq	ZDP Seq	Nwk Seq	Info
1	14:14:34,251484	ZigBee	0x6701	0xffff	0x6701	Broadcast	0xfffc		236			31	Link Status
2	14:14:35,881085	ZigBee	0xefd5	0xffff	0xefd5	Broadcast	0xfffc		182			252	Link Status
3	14:14:35,958750	ZigBee HA	0xacda	0xa69a	0xacda	0x0000	0x0000		192	21		107	ZCL OnOff: On, Seq: 11
4	14:14:35,966356	ZigBee HA	0xacda	0xa69a	0xacda	0x0000	0x0000		194	22		108	ZCL OnOff: On, Seq: 11
5	14:14:35,976637	ZigBee	0xa69a	0x0000	0xacda	0x0000	0x0000		64			214	Route Record, Dst: 0x0000
6	14:14:35,986328	ZigBee HA	0xacda	0xa69a	0xacda	0x0000	0x0000		196	23		109	ZCL OnOff: On, Seq: 11
7	14:14:35,999119	ZigBee	0xa69a	0x0000	0xacda	0x0000	0x0000		66			215	Route Record, Dst: 0x0000
8	14:14:36,006489	ZigBee HA	0xacda	0xa69a	0xacda	0x0000	0x0000		198	24		110	ZCL OnOff: On, Seq: 11
9	14:14:36,022813	ZigBee	0xa69a	0x0000	0xacda	0x0000	0x0000		68			216	Route Record, Dst: 0x0000
10	14:14:36,028356	ZigBee HA	0xacda	0xa69a	0xacda	0x0000	0x0000		200	25		111	ZCL OnOff: On, Seq: 11
11	14:14:36,038047	ZigBee	0xa69a	0x0000	0xacda	0x0000	0x0000		70			217	Route Record, Dst: 0x0000
12	14:14:36,050814	ZigBee	0xa69a	0x0000	0xacda	0x0000	0x0000		72			218	Route Record, Dst: 0x0000
13	14:14:36,058139	ZigBee HA	0xa69a	0x0000	0xacda	0x0000	0x0000		192	21		219	ZCL OnOff: On, Seq: 11
14	14:14:36,066833	ZigBee HA	0xa69a	0x0000	0xacda	0x0000	0x0000		194	22		220	ZCL OnOff: On, Seq: 11
15	14:14:36,080814	ZigBee HA	0xa69a	0x0000	0xacda	0x0000	0x0000		196	23		221	ZCL OnOff: On, Seq: 11
16	14:14:36,085447	ZigBee HA	0xa69a	0x0000	0xacda	0x0000	0x0000		198	24		222	ZCL OnOff: On, Seq: 11
17	14:14:36,096493	ZigBee HA	0xa69a	0x0000	0xacda	0x0000	0x0000		200	25		223	ZCL OnOff: On, Seq: 11
18	14:14:36,841296	ZigBee	0xa69a	0xffff	0xa69a	Broadcast	0xfffc		82			224	Link Status
19	14:14:36,945993	IEEE 802.15.4	0xacda	0xa69a	0xacda	0xa69a						112	Data Request
20	14:14:37,535240	ZigBee	0x0000	0xffff	0x0000	Broadcast	0xfffc		238			252	Link Status
21	14:14:37,942500	IEEE 802.15.4	0xacda	0xa69a	0xacda	0xa69a						113	Data Request
22	14:14:38,488080	ZigBee	0x881d	0xffff	0x881d	Broadcast	0xfffc		2			115	Link Status
23	14:14:38,661573	ZigBee	0x5c1f	0xffff	0x5c1f	Broadcast	0xfffc		134			247	Link Status
24	14:14:38,939507	IEEE 802.15.4	0xacda	0xa69a	0xacda	0xa69a						114	Data Request

And the first frame revived of the coordinator looks like this:

Frame 13: 112 bytes on wire (896 bits), 112 bytes captured (896 bits) on interface \Device\NPF_Loopback, id 0
Null/Loopback
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
User Datagram Protocol, Src Port: 17754, Dst Port: 17754
ZigBee Encapsulation Protocol, Channel: 15, Length: 48
IEEE 802.15.4 Data, Dst: 0x0000, Src: 0xa69a
ZigBee Network Layer Data, Dst: 0x0000, Src: 0xacda
    Frame Control Field: 0x0248, Frame Type: Data, Discover Route: Enable, Security Data
    Destination: 0x0000
    Source: 0xacda
    Radius: 29
    Sequence Number: 192
    [Extended Source: SiliconL_ff:fe:5f:89:0e (84:2e:14:ff:fe:5f:89:0e)]
    [Origin: 3]
    ZigBee Security Header
ZigBee Application Support Layer Data, Dst Endpt: 1, Src Endpt: 1
    Frame Control Field: Data (0x00)
        .... ..00 = Frame Type: Data (0x0)
        .... 00.. = Delivery Mode: Unicast (0x0)
        ..0. .... = Security: False
        .0.. .... = Acknowledgement Request: False
        0... .... = Extended Header: False
    Destination Endpoint: 1
    Cluster: On/Off (0x0006)
    Profile: Home Automation (0x0104)
    Source Endpoint: 1
    Counter: 21
ZigBee Cluster Library Frame
    Frame Control Field: Cluster-specific (0x01)
        .... ..01 = Frame Type: Cluster-specific (0x1)
        .... .0.. = Manufacturer Specific: False
        .... 0... = Direction: Client to Server
        ...0 .... = Disable Default Response: False
    Sequence Number: 11
    Command: On (0x01)

The remote is sending sequences 21, 22, 23, 24 and 25 before its parent have relayed the first unicast to the coordinator and its not reseeding the commands then its dot have getting any default response (that is have demanding to getting but is not missing) anf if it have re sending the commands it shall have being with the same sequence numbers (21-25) so its no prblem with that.

I was taking one look in SS5 and the parent is acking all commands from the remote in the IEEE 802.15.4 layer very nicely = OK.

So if we is forcing ZHA sending default response its not helping the unicast.
And from my sniff made before if doing more bindings or attribute reporting configs the remote is sending more commands (1 / configured cluster not only for unicast but also for broadcasts) so its not helping (the remote is having one very strong "personality" so must being "made in Sweden" like my) .
Also the bradcast spamming its not helping with default response then they is using passive acknowledge (is listening for its parent bradcasting the commands to the group and if its done its OK or its re sending the command).

And all commands is with the same sequence number (tsn in ZHA) so still getting the spamming until IKEA is fixing the firmware.

The Shortcut button and Symphonisk is having more or less the same "spamming" and if implanting tsn check its also being good doing it in there quirks 2 (and perhaps the old dimmer switch that is not working so well) but that is one later problem.

More thinking ?
Or do you need more information from sniffing and testing ?

Thanks in advance.

MW

@MattWestb
Copy link
Contributor

MattWestb commented Jul 28, 2021

@Adminiuga It looks like our TheJulianJES is on Holiday and more users is asking for support of this remote.

I have getting all device automation working and its also working OK bounded to one light group so its have the same status as the Shortcut button that is also spamming the network.

Shall i making one new PR for getting it true or can you patching this so its working OK or do you like waiting for TheJulianJES coming back ??

Mvh MW

Edit: Adding my quirk that is being used for some weeks:
fourbtnremote.zip

@TheJulianJES
Copy link
Collaborator Author

TheJulianJES commented Jul 28, 2021

@MattWestb Thanks for your work! Atm, I'm still kind of here.

These quirks seem to be pretty identical now. I noticed that I had the scenes cluster in the INPUT_CLUSTERS section rather than the OUTPUT_CLUSTERS section.

I still don't have a device to test with though. If you have some time, you can check if this works the same as your version now. (As they're a basically identical now, I'd assume so.)

To clarify, the device automations all work now, right? (Even the left/right buttons?)
The only issue is that under some circumstances, it still "spams" the network like the IKEA shortcut button?
(Spamming is unrelated to the quirk, even though it might be fixable through one.)

@MattWestb
Copy link
Contributor

Welcome back from your holiday i the other space ;-)

I downloading the quirk and installing it in my test setup and reporting back if i not must cutting away more of the sun-seal from the balcony then its full storm and 30° C with open sky here.

Do you knowing of the new manufacture cluster ID ? i was naming it 3 for the 3rd gen controllers so not mixing it up with the old / normal one if we start using it in the future for setting up "relative" scenes.

I´l bee back !!

@TheJulianJES
Copy link
Collaborator Author

Do you knowing of the new manufacture cluster ID ? i was naming it 3 for the 3rd gen controllers so not mixing it up with the old / normal one if we start using it in the future for setting up "relative" scenes.

0xFC57/64599 is the "Work With All Hubs" cluster IIRC.

@MattWestb
Copy link
Contributor

MattWestb commented Jul 28, 2021

Little events after much deleting spam:

On:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0006",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "on",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T17:45:39.478127+00:00",
    "context": {
        "id": "84b8a88ecb9d81ba3fc2e74ddab553b7",
        "parent_id": null,
        "user_id": null
    }
}

Off:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0006",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "off",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T17:46:17.705073+00:00",
    "context": {
        "id": "9c226628e50aa92f3a7473778ee976d2",
        "parent_id": null,
        "user_id": null
    }
}

Dim up:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0008",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 8,
        "command": "move_with_on_off",
        "args": [
            0,
            83
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T17:46:46.541964+00:00",
    "context": {
        "id": "33758be0eba10a250b33aebeacd89dce",
        "parent_id": null,
        "user_id": null
    }
}

Plus:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0008",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 8,
        "command": "stop",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T17:46:48.214966+00:00",
    "context": {
        "id": "c890c8692a784e226a7b536859efb14a",
        "parent_id": null,
        "user_id": null
    }
}

Dim down:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0008",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 8,
        "command": "move",
        "args": [
            1,
            83
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T17:48:01.117148+00:00",
    "context": {
        "id": "6206068038f7d35373f4ba2255e47af1",
        "parent_id": null,
        "user_id": null
    }
}

Plus:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0008",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 8,
        "command": "stop",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T17:48:02.305807+00:00",
    "context": {
        "id": "d9a6c4f1e423b87d2dc7071a01e629a7",
        "parent_id": null,
        "user_id": null
    }
}

Richt:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "press",
        "args": [
            256,
            13,
            0
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T17:48:54.932318+00:00",
    "context": {
        "id": "2807584ac35748fb69c0a6f6787bb4d6",
        "parent_id": null,
        "user_id": null
    }
}

Right long:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "release",
        "args": [
            28790
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T18:12:48.842360+00:00",
    "context": {
        "id": "94eb1149c470859c2c5f498071cbfe3b",
        "parent_id": null,
        "user_id": null
    }
}
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "release",
        "args": [
            0
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T18:16:31.923314+00:00",
    "context": {
        "id": "da86ecfa16062e6e17eadced678a817a",
        "parent_id": null,
        "user_id": null
    }
}
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0006",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "on",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T18:16:32.451830+00:00",
    "context": {
        "id": "4319ba7d0f8cae86be05d7591c26b5eb",
        "parent_id": null,
        "user_id": null
    }
}
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "press",
        "args": [
            2,
            0,
            0
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T18:16:32.980059+00:00",
    "context": {
        "id": "b9c9c222e28302948152e6e214cbbc29",
        "parent_id": null,
        "user_id": null
    }
}
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "hold",
        "args": [
            3328,
            0
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T18:16:33.866853+00:00",
    "context": {
        "id": "2eaf5a9263103cbaca1669547b1d5518",
        "parent_id": null,
        "user_id": null
    }
}

Relese:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "release",
        "args": [
            26921
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T18:17:07.790930+00:00",
    "context": {
        "id": "9273ab6f3cdfa93ff908cede4a4c934b",
        "parent_id": null,
        "user_id": null
    }
}

Left:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "press",
        "args": [
            257,
            13,
            0
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T17:54:28.399522+00:00",
    "context": {
        "id": "9cb2256f7ee72516bb7ca2d8c3d6ad91",
        "parent_id": null,
        "user_id": null
    }
}

Left long:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "release",
        "args": [
            0
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T18:25:08.627725+00:00",
    "context": {
        "id": "2c8f587e6a5a7366cadefcd5e28b49ba",
        "parent_id": null,
        "user_id": null
    }
}
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0006",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "on",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T18:25:09.138870+00:00",
    "context": {
        "id": "8994da5f112573db0bd23a09906f8876",
        "parent_id": null,
        "user_id": null
    }
}
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "press",
        "args": [
            2,
            0,
            0
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T18:25:09.635125+00:00",
    "context": {
        "id": "454cc97c695413a5a3243bc624395c05",
        "parent_id": null,
        "user_id": null
    }
}

    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "hold",
        "args": [
            3329,
            0
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T18:25:10.563096+00:00",
    "context": {
        "id": "755dbdee4fbcf24a637789d635b403a9",
        "parent_id": null,
        "user_id": null
    }
}


 Relese:
 {
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:5f:89:0e",
        "unique_id": "84:2e:14:ff:fe:5f:89:0e:1:0x0005",
        "device_id": "14c00f9f7f350057a29c75268ff7ad88",
        "endpoint_id": 1,
        "cluster_id": 5,
        "command": "release",
        "args": [
            15000
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2021-07-28T18:25:25.562798+00:00",
    "context": {
        "id": "a7429a958e1c767d83435a6b1482fde4",
        "parent_id": null,
        "user_id": null
    }
}

Shall being the same commands sequence that i have sniffed in #863 (comment) but i have not trying triggering device automatons on them.
But in automatons i have press and long press for right and left key, on, off and dim up and down.
For the moment they is not useful to using with all spam and also the new sequence for resetting the lights in the group that is implanted on left and right long press.

For my its looks OK until we is getting little antispamm implanted for IKEA devices.

Great thanks for implanting the quirk Julian !!!

@TheJulianJES TheJulianJES marked this pull request as ready for review July 28, 2021 19:57
@TheJulianJES
Copy link
Collaborator Author

This PR is ready to review/merge now.

Like the IKEA shortcut button, the remote seems to generate multiple zha_events for some poeple.
(AFAIK, some people with a TI coordinator didn't have an issue with multiple events on the shortcut button.)

The "spamming" issue needs to be looked at later (for all newer IKEA remotes), but this isn't caused by the quirk.

@MattWestb
Copy link
Contributor

@Adminiuga Do you have one MG21 board for your WSTK ?
Then its can being possible loading the dumped flash and user data on it and testing how its working without having the device.
I have not looking for the pin out but the SWD and HW reset is standard and and then its 4 buttons plus paring / SW reset and one LED so shall not being one big problem getting up and running on one test board.

Interested ?

@MattWestb
Copy link
Contributor

I think (without knowing as usual) that IT is doing the right thing, if one command is being revived with the same tsn (from the same device with same EP and cluster) with broad an / or unicast in one short time frame its shall being treated as one command and the rest commands shall filtered out and "spam" in the lowest possible layer in the system.

I think that shall being implanted in the radio libs or in zigpy layer for reusing the not needed commands sent between the layers in the system.

The funny thing if cooking one "LO controller bridge" in SS5 and doing multiple binding of one cluster the stack is sending * cluster bindings of the command to the destination also then doing group binding plus unicats bindings so its in the ground one Silabs Zigbee stack personality.

@dmulcahey dmulcahey merged commit 74ecdb9 into zigpy:dev Aug 25, 2021
@TheJulianJES TheJulianJES deleted the ikea_styrbar branch August 25, 2021 17:40
@VentiloFred
Copy link

Hello, i would to know what i need to do because i m lost in the different information.
I bought two Styrbar, everything work but after push long time the left button i lost the UP and Down function

How to use or install the quirk?

Home Assistant deConz

@MattWestb
Copy link
Contributor

MattWestb commented Nov 21, 2021

Is you using ZHA or deCONZ integration in HA ?

@VentiloFred
Copy link

Is you using ZHA or deCONZ integration in HA ?

I use deConz 6.10.0 in HA

@MattWestb
Copy link
Contributor

Then you need positing the ticket in https://github.com/dresden-elektronik/deconz-rest-plugin then this quirk is only working in ZHA and if you is using your deCONZ radio adapter with ZHA and not deCONZ integration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Device Support Request] IKEA TRADFRI W2045 - Solved! [Device Support Request] IKEA Remote N2 Styrbar
7 participants