use of org.openhab.binding.wago.internal.WagoGenericBindingProvider.WagoBindingConfig in project openhab1-addons by openhab.
the class WagoBinding method updateItem.
public void updateItem(String itemName, String couplerName, int module, boolean[] states) {
for (WagoBindingProvider provider : providers) {
if (provider.providesBindingFor(itemName)) {
WagoBindingConfig conf = provider.getConfig(itemName);
if (conf.couplerName.equals(couplerName) && conf.module == module) {
State currentState = conf.getItemState();
State newState = conf.translateBoolean2State(states[conf.channel]);
if (!newState.equals(currentState)) {
eventPublisher.postUpdate(itemName, newState);
}
}
}
}
}
use of org.openhab.binding.wago.internal.WagoGenericBindingProvider.WagoBindingConfig in project openhab1-addons by openhab.
the class WagoBinding method updateItemPWM.
public void updateItemPWM(String itemName, String couplerName, int module, int[] values) {
for (WagoBindingProvider provider : providers) {
if (provider.providesBindingFor(itemName)) {
WagoBindingConfig conf = provider.getConfig(itemName);
if (conf.couplerName.equals(couplerName) && conf.module == module) {
State currentState = conf.getItemState();
State newState;
if (conf.getItem() instanceof DimmerItem) {
newState = new PercentType((int) ((float) values[conf.channel] / 1023 * 100));
} else if (conf.getItem() instanceof SwitchItem) {
if (values[conf.channel] == 0) {
newState = OnOffType.OFF;
} else {
newState = OnOffType.ON;
}
} else {
logger.debug("Unsupported Itemtype");
return;
}
if (!newState.equals(currentState)) {
eventPublisher.postUpdate(itemName, newState);
}
}
}
}
}
use of org.openhab.binding.wago.internal.WagoGenericBindingProvider.WagoBindingConfig in project openhab1-addons by openhab.
the class WagoBinding method internalReceiveCommand.
/**
* @{inheritDoc
*/
@Override
protected void internalReceiveCommand(String itemName, Command command) {
for (WagoBindingProvider provider : providers) {
if (provider.providesBindingFor(itemName)) {
WagoBindingConfig conf = provider.getConfig(itemName);
FBCoupler coupler = getCoupler(conf.couplerName);
coupler.executeCommand(command, conf);
}
}
}
Aggregations