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

Niko 552-721X2 endpoint actions not working #13737

Closed
sephiroth1395 opened this issue Aug 28, 2022 · 114 comments
Closed

Niko 552-721X2 endpoint actions not working #13737

sephiroth1395 opened this issue Aug 28, 2022 · 114 comments
Labels
problem Something isn't working stale Stale issues

Comments

@sephiroth1395
Copy link

What happened?

In both control_relay and decoupled modes, the actions remains null on both endpoints L1 and L2 when I activate the switches physically. When in control_relay mode, the relays do operate when pressing the button so I have every reason to believe the device is not broken. It is brand new.

I can see a single "single, hold or release" action exposed in Home Assistant at device level instead of the l1 and l2 endpoints.

What did you expect to happen?

See the single, hold and release actions exposed.

How to reproduce it (minimal and precise)

Push any switch of the device.

Zigbee2MQTT version

1.27.0

Adapter firmware version

20210708

Adapter

Sonoff USB Dongle

Debug log

No response

@sephiroth1395 sephiroth1395 added the problem Something isn't working label Aug 28, 2022
@sjorge
Copy link
Contributor

sjorge commented Aug 29, 2022

Is it just home assistant not seeing the actions because it might be looking in the wrong property, or are you not getting them via mqtt either?

@sephiroth1395
Copy link
Author

sephiroth1395 commented Aug 30, 2022

Okay, just had a better look at this to answer your question.

Current configuration of the device:
{ "linkquality": 60, "operation_mode": "decoupled", "operation_mode_l1_l1": "control_relay", "operation_mode_l2_l2": "decoupled", "state_l1": "OFF", "state_l2": "OFF" }

When pressing the left button, I see these events in the Z2M logs:

