use of org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent in project openhab1-addons by openhab.
the class ZWaveCentralSceneCommandClass method handleApplicationCommandRequest.
/**
* {@inheritDoc}
*/
@Override
public void handleApplicationCommandRequest(SerialMessage serialMessage, int offset, int endpoint) {
logger.debug("NODE {}: Received central scene command (v{})", this.getNode().getNodeId(), this.getVersion());
int command = serialMessage.getMessagePayloadByte(offset);
switch(command) {
case SCENE_SET:
// offset+1 is an incrementing number
int sceneId = serialMessage.getMessagePayloadByte(offset + 3);
int key = serialMessage.getMessagePayloadByte(offset + 2);
logger.debug("NODE {}: Received scene {} ; key {}", this.getNode().getNodeId(), sceneId, key);
// Received Central Scene Commands. They are triggered by pushing a
// button on a controller supporting the CENTRAL_SCENE command class.
// Command class values in data holder: 'key' and 'scene'
// - ’scene’: indicates the current activated scene/button.
// - ’key’: indicates the current key/button state.
//
// Examples 'key' values:
// 0x00 = Key pressed,
// 0x01 = Key released,
// 0x02 = Key held down,
// 0x03 = Double Tap, (Homeseer HS-WD100, HS-WS100)
// 0x04 = Triple Tap, (Homeseer HS-WD100, HS-WS100)
Properties properties = new Properties();
properties.put("key", key);
properties.put("scene", sceneId);
// forward command class event value
ZWaveCommandClassValueEvent zEvent = new ZWaveCommandClassValueEvent(this.getNode().getNodeId(), endpoint, this.getCommandClass(), properties);
this.getController().notifyEventListeners(zEvent);
break;
case SCENE_REPORT:
sceneCount = serialMessage.getMessagePayloadByte(offset + 1);
logger.debug("NODE {}: Supports {} scenes", this.getNode().getNodeId(), sceneCount);
initialiseDone = true;
break;
default:
logger.warn(String.format("NODE %d: Unsupported Command %d for command class %s (0x%02X).", this.getNode().getNodeId(), command, this.getCommandClass().getLabel(), this.getCommandClass().getKey()));
}
}
use of org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent in project openhab1-addons by openhab.
the class ZWaveThermostatFanStateCommandClass method processThermostatFanStateReport.
/**
* Processes a THERMOSTAT_FAN_STATE_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 processThermostatFanStateReport(SerialMessage serialMessage, int offset, int endpoint) {
int value = serialMessage.getMessagePayloadByte(offset + 1);
logger.debug("NODE {}: Thermostat fan state report value = {}", this.getNode().getNodeId(), value);
FanStateType fanStateType = FanStateType.getFanStateType(value);
if (fanStateType == null) {
logger.error("NODE {}: Unknown fan state Type = {}, ignoring report.", this.getNode().getNodeId(), value);
return;
}
// fanState type seems to be supported, add it to the list.
if (!fanStateTypes.contains(fanStateType)) {
fanStateTypes.add(fanStateType);
}
dynamicDone = true;
logger.debug("NODE {}: Thermostat fan state Report value = {}", this.getNode().getNodeId(), fanStateType.getLabel());
ZWaveCommandClassValueEvent zEvent = new ZWaveCommandClassValueEvent(this.getNode().getNodeId(), endpoint, this.getCommandClass(), value);
this.getController().notifyEventListeners(zEvent);
}
use of org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent in project openhab1-addons by openhab.
the class ZWaveThermostatModeCommandClass method processThermostatModeReport.
/**
* Processes a THERMOSTAT_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 processThermostatModeReport(SerialMessage serialMessage, int offset, int endpoint) {
int value = serialMessage.getMessagePayloadByte(offset + 1);
logger.debug("NODE {}: Thermostat Mode report, value = {}", this.getNode().getNodeId(), value);
ModeType modeType = ModeType.getModeType(value);
if (modeType == null) {
logger.error("NODE {}: Unknown Mode Type = {}, ignoring report.", this.getNode().getNodeId(), value);
return;
}
// mode type seems to be supported, add it to the list.
if (!modeTypes.contains(modeType)) {
modeTypes.add(modeType);
}
dynamicDone = true;
logger.debug("NODE {}: Thermostat Mode Report, value = {}", this.getNode().getNodeId(), modeType.getLabel());
ZWaveCommandClassValueEvent zEvent = new ZWaveCommandClassValueEvent(this.getNode().getNodeId(), endpoint, this.getCommandClass(), value);
this.getController().notifyEventListeners(zEvent);
}
use of org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent in project openhab1-addons by openhab.
the class ZWaveThermostatOperatingStateCommandClass method processThermostatOperatingStateReport.
/**
* Processes a THERMOSTAT_OPERATING_STATE_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 processThermostatOperatingStateReport(SerialMessage serialMessage, int offset, int endpoint) {
int value = serialMessage.getMessagePayloadByte(offset + 1);
logger.debug("NODE {}: Thermostat Operating State report value = {}", this.getNode().getNodeId(), value);
OperatingStateType operatingStateType = OperatingStateType.getOperatingStateType(value);
if (operatingStateType == null) {
logger.error("NODE {}: Unknown Operating State Type = {}, ignoring report.", this.getNode().getNodeId(), value);
return;
}
dynamicDone = true;
logger.debug("NODE {}: Operating State Type = {} ({})", this.getNode().getNodeId(), operatingStateType.getLabel(), value);
logger.debug("NODE {}: Thermostat Operating State Report value = {}", this.getNode().getNodeId(), operatingStateType.getLabel());
ZWaveCommandClassValueEvent zEvent = new ZWaveCommandClassValueEvent(this.getNode().getNodeId(), endpoint, this.getCommandClass(), new BigDecimal(value));
this.getController().notifyEventListeners(zEvent);
}
use of org.openhab.binding.zwave.internal.protocol.event.ZWaveCommandClassValueEvent in project openhab1-addons by openhab.
the class ZWaveBatteryCommandClass method handleApplicationCommandRequest.
/**
* {@inheritDoc}
*/
@Override
public void handleApplicationCommandRequest(SerialMessage serialMessage, int offset, int endpoint) {
logger.debug("NODE {}: Received Battery Request", this.getNode().getNodeId());
int command = serialMessage.getMessagePayloadByte(offset);
switch(command) {
case BATTERY_GET:
logger.warn("Command {} not implemented.", command);
return;
case BATTERY_REPORT:
logger.trace("Process Battery Report");
if (serialMessage.getMessagePayload().length < offset + 1) {
logger.error("NODE {}: Battery report length too short");
return;
}
batteryLevel = serialMessage.getMessagePayloadByte(offset + 1);
logger.debug("NODE {}: Battery report value = {}", this.getNode().getNodeId(), batteryLevel);
// Set battery level to 0
if (batteryLevel == 255) {
batteryLevel = 0;
batteryLow = true;
logger.debug("NODE {}: BATTERY LOW!", this.getNode().getNodeId());
} else {
batteryLow = false;
}
// If the battery level is outside bounds, then we don't know what's up!
if (batteryLevel < 0 || batteryLevel > 100) {
logger.warn("NODE {}: Battery state unknown ({})!", this.getNode().getNodeId(), batteryLevel);
batteryLevel = null;
}
ZWaveCommandClassValueEvent zEvent = new ZWaveCommandClassValueEvent(this.getNode().getNodeId(), endpoint, this.getCommandClass(), batteryLevel);
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()));
}
}
Aggregations