Search in sources :

Example 1 with ZWaveConfigurationParameterEvent

use of org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveConfigurationCommandClass.ZWaveConfigurationParameterEvent in project openhab1-addons by openhab.

the class ZWaveConfigurationConverter method handleEvent.

/**
     * {@inheritDoc}
     */
@Override
public void handleEvent(ZWaveCommandClassValueEvent event, Item item, Map<String, String> arguments) {
    String parmNumber = arguments.get("parameter");
    ZWaveConfigurationParameterEvent cfgEvent = (ZWaveConfigurationParameterEvent) event;
    // Make sure this is for the parameter we want
    if (cfgEvent.getParameter() != null && cfgEvent.getParameter().getIndex() != Integer.parseInt(parmNumber)) {
        return;
    }
    ZWaveStateConverter<?, ?> converter = this.getStateConverter(item, cfgEvent.getParameter().getValue());
    if (converter == null) {
        logger.warn("NODE {}: No converter found for item = {}({}), endpoint = {}, ignoring event.", event.getNodeId(), item.getName(), item.getClass().getSimpleName(), event.getEndpoint());
        return;
    }
    State state = converter.convertFromValueToState(cfgEvent.getParameter().getValue());
    this.getEventPublisher().postUpdate(item.getName(), state);
}
Also used : State(org.openhab.core.types.State) ZWaveConfigurationParameterEvent(org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveConfigurationCommandClass.ZWaveConfigurationParameterEvent)

Example 2 with ZWaveConfigurationParameterEvent

use of org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveConfigurationCommandClass.ZWaveConfigurationParameterEvent in project openhab1-addons by openhab.

the class ZWaveConfiguration method ZWaveIncomingEvent.

/**
     * Event handler method for incoming Z-Wave events.
     *
     * @param event
     *            the incoming Z-Wave event.
     */
@Override
public void ZWaveIncomingEvent(ZWaveEvent event) {
    if (event instanceof ZWaveConfigurationParameterEvent) {
        // Write the node to disk
        ZWaveNodeSerializer nodeSerializer = new ZWaveNodeSerializer();
        nodeSerializer.SerializeNode(zController.getNode(event.getNodeId()));
        // We've received an updated configuration parameter
        // See if this is something in our 'pending' list and remove it
        PendingCfg.Remove(ZWaveCommandClass.CommandClass.CONFIGURATION.getKey(), event.getNodeId(), ((ZWaveConfigurationParameterEvent) event).getParameter().getIndex());
        return;
    }
    if (event instanceof ZWaveAssociationEvent) {
        // Write the node to disk
        ZWaveNodeSerializer nodeSerializer = new ZWaveNodeSerializer();
        nodeSerializer.SerializeNode(zController.getNode(event.getNodeId()));
        // See if this is something in our 'pending' list and remove it
        for (ZWaveNode node : zController.getNodes()) {
            PendingCfg.Remove(ZWaveCommandClass.CommandClass.ASSOCIATION.getKey(), event.getNodeId(), ((ZWaveAssociationEvent) event).getGroup(), node.getNodeId());
        }
        return;
    }
    if (event instanceof ZWaveWakeUpCommandClass.ZWaveWakeUpEvent) {
        // We only care about the wake-up report
        if (((ZWaveWakeUpCommandClass.ZWaveWakeUpEvent) event).getEvent() != ZWaveWakeUpCommandClass.WAKE_UP_INTERVAL_REPORT) {
            return;
        }
        // Write the node to disk
        ZWaveNodeSerializer nodeSerializer = new ZWaveNodeSerializer();
        nodeSerializer.SerializeNode(zController.getNode(event.getNodeId()));
        // Remove this node from the pending list
        PendingCfg.Remove(ZWaveCommandClass.CommandClass.WAKE_UP.getKey(), event.getNodeId());
        return;
    }
    if (event instanceof ZWaveSwitchAllCommandClass.ZWaveSwitchAllModeEvent) {
        ZWaveSwitchAllCommandClass.ZWaveSwitchAllModeEvent e = (ZWaveSwitchAllCommandClass.ZWaveSwitchAllModeEvent) event;
        // Write the node to disk
        ZWaveNodeSerializer nodeSerializer = new ZWaveNodeSerializer();
        nodeSerializer.SerializeNode(zController.getNode(event.getNodeId()));
        // Remove this node from the pending list
        PendingCfg.Remove(ZWaveCommandClass.CommandClass.SWITCH_ALL.getKey(), e.getNodeId());
        return;
    }
    if (event instanceof ZWaveInclusionEvent) {
        handleInclusionEvent((ZWaveInclusionEvent) event);
    }
}
Also used : ZWaveNodeSerializer(org.openhab.binding.zwave.internal.protocol.initialization.ZWaveNodeSerializer) ZWaveNode(org.openhab.binding.zwave.internal.protocol.ZWaveNode) ZWaveInclusionEvent(org.openhab.binding.zwave.internal.protocol.event.ZWaveInclusionEvent) ZWaveSwitchAllCommandClass(org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveSwitchAllCommandClass) ZWaveConfigurationParameterEvent(org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveConfigurationCommandClass.ZWaveConfigurationParameterEvent) ZWaveAssociationEvent(org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveAssociationCommandClass.ZWaveAssociationEvent) ZWaveWakeUpCommandClass(org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveWakeUpCommandClass)

Aggregations

ZWaveConfigurationParameterEvent (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveConfigurationCommandClass.ZWaveConfigurationParameterEvent)2 ZWaveNode (org.openhab.binding.zwave.internal.protocol.ZWaveNode)1 ZWaveAssociationEvent (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveAssociationCommandClass.ZWaveAssociationEvent)1 ZWaveSwitchAllCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveSwitchAllCommandClass)1 ZWaveWakeUpCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveWakeUpCommandClass)1 ZWaveInclusionEvent (org.openhab.binding.zwave.internal.protocol.event.ZWaveInclusionEvent)1 ZWaveNodeSerializer (org.openhab.binding.zwave.internal.protocol.initialization.ZWaveNodeSerializer)1 State (org.openhab.core.types.State)1