openhab / org.openhab.binding.zwave

openHAB binding for Z-Wave
Eclipse Public License 2.0
171 stars 202 forks source link

FIBARO WTRFID event mishandled #292

Closed bricolo100 closed 7 years ago

bricolo100 commented 7 years ago

While using the Fibaro WTRFID, the alarm_access channel is triggered on whatever type of access is requested: "Home" or Away. According to the device manual (https://www.zipato.com/wp-content/uploads/2015/07/wt-rfid-Zipato-Mini-Keypad-RFiD-Z-Wave-User-Manual-v1.4.pdf), page 2 AWAY generate an event 0x05 and Home 0x06. This is correctly detected on ZWaveAlarmCommandClass Away Debug log: NODE 11: NOTIFICATION report - 0 = 0, event=5, status=255 Home Debug log: NODE 11: NOTIFICATION report - 0 = 0, event=6, status=255 but in all cases it generates a updating to ON in the thinghandler Debug log: NODE 11: Updating channel state zwave:device:ZwaveController:node11:alarm_access to ON [OnOffType] The problem seems to come from the ZWaveAlarmConverter, where the type of event is taken into account:

// TODO: Handle these event to state specific conversions in a table.
    State state = null;
    switch (channel.getDataType()) {
       case OnOffType:
            state = event == 0 ? OnOffType.OFF : OnOffType.ON; <- modification here
            break;
        case OpenClosedType:
            logger.debug("Alarm converter NOTIFICATION 1");
            state = eventAlarm.getValue() == 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
            if (eventAlarm.getAlarmType() == AlarmType.ACCESS_CONTROL) {
                logger.debug("Alarm converter NOTIFICATION 2");
                switch (event) {
                    case 22: // Window/Door is open
                        state = OpenClosedType.OPEN;
                        break;
                    case 23: // Window/Door is closed
                        state = OpenClosedType.CLOSED;
                        logger.debug("Alarm converter NOTIFICATION 3");
                        break;
                    default:
                        break;
                }
            }
            break;
        case DecimalType:
            state = new DecimalType(eventAlarm.getAlarmEvent());
            break;
        default:
            logger.warn("No conversion in {} to {}", getClass().getSimpleName(), channel.getDataType());
            break;
    }
    return state;
}

A switch clause for OnOffType with

I wish you a happy new year

cdjackson commented 7 years ago

The current binding allows you to set filters for events. So you can set "event=6" to filter for ON=6 and OFF=0. You just need to set this in the database. Please feel free to update and confirm we can close this.