Search in sources :

Example 1 with ZWaveCommandClassValueEvent

use of org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent in project openhab1-addons by openhab.

the class ZWaveSceneActivationCommandClass method processSceneActivationSet.

/**
     * Processes a SCENEACTIVATION_SET message.
     *
     * @param serialMessage the incoming message to process.
     * @param offset the offset position from which to start message processing.
     * @param endpoint the endpoint or instance number this message is meant for.
     */
protected void processSceneActivationSet(SerialMessage serialMessage, int offset, int endpoint) {
    int sceneId = serialMessage.getMessagePayloadByte(offset + 1);
    int sceneTime = 0;
    // Aeon Minimote fw 1.19 sends SceneActivationSet without Time parameter
    if (serialMessage.getMessagePayload().length > (offset + 2)) {
        sceneTime = serialMessage.getMessagePayloadByte(offset + 2);
    }
    logger.debug(String.format("Scene activation node from node %d: Scene %d, Time %d", this.getNode().getNodeId(), sceneId, sceneTime));
    // Ignore the time for now at least!
    ZWaveCommandClassValueEvent zEvent = new ZWaveCommandClassValueEvent(this.getNode().getNodeId(), endpoint, this.getCommandClass(), sceneId);
    this.getController().notifyEventListeners(zEvent);
}
Also used : ZWaveCommandClassValueEvent(org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent) ZWaveEndpoint(org.openhab.binding.zwave.internal.protocol.ZWaveEndpoint)

Example 2 with ZWaveCommandClassValueEvent

use of org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent in project openhab1-addons by openhab.

the class ZWaveThermostatFanModeCommandClass method processThermostatFanModeReport.

/**
     * Processes a THERMOSTAT_FAN_MODE_REPORT message.
     *
     * @param serialMessage the incoming message to process.
     * @param offset the offset position from which to start message processing.
     * @param endpoint the endpoint or instance number this message is meant for.
     */
protected void processThermostatFanModeReport(SerialMessage serialMessage, int offset, int endpoint) {
    int value = serialMessage.getMessagePayloadByte(offset + 1);
    logger.debug("NODE {}: Thermostat Fan Mode report value = {}", this.getNode().getNodeId(), value);
    FanModeType fanModeType = FanModeType.getFanModeType(value);
    if (fanModeType == null) {
        logger.error("NODE {}: Unknown Fan Mode Type = {}, ignoring report.", this.getNode().getNodeId(), value);
        return;
    }
    // fanMode type seems to be supported, add it to the list.
    if (!fanModeTypes.contains(fanModeType)) {
        fanModeTypes.add(fanModeType);
    }
    dynamicDone = true;
    logger.debug("NODE {}: Thermostat Fan Mode Report value = {}", this.getNode().getNodeId(), fanModeType.getLabel());
    ZWaveCommandClassValueEvent zEvent = new ZWaveCommandClassValueEvent(this.getNode().getNodeId(), endpoint, this.getCommandClass(), value);
    this.getController().notifyEventListeners(zEvent);
}
Also used : ZWaveCommandClassValueEvent(org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent) ZWaveEndpoint(org.openhab.binding.zwave.internal.protocol.ZWaveEndpoint)

Example 3 with ZWaveCommandClassValueEvent

use of org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent in project openhab1-addons by openhab.

the class ZWaveClockCommandClass method handleApplicationCommandRequest.

/**
     * {@inheritDoc}
     *
     * @throws ZWaveSerialMessageException
     */
@Override
public void handleApplicationCommandRequest(SerialMessage serialMessage, int offset, int endpoint) {
    logger.debug("NODE {}: Received CLOCK command V{}", getNode().getNodeId(), getVersion());
    int command = serialMessage.getMessagePayloadByte(offset);
    switch(command) {
        case CLOCK_REPORT:
            int day = serialMessage.getMessagePayloadByte(offset + 1) >> 5;
            int hour = serialMessage.getMessagePayloadByte(offset + 1) & 0x1f;
            int minute = serialMessage.getMessagePayloadByte(offset + 2);
            String[] days = new DateFormatSymbols().getWeekdays();
            int javaDay = day == 7 ? 1 : day + 1;
            logger.debug(String.format("NODE %d: Received clock report: %s %02d:%02d", getNode().getNodeId(), days[javaDay], hour, minute));
            Calendar cal = Calendar.getInstance();
            cal.set(Calendar.DAY_OF_WEEK, javaDay);
            cal.set(Calendar.HOUR_OF_DAY, hour);
            cal.set(Calendar.MINUTE, minute);
            Date nodeTime = cal.getTime();
            ZWaveCommandClassValueEvent zEvent = new ZWaveCommandClassValueEvent(getNode().getNodeId(), endpoint, getCommandClass(), nodeTime);
            getController().notifyEventListeners(zEvent);
            break;
        default:
            logger.warn(String.format("NODE %d: Unsupported Command %d for command class %s (0x%02X).", getNode().getNodeId(), command, getCommandClass().getLabel(), getCommandClass().getKey()));
            break;
    }
}
Also used : Calendar(java.util.Calendar) DateFormatSymbols(java.text.DateFormatSymbols) ZWaveCommandClassValueEvent(org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent) ZWaveEndpoint(org.openhab.binding.zwave.internal.protocol.ZWaveEndpoint) Date(java.util.Date)

