use of org.openhab.core.library.items.DimmerItem in project openhab1-addons by openhab.
the class AudioZone method updateItem.
@Override
public void updateItem(Item item, OmniLinkBindingConfig config, EventPublisher publisher) {
int num = 0;
String str = "";
int source = new Integer(properties.getSource());
switch(config.getObjectType()) {
case AUDIOZONE_MUTE:
num = properties.isMute() ? 1 : 0;
break;
case AUDIOZONE_POWER:
num = properties.isOn() ? 1 : 0;
break;
case AUDIOZONE_SOURCE:
num = properties.getSource();
break;
case AUDIOZONE_VOLUME:
num = properties.getVolume();
break;
case AUDIOZONE_TEXT:
if (sourceValid(source)) {
str = audioSources.get(source).formatAudioText();
}
break;
case AUDIOZONE_TEXT_FIELD1:
if (sourceValid(source)) {
str = audioSources.get(source).getAudioText(0);
}
break;
case AUDIOZONE_TEXT_FIELD2:
if (sourceValid(source)) {
str = audioSources.get(source).getAudioText(1);
}
break;
case AUDIOZONE_TEXT_FIELD3:
if (sourceValid(source)) {
str = audioSources.get(source).getAudioText(2);
}
break;
case AUDIOZONE_KEY:
num = -1;
break;
default:
return;
}
if (item instanceof DimmerItem) {
logger.debug("updating percent type {}", num);
publisher.postUpdate(item.getName(), new PercentType(num));
} else if (item instanceof NumberItem) {
logger.debug("updating number type {}", num);
publisher.postUpdate(item.getName(), new DecimalType(num));
} else if (item instanceof SwitchItem) {
logger.debug("updating switch type {}", num > 0 ? OnOffType.ON : OnOffType.OFF);
publisher.postUpdate(item.getName(), num > 0 ? OnOffType.ON : OnOffType.OFF);
} else if (item instanceof StringItem) {
logger.debug("updating string type {}", str);
publisher.postUpdate(item.getName(), new StringType(str));
}
}
use of org.openhab.core.library.items.DimmerItem in project openhab1-addons by openhab.
the class RockerSwitchInDimmerProfileTest method setUpDefaultDevice.
@Before
public void setUpDefaultDevice() {
parameterAddress = new EnoceanParameterAddress(EnoceanId.fromString(EnoceanBindingProviderMock.DEVICE_ID));
provider.setParameterAddress(parameterAddress);
provider.setItem(new DimmerItem("dummie"));
provider.setEep(EEPId.EEP_F6_02_01);
binding.addBindingProvider(provider);
}
use of org.openhab.core.library.items.DimmerItem in project openhab1-addons by openhab.
the class DigitalSTROMBinding method updateItemState.
private void updateItemState(Item item) {
if (item != null) {
Device device = deviceMap.get(item.getName());
if (device != null) {
State state = null;
if (item instanceof DimmerItem) {
state = new PercentType(getPercent(device.getMaxOutPutValue(), device.getOutputValue()));
} else if (item instanceof SwitchItem && !(item instanceof DimmerItem)) {
state = device.getOutputValue() > 0 ? OnOffType.ON : OnOffType.OFF;
} else if (item instanceof NumberItem) {
DigitalSTROMBindingConfig confItem = getConfigForItemName(item.getName());
if (confItem != null) {
if (confItem.sensor != null) {
int value = -1;
switch(confItem.sensor) {
case TEMPERATURE_INDOORS:
value = device.getTemperatureSensorValue();
if (value != -1) {
// Celsius
// TODO use resolution
state = new DecimalType((double) (value) / 40 - 43.15);
// from sensor
}
break;
case RELATIVE_HUMIDITY_INDOORS:
value = device.getHumiditySensorValue();
if (value != -1) {
// Percent
// TODO use resolution from
state = new DecimalType((double) (value) / 40);
// sensor
}
break;
case TEMPERATURE_OUTDOORS:
value = device.getTemperatureSensorValue();
if (value != -1) {
// Celsius
// TODO use resolution
state = new DecimalType((double) (value) / 40 - 43.15);
// from sensor
}
break;
case RELATIVE_HUMIDITY_OUTDOORS:
value = device.getHumiditySensorValue();
if (value != -1) {
// Percent
// TODO use resolution from
state = new DecimalType((double) (value) / 40);
// sensor
}
break;
default:
break;
}
} else if (confItem.consumption != null) {
int value = -1;
switch(confItem.consumption) {
case ACTIVE_POWER:
value = device.getPowerConsumption();
break;
case OUTPUT_CURRENT:
value = device.getEnergyMeterValue();
if (value != -1) {
state = new DecimalType(value);
}
break;
default:
break;
}
}
}
} else if (item instanceof RollershutterItem) {
DigitalSTROMBindingConfig confItem = getConfigForItemName(item.getName());
if (confItem != null) {
if (confItem.context != null && confItem.context.equals(ContextConfig.slat)) {
int output = getPercent(device.getMaxSlatPosition(), device.getSlatPosition());
state = new PercentType(100 - output);
} else if (confItem.context != null && confItem.context.equals(ContextConfig.awning)) {
int output = getPercent(device.getMaxOutPutValue(), device.getOutputValue());
state = new PercentType(output);
} else {
int output = getPercent(device.getMaxOutPutValue(), device.getOutputValue());
state = new PercentType(100 - output);
}
}
} else if (item instanceof StringItem) {
DigitalSTROMBindingConfig confItem = getConfigForItemName(item.getName());
if (confItem != null) {
if (confItem.sensor != null) {
int value = -1;
switch(confItem.sensor) {
case TEMPERATURE_INDOORS:
value = device.getTemperatureSensorValue();
if (value != -1) {
// Celsius
// TODO use resolution
state = new DecimalType((double) (value) / 40 - 43.15);
// from sensor
}
break;
case RELATIVE_HUMIDITY_INDOORS:
value = device.getHumiditySensorValue();
if (value != -1) {
// Percent
// TODO use resolution from
state = new DecimalType((double) (value) / 40);
// sensor
}
break;
case TEMPERATURE_OUTDOORS:
value = device.getTemperatureSensorValue();
if (value != -1) {
// Celsius
// TODO use resolution
state = new DecimalType((double) (value) / 40 - 43.15);
// from sensor
}
break;
case RELATIVE_HUMIDITY_OUTDOORS:
value = device.getHumiditySensorValue();
if (value != -1) {
// Percent
// TODO use resolution from
state = new DecimalType((double) (value) / 40);
// sensor
}
break;
default:
break;
}
} else if (confItem.consumption != null) {
int value = -1;
switch(confItem.consumption) {
case ACTIVE_POWER:
value = device.getPowerConsumption();
if (value != -1) {
state = new DecimalType(value);
}
break;
case OUTPUT_CURRENT:
value = device.getEnergyMeterValue();
if (value != -1) {
state = new DecimalType(value);
}
break;
default:
break;
}
}
}
}
eventPublisher.postUpdate(item.getName(), state);
} else {
logger.error("couldn't update item state, because device is null: " + item.getName());
}
} else {
logger.error("couldn't update item state, because item is null");
}
}
use of org.openhab.core.library.items.DimmerItem in project openhab1-addons by openhab.
the class HueGenericBindingProvider method processBindingConfiguration.
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
super.processBindingConfiguration(context, item, bindingConfig);
try {
if (bindingConfig != null) {
String[] configParts = bindingConfig.split(";");
if (item instanceof ColorItem) {
BindingConfig hueBindingConfig = new HueBindingConfig(configParts[0], BindingType.rgb.name(), null);
addBindingConfig(item, hueBindingConfig);
} else if (item instanceof DimmerItem) {
BindingConfig hueBindingConfig = new HueBindingConfig(configParts[0], configParts.length < 2 ? null : configParts[1], configParts.length < 3 ? null : configParts[2]);
addBindingConfig(item, hueBindingConfig);
} else if (item instanceof SwitchItem) {
BindingConfig hueBindingConfig = new HueBindingConfig(configParts[0], BindingType.switching.name(), null);
addBindingConfig(item, hueBindingConfig);
}
} else {
logger.warn("bindingConfig is NULL (item=" + item + ") -> processing bindingConfig aborted!");
}
} catch (ArrayIndexOutOfBoundsException e) {
logger.warn("bindingConfig is invalid (item=" + item + ") -> processing bindingConfig aborted!");
}
}
use of org.openhab.core.library.items.DimmerItem in project openhab1-addons by openhab.
the class LightwaveRfBindingFunctionalTest method testOffMessageSentByAndriodApp.
@Test
public void testOffMessageSentByAndriodApp() throws Exception {
String message = "030271,102,!R3D1F0|Living Room|Side Light 1 Off";
testReceivingACommandAndVerify(new DimmerItem("LivingRoom"), "room=3,device=1,type=DIMMER", message, OnOffType.OFF);
}
Aggregations