use of org.openhab.binding.lcn.connection.ModInfo in project openhab1-addons by openhab.
the class LockKeysTemporary method send.
/** {@inheritDoc} */
@Override
public void send(Connection conn, Item item, Command cmd) {
boolean sent = false;
for (int tableId = 0; tableId < 4; ++tableId) {
for (int keyId = 0; keyId < 8; ++keyId) {
if (this.keys[tableId][keyId]) {
// Lock if at least one key should be locled
if (tableId == 0) {
// Only table A is currently supported
conn.queue(this.addr, !this.addr.isGroup(), PckGenerator.lockKeyTabATemporary(this.time, this.timeUnit, this.keys[tableId]));
sent = true;
} else {
logger.error(String.format("Locking keys from table %s (temporary) is not supported.", tableId == 1 ? "B" : tableId == 2 ? "C" : "D"));
}
break;
}
}
}
// Force status update (status is polled and should be updated now)
if (sent && !this.addr.isGroup()) {
ModInfo info = conn.getModInfo((LcnAddrMod) this.addr);
if (info != null) {
info.requestStatusLockedKeys.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 LockedRegulatorVisualize method register.
/** {@inheritDoc} */
@Override
public void register(Connection conn) {
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);
}
}
use of org.openhab.binding.lcn.connection.ModInfo in project openhab1-addons by openhab.
the class VarRel 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);
}
if (info.requestStatusVars.containsKey(this.var) && !info.requestStatusVars.get(this.var).isActive()) {
info.requestStatusVars.get(this.var).nextRequestIn(0, currTime);
}
}
}
use of org.openhab.binding.lcn.connection.ModInfo in project openhab1-addons by openhab.
the class VarRel method send.
/** {@inheritDoc} */
@Override
public void send(Connection conn, Item item, Command cmd) {
// No ack. for
boolean ack = !item.getAcceptedDataTypes().contains(PercentType.class) && !this.addr.isGroup();
// many of them)
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;
}
}
conn.queue(this.addr, ack, PckGenerator.varRel(this.var, this.targetLcnType, this.value.toNative(), is2013));
// 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 relative commands.", this.var));
}
}
use of org.openhab.binding.lcn.connection.ModInfo in project openhab1-addons by openhab.
the class VarReset method send.
/** {@inheritDoc} */
@Override
public void send(Connection conn, Item item, Command cmd) {
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;
}
}
conn.queue(this.addr, !this.addr.isGroup(), PckGenerator.varReset(this.var, is2013));
// 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 \"reset to 0\" commands.", this.var));
}
}
Aggregations