use of org.openhab.binding.lcn.connection.ModInfo in project openhab1-addons by openhab.
the class OutputDimAbs method send.
/** {@inheritDoc} */
@Override
public void send(Connection conn, Item item, Command cmd) {
double value = this.percent;
if (value == -1 && cmd instanceof PercentType) {
value = ((PercentType) cmd).doubleValue();
}
if (value >= 0 && value <= 100) {
if (this.outputId == -1) {
// All
// Default
boolean is1805 = false;
if (!this.addr.isGroup()) {
ModInfo info = conn.getModInfo((LcnAddrMod) this.addr);
if (info != null) {
is1805 = info.getSwAge() >= 0x180501;
}
}
conn.queue(this.addr, !this.addr.isGroup(), PckGenerator.dimAllOutputs(value, LcnDefs.timeToRampValue(this.rampMSec), is1805));
} else {
// Single
conn.queue(this.addr, !this.addr.isGroup(), PckGenerator.dimOutput(this.outputId, value, LcnDefs.timeToRampValue(this.rampMSec)));
}
}
}
use of org.openhab.binding.lcn.connection.ModInfo in project openhab1-addons by openhab.
the class OutputDimAbs method register.
/** {@inheritDoc} */
@Override
public void register(Connection conn) {
if (!this.addr.isGroup()) {
long currTime = System.nanoTime();
ModInfo info = conn.updateModuleData((LcnAddrMod) this.addr);
if (this.outputId == -1) {
// All
if (!info.requestSwAge.isActive()) {
// Firmware version is required
info.requestSwAge.nextRequestIn(0, currTime);
}
} else {
// Single: Allow visualization
if (!info.requestStatusOutputs.get(this.outputId).isActive()) {
info.requestStatusOutputs.get(this.outputId).nextRequestIn(0, currTime);
}
}
}
}
use of org.openhab.binding.lcn.connection.ModInfo in project openhab1-addons by openhab.
the class VarAbs method send.
/** {@inheritDoc} */
@Override
public void send(Connection conn, Item item, Command cmd) {
LcnDefs.VarValue value = this.value;
if (value == null && cmd instanceof DecimalType) {
value = LcnDefs.VarValue.fromVarUnit(((DecimalType) cmd).doubleValue(), this.unit, true);
}
if (value != null) {
try {
boolean is2013 = !this.forceOld;
ModInfo info = null;
if (!this.addr.isGroup()) {
info = conn.getModInfo((LcnAddrMod) this.addr);
if (info != null) {
is2013 = info.getSwAge() >= 0x170206;
}
}
if (LcnDefs.Var.toVarId(this.var) != -1) {
// Absolute commands for variables are not supported.
if (this.addr.getId() == 4 && this.addr.isGroup()) {
// group 4 are status messages
conn.queue(this.addr, !this.addr.isGroup(), PckGenerator.updateStatusVar(this.var, value.toNative()));
} else {
// We fake the missing command by using reset and relative commands.
conn.queue(this.addr, !this.addr.isGroup(), PckGenerator.varReset(this.var, is2013));
conn.queue(this.addr, !this.addr.isGroup(), PckGenerator.varRel(this.var, LcnDefs.RelVarRef.CURRENT, value.toNative(), is2013));
}
} else {
conn.queue(this.addr, !this.addr.isGroup(), PckGenerator.varAbs(this.var, value.toNative()));
}
// Force a status update
if (info != null && LcnDefs.Var.shouldPollStatusAfterCommand(this.var, is2013) && info.requestStatusVars.containsKey(this.var)) {
info.requestStatusVars.get(this.var).nextRequestIn(ModInfo.STATUS_REQUEST_DELAY_AFTER_COMMAND_MSEC, System.nanoTime());
}
} catch (IllegalArgumentException ex) {
logger.warn(String.format("Variable of type %s does not support \"set absolute\" commands.", this.var));
}
}
}
use of org.openhab.binding.lcn.connection.ModInfo in project openhab1-addons by openhab.
the class LockRegulator method send.
/** {@inheritDoc} */
@Override
public void send(Connection conn, Item item, Command cmd) {
conn.queue(this.addr, !this.addr.isGroup(), PckGenerator.lockRegulator(this.regId, this.state));
// Force a status update
if (!this.addr.isGroup() && !this.state) {
LcnDefs.Var var = this.regId == 0 ? LcnDefs.Var.R1VARSETPOINT : LcnDefs.Var.R2VARSETPOINT;
ModInfo info = conn.getModInfo((LcnAddrMod) this.addr);
if (info != null && LcnDefs.Var.shouldPollStatusAfterRegulatorLock(info.getSwAge(), this.state) && info.requestStatusVars.containsKey(var)) {
info.requestStatusVars.get(var).nextRequestIn(ModInfo.STATUS_REQUEST_DELAY_AFTER_COMMAND_MSEC, System.nanoTime());
}
}
}
use of org.openhab.binding.lcn.connection.ModInfo in project openhab1-addons by openhab.
the class LockRegulator method register.
/** {@inheritDoc} */
@Override
public void register(Connection conn) {
if (!this.addr.isGroup()) {
long currTime = System.nanoTime();
ModInfo info = conn.updateModuleData((LcnAddrMod) this.addr);
if (!info.requestSwAge.isActive()) {
// Firmware version is required
info.requestSwAge.nextRequestIn(0, currTime);
}
LcnDefs.Var var = this.regId == 0 ? LcnDefs.Var.R1VARSETPOINT : LcnDefs.Var.R2VARSETPOINT;
if (info.requestStatusVars.containsKey(var) && !info.requestStatusVars.get(var).isActive()) {
info.requestStatusVars.get(var).nextRequestIn(0, currTime);
}
}
}
Aggregations