`Zigbee2MQTT:info 2022-08-30 11:40:52: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action_l1":null,"action_l2":null,"linkquality":63,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"ON","state_l2":"OFF"}'

Zigbee2MQTT:info 2022-08-30 11:40:54: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action_l1":null,"action_l2":null,"linkquality":54,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'

Zigbee2MQTT:info 2022-08-30 11:40:55: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action_l1":null,"action_l2":null,"linkquality":63,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"ON","state_l2":"OFF"}'

Zigbee2MQTT:info 2022-08-30 11:40:56: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action_l1":null,"action_l2":null,"linkquality":60,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'

You can see the action_l1 attribute remains to null. Z2M appears to see the relay event, but not the button click themselves.

What's even weirder is this. When I press the right button, I see these events in the Z2M log:

Zigbee2MQTT:info 2022-08-30 11:45:28: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action_l1":null,"action_l2":null,"linkquality":27,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"OFF","state_l2":"ON"}'

Zigbee2MQTT:info 2022-08-30 11:45:29: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action_l1":null,"action_l2":null,"linkquality":33,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'

The l2 state shouldn't change as it is in decoupled operation mode. I can confirm that the L2 relay DOES activate.

If you provide me directions I can provide other logs if it can help. I'm really at loss here.. I can't really tell if the device is doing something wrong or if it's a Z2M issue.

I bought this unit to have an outdoors dual Zigbee switch, by fitting it inside a Niko Hydro box. Really hope I can get this to work as there are not a ton of options here in Belgium for this use case.

@sjorge
Copy link
Contributor

sjorge commented Aug 30, 2022

Can you set the log level to debug and press the buttons again, that should show what the device is sending. And hopefully that is enough for me to figure out what is wrong. 🤞

I bought this unit to have an outdoors dual Zigbee switch, by fitting it inside a Niko Hydro box. Really hope I can get this to work as there are not a ton of options here in Belgium for this use case.

Yeah not much options, you got the generic TuYa stuff which I personally don't like, and well Ubisys ships to Belgium too. I love there stuff but rather expensive, especially compared to the Niko stuff. (Sadly the Niko stuff does not do binding which is a deal breaker for me personally).

@sephiroth1395
Copy link
Author

Starting from both relays off, nothing changed in the device config.

L1 button first press:

Zigbee2MQTT:debug 2022-08-30 13:48:56: Received Zigbee message from 'Interrupteurs toit cuisine', type 'attributeReport', cluster 'genOnOff', data '{"onOff":1}' from endpoint 1 with groupID 0

Zigbee2MQTT:info 2022-08-30 13:48:56: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action_l1":null,"action_l2":null,"linkquality":75,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"ON","state_l2":"OFF"}'

L1 second press:

Zigbee2MQTT:debug 2022-08-30 13:50:35: Received Zigbee message from 'Interrupteurs toit cuisine', type 'attributeReport', cluster 'genOnOff', data '{"onOff":0}' from endpoint 1 with groupID 0

Zigbee2MQTT:info 2022-08-30 13:50:35: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action_l1":null,"action_l2":null,"linkquality":54,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'

L2 first press:

Zigbee2MQTT:debug 2022-08-30 13:51:49: Received Zigbee message from 'Interrupteurs toit cuisine', type 'attributeReport', cluster 'genOnOff', data '{"onOff":1}' from endpoint 2 with groupID 0

Zigbee2MQTT:info 2022-08-30 13:51:49: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action_l1":null,"action_l2":null,"linkquality":48,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"OFF","state_l2":"ON"}'

L2 second press:

Zigbee2MQTT:debug 2022-08-30 13:52:15: Received Zigbee message from 'Interrupteurs toit cuisine', type 'attributeReport', cluster 'genOnOff', data '{"onOff":0}' from endpoint 2 with groupID 0

Zigbee2MQTT:info 2022-08-30 13:52:15: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action_l1":null,"action_l2":null,"linkquality":30,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'

I also looked into what the feedback is when I try to set the switch behaviour to decoupled, as obviously L2 behaves as control_relay although it is configured as decoupled.

Here is what I see in the debug logs :

Zigbee2MQTT:debug 2022-08-30 13:53:37: Received MQTT message on 'zigbee2mqtt/Interrupteurs toit cuisine/set' with data '{"operation_mode_l2":"decoupled"}'

Zigbee2MQTT:debug 2022-08-30 13:53:37: Publishing 'set' 'operation_mode' to 'Interrupteurs toit cuisine'

Zigbee2MQTT:info 2022-08-30 13:53:37: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action_l1":null,"action_l2":null,"linkquality":36,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'

When I do a get after that:

Zigbee2MQTT:debug 2022-08-30 13:54:32: Received MQTT message on 'zigbee2mqtt/Interrupteurs toit cuisine/get' with data '{"operation_mode_l2":""}'

Zigbee2MQTT:debug 2022-08-30 13:54:32: Publishing get 'get' 'operation_mode' to 'Interrupteurs toit cuisine'

Zigbee2MQTT:debug 2022-08-30 13:54:32: Received Zigbee message from 'Interrupteurs toit cuisine', type 'readResponse', cluster 'manuSpecificNiko1', data '{"switchOperationMode":1}' from endpoint 2 with groupID 0

Zigbee2MQTT:info 2022-08-30 13:54:32: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action_l1":null,"action_l2":null,"linkquality":39,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'

I'm not a Z2M expert, but I think the whole issue is excess/missing _l1 and _l2 things here and there. In particular, this:

"operation_mode_l2":null,"operation_mode_l2_l2":"decoupled"

Sounds extremely weird, and as control_relay is the default behaviour, I think it's our clue. I will be away from home for the coming 48 hours but happy to test any fix that might come up :)

@sjorge
Copy link
Contributor

sjorge commented Aug 30, 2022

Yes the double _l2_l2 and _l1_l1 are not correct for sure, but it at least looks to be reading the info from the correct endpoint.

https://github.com/Koenkk/zigbee-herdsman-converters/blob/5ad7be2d69f371b170b5b0741e98d2e4579ea255/devices/niko.js#L193-L221

Looks like I did set multiEndpoint correctly so as of now i am puzzled why it is not working. I think the actions are probably missing because the device never wrote the decoupled config for the 2nd endpoint correctly so it's not generating the actions, as I am still seeing the genOnOff reporting coming in.

Edit:
https://github.com/Koenkk/zigbee-herdsman-converters/blob/5ad7be2d69f371b170b5b0741e98d2e4579ea255/devices/niko.js#L10-L22
https://github.com/Koenkk/zigbee-herdsman-converters/blob/5ad7be2d69f371b170b5b0741e98d2e4579ea255/devices/niko.js#L55-L72

@Koenkk I probably messed stuff on in these convertors, can you have I look?
Probably something like this to fix? Koenkk/zigbee-herdsman-converters@master...sjorge:zigbee-herdsman-converters:patch-2

@sephiroth1395 are you able to apply a diff to devices/niko.js and restart zigbee2mqtt to test?

@sephiroth1395
Copy link
Author

sephiroth1395 commented Aug 30, 2022

Not really how to do this with Z2M running as a HASS add-on.. Looking into it.

EDIT: Okay, got it. Forgot it was just old plain Docker. In some ways it appears to be better:

Zigbee2MQTT:debug 2022-08-30 14:39:45: Received Zigbee message from 'Interrupteurs toit cuisine', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":16}' from endpoint 1 with groupID 0

Zigbee2MQTT:info 2022-08-30 14:39:45: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action":null,"action_l1":null,"action_l2":null,"linkquality":33,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'

Zigbee2MQTT:debug 2022-08-30 14:39:46: Received Zigbee message from 'Interrupteurs toit cuisine', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":64}' from endpoint 1 with groupID 0

Zigbee2MQTT:info 2022-08-30 14:39:46: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action":"single","action_l1":null,"action_l2":null,"linkquality":36,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}

Zigbee2MQTT:info 2022-08-30 14:39:46: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine', payload '{"action":"","action_l1":null,"action_l2":null,"linkquality":36,"operation_mode":"decoupled","operation_mode_l1":null,"operation_mode_l1_l1":"control_relay","operation_mode_l2":null,"operation_mode_l2_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'

Zigbee2MQTT:info 2022-08-30 14:39:46: MQTT publish: topic 'zigbee2mqtt/Interrupteurs toit cuisine/action', payload 'single'

There is still a lot of confusion between general attributes, l1 and l2.

Koenkk added a commit to Koenkk/zigbee-herdsman-converters that referenced this issue Aug 30, 2022
@Koenkk
Copy link
Owner

Koenkk commented Aug 30, 2022

@sephiroth1395 issue should be fixed now, updated to the latest-dev, clear out data/state.json (or just operation_mode_l2_l2/operation_mode_l1_l1) and start z2m. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html)

@sjorge for toZigbee converters, the endpoint is added by z2m thus it doesn't have to be added in the converter.

@sjorge
Copy link
Contributor

sjorge commented Aug 30, 2022

@Koenkk ok so as my diff showed, I think this is also needed for the action one as you missed that.

sjorge added a commit to sjorge/zigbee-herdsman-converters that referenced this issue Aug 31, 2022
@Koenkk
Copy link
Owner

Koenkk commented Aug 31, 2022

@sjorge that should be fine, this is a fromZigbee converter so no endpoint will appended twice.

@sjorge
Copy link
Contributor

sjorge commented Aug 31, 2022

OK, lets wait until we hear back form sephiroth1395 then to make sure everything is working.

@sephiroth1395
Copy link
Author

Sorry for the late feedback. Life happened.
I wasn't comfortable with switching to the dev branch, so I just fetched the niko.js file from master, cleaned state file and restarted Z2M.

It's better! The duplicate state is still there but so is the "normal" one:

{
    "linkquality": 90,
    "operation_mode": "decoupled",
    "operation_mode_l1": "decoupled",
    "operation_mode_l1_l1": "control_relay",
    "operation_mode_l2": "decoupled",
    "operation_mode_l2_l2": "decoupled",
    "state_l1": "OFF",
    "state_l2": "OFF",
    "action_l1": null,
    "action_l2": null
}

And it appears to be obeyed. The relays are indeed decoupled from the switches ! Changing the operation_mode to control_relay also works as intended.

What I'm still missing is actions. Things are still happening on a single action attribute, that appears when I press a button, instead on action_l1 and action_l2.

@sjorge
Copy link
Contributor

sjorge commented Sep 6, 2022

Can you try applying the additional change I had in my diff for the switch_action function?

Koenkk/zigbee-herdsman-converters@master...sjorge:zigbee-herdsman-converters:patch-2

@sephiroth1395
Copy link
Author

No difference, but I noticed only the left (l1) button triggers events to HA. The second one, not so much.

@sjorge
Copy link
Contributor

sjorge commented Sep 6, 2022

Can you grab another debug log with both of l1 and l2 in decoupled mode when you click each of the buttons?

@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2022

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the stale Stale issues label Oct 7, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2022
@nlspln
Copy link

nlspln commented Oct 20, 2022

Hi all,
I am having the same problem with these devices. Found this thread and so I tested now with the Edge build to see if there's improvement.

Symptoms (on edge build)

  • When at least 1 of the two switches is set as decoupled, neither physical button doesn't respond.
  • HASS shows Null as the status, I don't get a single, hold, and release action.
  • I can control the relays using z2m / HASS now, which wasn't the case with the stable build.

State (for reference)

{
    "linkquality": 127,
    "operation_mode": "control_relay",
    "operation_mode_l1": "decoupled",
    "operation_mode_l2": "decoupled",
    "state_l1": "OFF",
    "state_l2": "OFF",
    "action_l1": null,
    "action_l2": null,
    "action": ""
}

Debug logs

Below are the logs I get when pressing the physical switches. Both are set to decoupled mode:

Debug 2022-10-20 11:24:23Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":16}' from endpoint 1 with groupID 0
Info 2022-10-20 11:24:23MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action":null,"action_l1":null,"action_l2":null,"linkquality":120,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'
Debug 2022-10-20 11:24:23Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":64}' from endpoint 1 with groupID 0
Info 2022-10-20 11:24:23MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action":"single","action_l1":null,"action_l2":null,"linkquality":120,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'
Info 2022-10-20 11:24:23MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action":"","action_l1":null,"action_l2":null,"linkquality":120,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'
Info 2022-10-20 11:24:23MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights/action', payload 'single'
Debug 2022-10-20 11:24:24Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":4096}' from endpoint 1 with groupID 0
Info 2022-10-20 11:24:24MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action_l1":null,"action_l2":null,"linkquality":127,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'
Debug 2022-10-20 11:24:24Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":16384}' from endpoint 1 with groupID 0
Info 2022-10-20 11:24:24MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action_l1":null,"action_l2":null,"linkquality":127,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"decoupled","state_l1":"OFF","state_l2":"OFF"}'

Hope this helps.

@sjorge
Copy link
Contributor

sjorge commented Oct 29, 2022

I no longer have the dual rocker one so I can't double check myself, so some follow up questions:

  1. when setting to decoupled on operation_mode_l1, what does a /get for operation_mode_l2 return? Is it also updated to decoupled?

  2. can you post a debug log in decoupled mode while doing the following:

  • press left button
  • press and hold left button (5 sec or so should do fine I think)
  • press right button
  • press and hold right button (5sec or should should do)

The value in your snipper above for 4096 16384 are things I have not see with my brief time with the device, so it probably means I did not capture all the data correctly before I send it back. I only had like 3 days to poke and collect data.

My initial messing around (pre having any support) indicated that it should be possible to toggle the mode individually as the difference between single and dual seemed to be an extra endpoint mirroring all the clusters. This might have been wrong. Hopefully 1 above should that they are either in sync or not, if the former it's probably an all or nothing option.

That would also explain why all actions arrive on endpoint 1 even when using the other button. If that's the case the action map probably also needs to be extended. Currently it is:

const actionMap = {16: null, 64: 'single', 32: 'hold', 48: 'release'};

But it might be that there is another set of 4 values for the 2nd button.

@nlspln
Copy link

nlspln commented Oct 31, 2022

  1. when setting to decoupled on operation_mode_l1, what does a /get for operation_mode_l2 return? Is it also updated to decoupled?

These are the logs after setting operation_mode_l1 to decoupled and pressing the physical button for L2:

Debug 2022-10-31 07:13:59Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":4096}' from endpoint 1 with groupID 0
Info 2022-10-31 07:13:59MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action_l1":null,"action_l2":null,"linkquality":76,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"control_relay","state_l1":"ON","state_l2":"OFF"}'
Debug 2022-10-31 07:13:59Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":16384}' from endpoint 1 with groupID 0
Info 2022-10-31 07:13:59MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action_l1":null,"action_l2":null,"linkquality":72,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"control_relay","state_l1":"ON","state_l2":"OFF"}'
Debug 2022-10-31 07:13:59Received Zigbee message from 'Master Bedroom Heater', type 'attributeReport', cluster 'seMetering', data '{"currentSummDelivered":[0,1223362]}' from endpoint 1 with groupID 0
Info 2022-10-31 07:13:59MQTT publish: topic 'zigbee2mqtt/Master Bedroom Heater', payload '{"child_lock":"LOCK","current":0,"energy":122.34,"led_enable":true,"linkquality":87,"power":0,"state":"OFF","voltage":230.4}'
Debug 2022-10-31 07:13:59Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'genOnOff', data '{"onOff":1}' from endpoint 1 with groupID 0
Info 2022-10-31 07:13:59MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action_l1":null,"action_l2":null,"linkquality":51,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"control_relay","state_l1":"ON","state_l2":"OFF"}'
  1. can you post a debug log in decoupled mode while doing the following:
  • press left button
  • press and hold left button (5 sec or so should do fine I think)
  • press right button
  • press and hold right button (5sec or should should do)
    Left button (L1 & L2 decoupled)
Debug 2022-10-31 07:16:34Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":16}' from endpoint 1 with groupID 0
Info 2022-10-31 07:16:34MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action":null,"action_l1":null,"action_l2":null,"linkquality":94,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"control_relay","state_l1":"ON","state_l2":"OFF"}'
Debug 2022-10-31 07:16:35Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":32}' from endpoint 1 with groupID 0
Info 2022-10-31 07:16:35MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action":"hold","action_l1":null,"action_l2":null,"linkquality":91,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"control_relay","state_l1":"ON","state_l2":"OFF"}'
Info 2022-10-31 07:16:35MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action":"","action_l1":null,"action_l2":null,"linkquality":91,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"control_relay","state_l1":"ON","state_l2":"OFF"}'
Info 2022-10-31 07:16:35MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights/action', payload 'hold'
Debug 2022-10-31 07:16:38Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":48}' from endpoint 1 with groupID 0
Info 2022-10-31 07:16:38MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action":"release","action_l1":null,"action_l2":null,"linkquality":91,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"control_relay","state_l1":"ON","state_l2":"OFF"}'
Info 2022-10-31 07:16:38MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action":"","action_l1":null,"action_l2":null,"linkquality":91,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"control_relay","state_l1":"ON","state_l2":"OFF"}'
Info 2022-10-31 07:16:38MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights/action', payload 'release'

Right button (L2 & L1 decoupled)

Debug 2022-10-31 07:18:41Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":4096}' from endpoint 1 with groupID 0
Info 2022-10-31 07:18:41MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action_l1":null,"action_l2":null,"linkquality":40,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"decoupled","state_l1":"ON","state_l2":"OFF"}'
Debug 2022-10-31 07:18:42Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":8192}' from endpoint 1 with groupID 0
Info 2022-10-31 07:18:42MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action_l1":null,"action_l2":null,"linkquality":29,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"decoupled","state_l1":"ON","state_l2":"OFF"}'
Debug 2022-10-31 07:18:45Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'manuSpecificNiko2', data '{"switchAction":12288}' from endpoint 1 with groupID 0
Info 2022-10-31 07:18:45MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action_l1":null,"action_l2":null,"linkquality":61,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"decoupled","state_l1":"ON","state_l2":"OFF"}'

Right button (L1 decoupled, L2 control_relay)

Debug 2022-10-31 07:31:20Received Zigbee message from 'Living Room / Kitchen Lights', type 'attributeReport', cluster 'genOnOff', data '{"onOff":1}' from endpoint 2 with groupID 0
Info 2022-10-31 07:31:20MQTT publish: topic 'zigbee2mqtt/Living Room / Kitchen Lights', payload '{"action_l1":null,"action_l2":null,"linkquality":83,"operation_mode":"control_relay","operation_mode_l1":"decoupled","operation_mode_l2":"control_relay","state_l1":"ON","state_l2":"ON"}'

Hope this helps

@Herwigvd
Copy link

Herwigvd commented Nov 1, 2022

Hello, I am also struggling with this double Niko switch and recognize the problems described in this topic. I want to use it in decoupled mode and detect the individual switches. Not sure if I can help in debugging as I am not that acquainted with github and install a beta version to do some testing. Nevertheless, if I can do a test with the released version then let me know.

Mephistofeles pushed a commit to Mephistofeles/zigbee-herdsman-converters that referenced this issue Dec 13, 2022
@aocaoc
Copy link

aocaoc commented Dec 19, 2022

I'm having the same problem.
When the switches are set to decoupled, neither action is recognized.

@sjorge
Copy link
Contributor

sjorge commented Dec 21, 2022

Can you try with this external converter?

I modified the fz.switch_action, I took a guess based on the data in this thread but I did not test it, as no longer have any of the Niko switches.

const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const extend = require('zigbee-herdsman-converters/lib/extend');
const e = exposes.presets;
const ea = exposes.access;

const local = {
    fz: {
        switch_operation_mode: {
            cluster: 'manuSpecificNiko1',
            type: ['attributeReport', 'readResponse'],
            convert: (model, msg, publish, options, meta) => {
                const state = {};
                if (msg.data.hasOwnProperty('switchOperationMode')) {
                    const operationModeMap = {0x02: 'control_relay', 0x01: 'decoupled', 0x00: 'unknown'};
                    state['operation_mode'] = operationModeMap[msg.data.switchOperationMode];
                }
                return state;
            },
        },
        switch_action: {
            cluster: 'manuSpecificNiko2',
            type: ['attributeReport', 'readResponse'],
            convert: (model, msg, publish, options, meta) => {
                const state = {};

                if (msg.data.hasOwnProperty('switchAction')) {
                    // NOTE: a single press = two seperate values reported, 16 followed by 64
                    //       a hold/release cyle = three seperate values, 16, 32, and 48
                    const actionMap = (model.model == '552-721X1') ?
                                {16: null, 64: 'single', 32: 'hold', 48: 'release'} :
                                {16: null, 64: 'left_single', 32: 'left_hold', 48: 'left_release', 4096: 'right_single', 8192: 'right_hold', 12288: 'right_release'};
                    state['action'] = actionMap[msg.data.switchAction];
                }
                return state;
            },
        },
    },
    tz: {
        switch_operation_mode: {
            key: ['operation_mode'],
            convertSet: async (entity, key, value, meta) => {
                // WARN: while we can technically write 0x00 to the operationMode attribute
                //       this seems to brick the device and it will need to be rejoined
                const operationModeLookup = {control_relay: 0x02, decoupled: 0x01};
                if (!operationModeLookup.hasOwnProperty(value)) {
                    throw new Error(`operation_mode was called with an invalid value (${value})`);
                } else {
                    await entity.write('manuSpecificNiko1', {'switchOperationMode': operationModeLookup[value]});
                    return {state: {operation_mode: value.toLowerCase()}};
                }
            },
            convertGet: async (entity, key, meta) => {
                await entity.read('manuSpecificNiko1', ['switchOperationMode']);
            },
        },
    },
};

const definition = [
    {
        zigbeeModel: ['Double connectable switch,10A'],
        model: '552-721X2',
        vendor: 'Niko',
        description: 'Double connectable switch',
        fromZigbee: [fz.on_off, local.fz.switch_operation_mode, local.fz.switch_action],
        toZigbee: [tz.on_off, local.tz.switch_operation_mode],
        endpoint: (device) => {
            return {'l1': 1, 'l2': 2};
        },
        meta: {multiEndpoint: true, multiEndpointEnforce: {'operation_mode': 1}},
        configure: async (device, coordinatorEndpoint, logger) => {
            const ep1 = device.getEndpoint(1);
            const ep2 = device.getEndpoint(2);
            await reporting.bind(ep1, coordinatorEndpoint, ['genOnOff']);
            await reporting.bind(ep2, coordinatorEndpoint, ['genOnOff']);
            await reporting.onOff(ep1);
            await reporting.onOff(ep2);
            await ep1.read('manuSpecificNiko1', ['switchOperationMode']);
            await ep2.read('manuSpecificNiko1', ['switchOperationMode']);
        },
        exposes: [
            e.switch().withEndpoint('l1'), e.switch().withEndpoint('l2'),
            e.action(['single', 'hold', 'release']).withEndpoint('l1'),
            e.action(['single', 'hold', 'release']).withEndpoint('l2'),
            exposes.enum('operation_mode', ea.ALL, ['control_relay', 'decoupled']),
        ],
    },
    {
        zigbeeModel: ['Single connectable switch,10A'],
        model: '552-721X1',
        vendor: 'Niko',
        description: 'Single connectable switch',
        fromZigbee: [fz.on_off, local.fz.switch_operation_mode, local.fz.switch_action],
        toZigbee: [tz.on_off, local.tz.switch_operation_mode],
        configure: async (device, coordinatorEndpoint, logger) => {
            const endpoint = device.getEndpoint(1);
            await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff']);
            await reporting.onOff(endpoint);
            await endpoint.read('manuSpecificNiko1', ['switchOperationMode']);
        },
        exposes: [
            e.switch(),
            e.action(['single', 'hold', 'release']),
            exposes.enum('operation_mode', ea.ALL, ['control_relay', 'decoupled']),
        ],
    },
];
module.exports = definition;

@bartpijnaert
Copy link

helaas heb ook ik hetzelfde probleem.

Unfortunately, I too have the same problem.

@RubenVerborgh
Copy link

Tested; the solution to this issue is setting attribute 0x0001 (cluster 0xfc01, 8-bit bitmap) to 0x06 (552-721X1) or 0x1e (552-721X2). Actions happen normally after that.

@Hansvank
Copy link

Thanks a lot everyone for looking into this! @RubenVerborgh can this attribute be set through Z2M or can you point me in the right direction?

@RubenVerborgh
Copy link

@Hansvank It will still need to be added to Z2M; looks like the place for that is here: https://github.com/Koenkk/zigbee-herdsman/blob/1e6ca6fc6cb84389f5c1c25102cf7b2461287dbe/src/zspec/zcl/definition/cluster.ts#L4041-L4053
(Note; I'm not a Z2M user myself, so it might have tools to send such messages without updating the code.)

@sjorge
Copy link
Contributor

sjorge commented Dec 29, 2024

@Hansvank It will still need to be added to Z2M; looks like the place for that is here: https://github.com/Koenkk/zigbee-herdsman/blob/1e6ca6fc6cb84389f5c1c25102cf7b2461287dbe/src/zspec/zcl/definition/cluster.ts#L4041-L4053 (Note; I'm not a Z2M user myself, so it might have tools to send such messages without updating the code.)

That is not the right location any more, it should end up as a device specific custom cluster (e.g. https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/lib/ubisys.ts)

Exactly for the reason noted in the warning, as there is often overlap with other devices but with different attribute types.

@Homergy
Copy link

Homergy commented Jan 8, 2025

Thanks @RubenVerborgh for the hard work.
Seems like great solution unfortunately I'm too unexperienced to implement it to Z2M...
And ChatGPT wasn't really helpfull either...
I guess I'll have to wait, but nice to see that this might be fixed in the near future.

@RubenVerborgh
Copy link

Working ZHA code is available at zigpy/zha-device-handlers#3701
The relevant fix is the 0x0001 bit; in particular writing 0b11110 for its value at initialization time.

@svenjochems
Copy link

svenjochems commented Jan 12, 2025

@RubenVerborgh Thanks for the work and the nice PR!

I did some testing to implement this for zigbee2mqtt and got something working.
I read the 0x0001 bit on my working switch and my non-working double switch. The values were 0x1F(in contrast to 0x1E reported by @RubenVerborgh) and 0x00. I tested both values and they both seem to work.

I have attached changed files: cluster.ts and niko.ts. I tested this by compiling (pnpm run build) and mounting the .js files in my docker container koenkk/zigbee2mqtt:2.0.0. Not sure if this is the correct approach as I have no experience with js.

    volumes:
      - ./dev/niko.js:/app/node_modules/zigbee-herdsman-converters/devices/niko.js
      - ./dev/cluster.js:/app/node_modules/.pnpm/[email protected]/node_modules/zigbee-herdsman/dist/zspec/zcl/definition/cluster.js

Issues/Todo's:

  • When pressing a button and an action is reported, the state of the action reporting parameter seems to reset to null in zigbee2mqtt
  • The changes in cluster.ts should probably be migrated to lib/niko.ts as mentioned by @sjorge
  • Currently only tested double switches as i don't own a single switch, I wonder if the 0x1F parameter works on this model as well
  • Implement other additions and changes from @RubenVerborgh 's PR

Feedback on the Issues/Todo's are welcome!

niko.js.txt
niko.ts.txt
cluster.js.txt
cluster.ts.txt

@RubenVerborgh
Copy link

@svenjochems Thanks so much for taking the time to test!

I read the 0x0001 bit on my working switch and my non-working double switch. The values were 0x1F […] and 0x00. I tested both values and they both seem to work.

Awesome, that's consistent, fortunately! Still wonder how the non-zero value ended up there, or rather how it stayed persistent after a reset. (Does it, actually? If you reset the switches, do the values stay?)

The values were 0x1F(in contrast to 0x1E reported by @RubenVerborgh)

Interesting. So we know it to be a bit mask wherein each of the ones represent the four buttons. So that would be Main/Left (0b00010), Extension/Left Extension (0b00100), Right (0b01000), Right Extension (0b10000), so 0b11110/0x1E together, which is also what NHC writes. I have not come across usage of the lowest bit, so I'd still be interested if anyone knows what 0b00001 represents. I wonder if there are other kinds of reporting that would happen.

  • When pressing a button and an action is reported, the state of the action reporting parameter seems to reset

That's weird, I do not observe such behavior with my switches. The value of 0x0001 remains as set.
Wondered if this was related to the unknown 0b00001 bit, but does not seem to be the case.

I do observe that the state itself (0x0002) cannot be read (and thus seems reset), as it is report-only.

  • Currently only tested double switches as i don't own a single switch, I wonder if the 0x1F parameter works on this model as well

Confirmed to be working.

Ain't no party like a Niko Home Party 🥳

niko-home-party

@svenjochems
Copy link

@RubenVerborgh

When pressing a button and an action is reported, the state of the action reporting parameter seems to reset

This parameter was only reset in zigbee2mqtt and not in the device itself. When reading the parameter again, it was reported correctly again. Probably an issue in my code 🙂

Still wonder how the non-zero value ended up there, or rather how it stayed persistent after a reset. (Does it, actually? If you reset the switches, do the values stay?)

My first switches have always had this value (I guess because actions were reported). They were reset multiple times and were never connected to the Niko hub.

@RubenVerborgh
Copy link

They were reset multiple times and were never connected to the Niko hub.

Perhaps that's the key to the mystery: all devices I bought the past couple of weeks had 0x0001 set to zero (and I believe they also reset to it). So maybe at some point, older switches left the factory with different settings.

@RubenVerborgh
Copy link

Wait, the 0b00001/0x1F is going to be "preserve after reset", isn't it? 😎

@Diepzeevogel
Copy link

H!i I'm not sure how any of this works, but I've been waiting for this to be fixed for a while now. Does anyone know when this will be pushed to the release version?

@svenjochems
Copy link

@Diepzeevogel I will create a PR once I have figured out the issues/todo's I have listed in #13737 (comment).
Since I don't have a lot of free time and have very little experience with javascript development and the zigbee2mqtt codebase in general, this might take some time.
In the meantime, you can help by testing the files I have linked in my comment and providing feedback on the issues/todos

@svenjochems
Copy link

I have create PR's Koenkk/zigbee-herdsman#1301 and Koenkk/zigbee-herdsman-converters#8635 with the changes I listed #13737 (comment).
The issues and Todo's are still there but I think these can be implemented in a separate PR later on.

@svenjochems
Copy link

@RubenVerborgh

So maybe at some point, older switches left the factory with different settings.

There seems to be a firmware difference as well. I tested the 0x0107 attribute. While this works on my newest devices, this attribute is not supported on my old devices.

@svenjochems
Copy link

I have finished my PR Koenkk/zigbee-herdsman-converters#8635
All changes are listed in the description.
If someone is able to test the changes and provide feedback, it would help to get this merged.

@paddenstoeltje
Copy link

Looks good, thanks @svenjochems!

One issue I'm still bumping into is the fact that I use the connected switch for push2dim control meaning the relay should deactivate whenever the button is released. Is this a possible to achieve with the Niko Software? If so would it be possible to integrate this in zigbee2mqtt?

@svenjochems
Copy link

@paddenstoeltje are you using homeassistant or something similar? I think this is possible of you set the switch to decoupled mode and create an automation:

  • When action=hold => switch on
  • When action=released => switch off

@paddenstoeltje
Copy link

Hi Sven,

yes I'm using HA and it is already implemented with an automation. However, I'm trying to make the system as robust as possible: basically I want the lights to be able to switch all the time, even if HA or the coordinator is out...

That's why I was asking if it is possible in the Niko Software to program the switch to act monostable (relay should follow the state of the button).

Thx for looking into this

@Hansvank
Copy link

Hansvank commented Feb 3, 2025

I just ran a quick test and everything works like a charm! Thank you very much for fixing this!!

@svenjochems
Copy link

Hi Sven,

yes I'm using HA and it is already implemented with an automation. However, I'm trying to make the system as robust as possible: basically I want the lights to be able to switch all the time, even if HA or the coordinator is out...

That's why I was asking if it is possible in the Niko Software to program the switch to act monostable (relay should follow the state of the button).

Thx for looking into this

I'm not sure if this is possible. We will need to test if this is possible using Niko Home Control and sniff the network to check which parameters are being sent to the device. I cannot do this myself because I don't have a Niko Home Control.

@RubenVerborgh
Copy link

relay should follow the state of the button

Yes:

  • Attribute 0x0000 (cluster 0xfc00, 8-bit enum) encodes button/relay coupling as decoupled (0x01) or coupled (0x02).

@svenjochems
Copy link

relay should follow the state of the button

Yes:

  • Attribute 0x0000 (cluster 0xfc00, 8-bit enum) encodes button/relay coupling as decoupled (0x01) or coupled (0x02).

This is for switch behaviour (click->on, click->off). I think what @paddenstoeltje wants is push-button behaviour (press->on, release->off). Correct me if I'm wrong!

@RubenVerborgh
Copy link

In that case, presumed not possible: the Niko hub would implement such behavior explicitly.

@paddenstoeltje
Copy link

Correct, I'm looking for push-button behaviour (press->on, release->off).

At the moment it is tackled via software. The only problem is that whenever zigbee2Mqtt / coordinator / ha is down, the lights fail to work. So when I'm updating something and the wife presses a button I get a lot of complaints :p ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Something isn't working stale Stale issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.