Example 4 with ZWaveCommandClassValueEvent

use of org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent in project openhab1-addons by openhab.

the class ZWaveMultiLevelSwitchCommandClass method handleApplicationCommandRequest.

/**
     * {@inheritDoc}
     */
@Override
public void handleApplicationCommandRequest(SerialMessage serialMessage, int offset, int endpoint) {
    logger.debug("NODE {}: Received Switch Multi Level Request", this.getNode().getNodeId());
    int command = serialMessage.getMessagePayloadByte(offset);
    switch(command) {
        case SWITCH_MULTILEVEL_SET:
        case SWITCH_MULTILEVEL_GET:
        case SWITCH_MULTILEVEL_SUPPORTED_GET:
        case SWITCH_MULTILEVEL_SUPPORTED_REPORT:
            logger.warn("Command {} not implemented.", command);
        case SWITCH_MULTILEVEL_START_LEVEL_CHANGE:
            return;
        case SWITCH_MULTILEVEL_STOP_LEVEL_CHANGE:
            logger.debug("NODE {}: Process Switch Multi Level Stop Level Change", this.getNode().getNodeId());
            // request level after dimming
            logger.debug("NODE {}: Requesting level from endpoint {}", this.getNode().getNodeId(), endpoint);
            this.getController().sendData(this.getNode().encapsulate(this.getValueMessage(), this, endpoint));
            break;
        case SWITCH_MULTILEVEL_REPORT:
            logger.trace("Process Switch Multi Level Report");
            int value = serialMessage.getMessagePayloadByte(offset + 1);
            logger.debug("NODE {}: Switch Multi Level report, value = {}", this.getNode().getNodeId(), value);
            ZWaveCommandClassValueEvent zEvent = new ZWaveCommandClassValueEvent(this.getNode().getNodeId(), endpoint, this.getCommandClass(), value);
            this.getController().notifyEventListeners(zEvent);
            dynamicDone = true;
            break;
        default:
            logger.warn(String.format("Unsupported Command 0x%02X for command class %s (0x%02X).", command, this.getCommandClass().getLabel(), this.getCommandClass().getKey()));
    }
}
Also used : ZWaveCommandClassValueEvent(org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent) ZWaveEndpoint(org.openhab.binding.zwave.internal.protocol.ZWaveEndpoint)

Example 5 with ZWaveCommandClassValueEvent

use of org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent in project openhab1-addons by openhab.

the class ZWaveNodeNamingCommandClass method processNameReport.

/**
     * Processes a NAME_REPORT / NAME_SET message.
     *
     * @param serialMessage the incoming message to process.
     * @param offset the offset position from which to start message processing.
     * @param endpoint the endpoint or instance number this message is meant for.
     */
protected void processNameReport(SerialMessage serialMessage, int offset, int endpoint) {
    String name = getString(serialMessage, offset);
    if (name == null) {
        return;
    }
    this.name = name;
    logger.debug("NODE {}: Node name: {}", this.getNode().getNodeId(), name);
    ZWaveCommandClassValueEvent zEvent = new ZWaveCommandClassValueEvent(this.getNode().getNodeId(), endpoint, this.getCommandClass(), name);
    this.getController().notifyEventListeners(zEvent);
}
Also used : ZWaveCommandClassValueEvent(org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent)

Aggregations

ZWaveCommandClassValueEvent (org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent)15 ZWaveEndpoint (org.openhab.binding.zwave.internal.protocol.ZWaveEndpoint)13 BigDecimal (java.math.BigDecimal)1 DateFormatSymbols (java.text.DateFormatSymbols)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 Properties (java.util.Properties)1