Search in sources :

Example 46 with SerialMessage

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

the class ZWaveThermostatModeConverter method receiveCommand.

/**
     * {@inheritDoc}
     */
@Override
void receiveCommand(Item item, Command command, ZWaveNode node, ZWaveThermostatModeCommandClass commandClass, int endpointId, Map<String, String> arguments) {
    ZWaveCommandConverter<?, ?> converter = this.getCommandConverter(command.getClass());
    if (converter == null) {
        logger.warn("NODE {}: No converter found for item = {}, endpoint = {}, ignoring command.", node.getNodeId(), item.getName(), endpointId);
        return;
    }
    logger.debug("NODE {}: receiveCommand with converter {} ", node.getNodeId(), converter.getClass());
    SerialMessage serialMessage = node.encapsulate(commandClass.setValueMessage((Integer) converter.convertFromCommandToValue(item, command)), commandClass, endpointId);
    logger.debug("NODE {}: receiveCommand sending message {} ", node.getNodeId(), serialMessage);
    if (serialMessage == null) {
        logger.warn("NODE {}: Generating message failed for command class = {}, endpoint = {}", node.getNodeId(), commandClass.getCommandClass().getLabel(), endpointId);
        return;
    }
    this.getController().sendData(serialMessage);
    if (command instanceof State) {
        this.getEventPublisher().postUpdate(item.getName(), (State) command);
    }
}
Also used : State(org.openhab.core.types.State) SerialMessage(org.openhab.binding.zwave.internal.protocol.SerialMessage)

Example 47 with SerialMessage

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

the class ZWaveWakeUpConverter method receiveCommand.

/**
     * {@inheritDoc}
     */
@Override
public void receiveCommand(Item item, Command command, ZWaveNode node, ZWaveWakeUpCommandClass commandClass, int endpointId, Map<String, String> arguments) {
    ZWaveCommandConverter<?, ?> converter = this.getCommandConverter(command.getClass());
    if (converter == null) {
        logger.warn("NODE {}: No converter found for item={}, type={}, endpoint={}, ignoring command.", node.getNodeId(), item.getName(), command.getClass().getSimpleName(), endpointId);
        return;
    }
    // Set the wakeup
    SerialMessage serialMessage = commandClass.setInterval((Integer) converter.convertFromCommandToValue(item, command));
    if (serialMessage == null) {
        logger.warn("NODE {}: Generating message failed for command class = {}, endpoint = {}", node.getNodeId(), commandClass.getCommandClass().getLabel(), endpointId);
        return;
    }
    this.getController().sendData(serialMessage);
    // And request a read-back
    serialMessage = commandClass.getIntervalMessage();
    this.getController().sendData(serialMessage);
    if (command instanceof State) {
        this.getEventPublisher().postUpdate(item.getName(), (State) command);
    }
}
Also used : State(org.openhab.core.types.State) SerialMessage(org.openhab.binding.zwave.internal.protocol.SerialMessage)

Example 48 with SerialMessage

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

the class ZWaveAlarmSensorCommandClass method getSupportedMessage.

/**
     * Gets a SerialMessage with the SENSOR_ALARM_SUPPORTED_GET command
     *
     * @return the serial message, or null if the supported command is not supported.
     */
public SerialMessage getSupportedMessage() {
    logger.debug("NODE {}: Creating new message for command SENSOR_ALARM_SUPPORTED_GET", this.getNode().getNodeId());
    if (this.getNode().getManufacturer() == 0x010F && this.getNode().getDeviceType() == 0x0501) {
        logger.warn("NODE {}: Detected Fibaro FGBS001 Universal Sensor - this device fails to respond to SENSOR_ALARM_GET and SENSOR_ALARM_SUPPORTED_GET.", this.getNode().getNodeId());
        return null;
    }
    if (this.getNode().getManufacturer() == 0x010F && this.getNode().getDeviceType() == 0x0600) {
        logger.warn("NODE {}: Detected Fibaro FGWPE Wall Plug - this device fails to respond to SENSOR_ALARM_GET and SENSOR_ALARM_SUPPORTED_GET.", this.getNode().getNodeId());
        return null;
    }
    SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.ApplicationCommandHandler, SerialMessagePriority.High);
    byte[] newPayload = { (byte) this.getNode().getNodeId(), 2, (byte) getCommandClass().getKey(), (byte) SENSOR_ALARM_SUPPORTED_GET };
    result.setMessagePayload(newPayload);
    return result;
}
Also used : SerialMessage(org.openhab.binding.zwave.internal.protocol.SerialMessage)

Example 49 with SerialMessage

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

the class ZWaveAlarmSensorCommandClass method getMessage.

/**
     * Gets a SerialMessage with the SENSOR_ALARM_GET command
     *
     * @return the serial message
     */
public SerialMessage getMessage(AlarmType alarmType) {
    if (isGetSupported == false) {
        logger.debug("NODE {}: Node doesn't support get requests", this.getNode().getNodeId());
        return null;
    }
    logger.debug("NODE {}: Creating new message for command SENSOR_ALARM_GET, type {}", this.getNode().getNodeId(), alarmType.getLabel());
    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_ALARM_GET, (byte) alarmType.getKey() };
    result.setMessagePayload(newPayload);
    return result;
}
Also used : SerialMessage(org.openhab.binding.zwave.internal.protocol.SerialMessage)

Example 50 with SerialMessage

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

the class ZWaveAssociationCommandClass method getAssociationMessage.

/**
     * Gets a SerialMessage with the ASSOCIATIONCMD_GET command
     *
     * @param group
     *            the association group to read
     * @return the serial message
     */
public SerialMessage getAssociationMessage(int group) {
    logger.debug("NODE {}: Creating new message for application command ASSOCIATIONCMD_GET group {}", this.getNode().getNodeId(), group);
    SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.ApplicationCommandHandler, SerialMessagePriority.Config);
    byte[] newPayload = { (byte) this.getNode().getNodeId(), 3, (byte) getCommandClass().getKey(), (byte) ASSOCIATIONCMD_GET, (byte) (group & 0xff) };
    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