Search in sources :

Example 16 with SerialMessage

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

the class ZWaveWakeUpCommandClass method getIntervalMessage.

/**
     * Gets a SerialMessage with the WAKE UP INTERVAL GET command
     *
     * @return the serial message
     */
public SerialMessage getIntervalMessage() {
    if (isGetSupported == false) {
        logger.debug("NODE {}: Node doesn't support get requests", this.getNode().getNodeId());
        return null;
    }
    logger.debug("NODE {}: Creating new message for application command WAKE_UP_INTERVAL_GET", this.getNode().getNodeId());
    SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.ApplicationCommandHandler, SerialMessagePriority.Config);
    byte[] newPayload = { (byte) this.getNode().getNodeId(), 2, (byte) getCommandClass().getKey(), (byte) WAKE_UP_INTERVAL_GET };
    result.setMessagePayload(newPayload);
    return result;
}
Also used : SerialMessage(org.openhab.binding.zwave.internal.protocol.SerialMessage)

Example 17 with SerialMessage

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

the class ZWaveMultiLevelSensorCommandClass method getMessage.

/**
     * Gets a SerialMessage with the SENSOR_MULTI_LEVEL_GET command
     *
     * @param sensorType the {@link SensorType} to get the value for.
     * @return the serial message
     */
public SerialMessage getMessage(SensorType sensorType) {
    if (isGetSupported == false) {
        logger.debug("NODE {}: Node doesn't support get requests for MULTI_LEVEL_SENSOR", this.getNode().getNodeId());
        return null;
    }
    logger.debug("NODE {}: Creating new message for command SENSOR_MULTI_LEVEL_GET", this.getNode().getNodeId());
    SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.ApplicationCommandHandler, SerialMessagePriority.Get);
    byte[] newPayload = { (byte) this.getNode().getNodeId(), 3, (byte) getCommandClass().getKey(), (byte) SENSOR_MULTI_LEVEL_GET, (byte) sensorType.getKey() };
    result.setMessagePayload(newPayload);
    return result;
}
Also used : SerialMessage(org.openhab.binding.zwave.internal.protocol.SerialMessage)

Example 18 with SerialMessage

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

the class ZWaveMultiLevelSensorCommandClass method getSupportedValueMessage.

/**
     * Gets a SerialMessage with the SENSOR_MULTI_LEVEL_SUPPORTED_GET command
     *
     * @return the serial message
     */
public SerialMessage getSupportedValueMessage() {
    logger.debug("NODE {}: Creating new message for command SENSOR_MULTI_LEVEL_SUPPORTED_GET", this.getNode().getNodeId());
    SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.ApplicationCommandHandler, SerialMessagePriority.Config);
    byte[] newPayload = { (byte) this.getNode().getNodeId(), 2, (byte) getCommandClass().getKey(), (byte) SENSOR_MULTI_LEVEL_SUPPORTED_GET };
    result.setMessagePayload(newPayload);
    return result;
}
Also used : SerialMessage(org.openhab.binding.zwave.internal.protocol.SerialMessage)

Example 19 with SerialMessage

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

the class ZWaveMultiLevelSensorCommandClass method getValueMessage.

/**
     * Gets a SerialMessage with the SENSOR_MULTI_LEVEL_GET command
     *
     * @return the serial message
     */
@Override
public SerialMessage getValueMessage() {
    if (isGetSupported == false) {
        logger.debug("NODE {}: Node doesn't support get requests", this.getNode().getNodeId());
        return null;
    }
    // TODO: Why does this return???!!!???
    if (this.getVersion() > 4) {
        for (Map.Entry<SensorType, Sensor> entry : this.sensors.entrySet()) {
            return this.getMessage(entry.getValue().getSensorType());
        }
    }
    logger.debug("NODE {}: Creating new message for command SENSOR_MULTI_LEVEL_GET", this.getNode().getNodeId());
    SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.ApplicationCommandHandler, SerialMessagePriority.Get);
    byte[] newPayload = { (byte) this.getNode().getNodeId(), 2, (byte) getCommandClass().getKey(), (byte) SENSOR_MULTI_LEVEL_GET };
    result.setMessagePayload(newPayload);
    return result;
}
Also used : SerialMessage(org.openhab.binding.zwave.internal.protocol.SerialMessage) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with SerialMessage

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

the class ZWaveMultiLevelSwitchCommandClass method setValueMessage.

/**
     * Gets a SerialMessage with the SWITCH_MULTILEVEL_SET command
     *
     * @param the level to set. 0 is mapped to off, > 0 is mapped to on.
     * @return the serial message
     */
@Override
public SerialMessage setValueMessage(int level) {
    logger.debug("NODE {}: Creating new message for command SWITCH_MULTILEVEL_SET", this.getNode().getNodeId());
    SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.SendData, SerialMessagePriority.Set);
    byte[] newPayload = { (byte) this.getNode().getNodeId(), 3, (byte) getCommandClass().getKey(), (byte) SWITCH_MULTILEVEL_SET, (byte) level };
    result.setMessagePayload(newPayload);
    return result;
}
Also used : SerialMessage(org.openhab.binding.zwave.internal.protocol.SerialMessage)

Aggregations

SerialMessage (org.openhab.binding.zwave.internal.protocol.SerialMessage)125 State (org.openhab.core.types.State)12 ZWaveEndpoint (org.openhab.binding.zwave.internal.protocol.ZWaveEndpoint)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 HashMap (java.util.HashMap)5 ZWaveNode (org.openhab.binding.zwave.internal.protocol.ZWaveNode)5 ZWaveWakeUpCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveWakeUpCommandClass)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 ConfigurationParameter (org.openhab.binding.zwave.internal.protocol.ConfigurationParameter)3 SecurityEncapsulatedSerialMessage (org.openhab.binding.zwave.internal.protocol.SecurityEncapsulatedSerialMessage)3 ZWaveCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveCommandClass)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ZWaveDbConfigurationParameter (org.openhab.binding.zwave.internal.config.ZWaveDbConfigurationParameter)2 ZWaveProductDatabase (org.openhab.binding.zwave.internal.config.ZWaveProductDatabase)2 MultiLevelPercentCommandConverter (org.openhab.binding.zwave.internal.converter.command.MultiLevelPercentCommandConverter)2 ZWaveAssociationCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveAssociationCommandClass)2 ZWaveConfigurationCommandClass (org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveConfigurationCommandClass)2 ZWaveNetworkEvent (org.openhab.binding.zwave.internal.protocol.event.ZWaveNetworkEvent)2