How does one tweak Zigbee devices, in particular Sonoff ones?

I have purchased and paired with the Openhab zigbee binding some sensors and buttons from Sonoff.
In particular the Sonoff SNZB-01 button and the SNZB-03 IR motion sensor.
The devices work perfectly but only in what I think is only a basic mode. I.e., unlike Zwave devices where there are easily customizable parameters, there are none available in the Zigbee pairing.

In particular for the SNZB-01 I wonder how one takes advantage of the double-tap and long press feature? Without them, the button is just a single-purpose On-Off button. And it works well for that, but I’d like to be able to give the button more than one function (Single press turns my bed sight light on/off, double press then all the bedroom lights are turned on or off and long press turns off all the lights in the house, for example.)

@chris is that doable?

PS: A search on those devices shows that most people use an intermediary to use them. I do not want to use any MQTT interface or such. Just the zigbee binding with my USB stick.

I don’t really know anything about the device, so it’s hard to comment in detail, but probably this device would require a custom definition (ie custom thing file in the binding) to define these commands (whatever they might be).

You’d have to look through the binding source to work out how to use this functionality - it was added by DT and isn’t something I’m super familiar with.

I’ll see if I can find technical details of the devices.
As I said, I am at least happy they are very to use for their basic purposes and given their price, it’s a bargain. Cheaper than the IKEA devices.

I remember zwave definition files. This is the first time I’d need to get into zigbee details.
Where do the custom definition files go?
Is there a way to see (via a debug/snoop flag) whatever the device sends to the coordinator in order to construct the definition file?

I did find out how to turn on the debug of the zigbee.
Here is what I found:

  1. A single press sends a ‘Toggle’ command:
    ZigBee command received ToggleCommand [On/Off: 33F4/1 -> 0000/1, cluster=0006, TID=1D]
  2. A double press sends a ‘On’ command:
    ZigBee command received OnCommand [On/Off: 33F4/1 -> 0000/1, cluster=0006, TID=1E]
  3. A long press sends an ‘Off’ command:
    ZigBee command received OffCommand [On/Off: 33F4/1 -> 0000/1, cluster=0006, TID=2B]

So it looks like it should not be too difficult to work with that.
I emulated the example of the fillipsHowever I am not sure what symbolic constant to use. I tried:

rule "ButtonLongPress"
when
        Channel 'zigbee:device:AAAAAAAAAA:BBBBBBBBBBBBB:CCCCCCCCCCCCC_1_switch' triggered 'OffCommand'
then
        logInfo("Button Press", "Long press")
end

But the rule does not get triggered. Is there a trick to get the rule triggered based on the message received rather than the on/off transition?

@chris I went to look through the source code and it does not look like the command received is being propagating anywhere down the line so that the rules could act based on the received command.

    @Override
    public boolean commandReceived(ZclCommand command) {
        logger.debug("{}: ZigBee command received {}", endpoint.getIeeeAddress(), command);
        if (command instanceof OnCommand) {
            currentOnOffState.set(true);
            updateChannelState(OnOffType.ON);
            clusterOnOffClient.sendDefaultResponse(command, ZclStatus.SUCCESS);
            return true;
        }
        if (command instanceof OnWithTimedOffCommand) {
            currentOnOffState.set(true);
            updateChannelState(OnOffType.ON);
            OnWithTimedOffCommand timedCommand = (OnWithTimedOffCommand) command;
            clusterOnOffClient.sendDefaultResponse(command, ZclStatus.SUCCESS);
            startOffTimer(timedCommand.getOnTime() * 100);
            return true;
        }
        if (command instanceof OffCommand || command instanceof OffWithEffectCommand) {
            currentOnOffState.set(false);
            updateChannelState(OnOffType.OFF);
            clusterOnOffClient.sendDefaultResponse(command, ZclStatus.SUCCESS);
            return true;
        }
        if (command instanceof ToggleCommand) {
            currentOnOffState.set(!currentOnOffState.get());
            updateChannelState(currentOnOffState.get() ? OnOffType.ON : OnOffType.OFF);
            clusterOnOffClient.sendDefaultResponse(command, ZclStatus.SUCCESS);
            return true;
        }

        return false;
    }

So it looks like what I want to do is not achievable without changing the source code. Is that right?
Or does the thing’s configuration have a way to modify what happens?

Yes, that is right. As I stated earlier, this requires a custom definition -:

As this states, it requires changes to the binding.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.