Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #13 from openhab/master
Browse files Browse the repository at this point in the history
Merge with master
  • Loading branch information
peuter committed Jan 27, 2014
2 parents 6504408 + 49ae45e commit b047c9a
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
import org.openhab.core.binding.AbstractActiveBinding;
import org.openhab.core.items.Item;
import org.openhab.core.library.items.ContactItem;
import org.openhab.core.library.items.DateTimeItem;
import org.openhab.core.library.items.NumberItem;
import org.openhab.core.library.items.RollershutterItem;
import org.openhab.core.library.items.SwitchItem;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType;
Expand Down Expand Up @@ -245,6 +247,8 @@ private State createState(Class<? extends Item> itemType, String transformedResp
return OnOffType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(RollershutterItem.class)) {
return PercentType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(DateTimeItem.class)) {
return DateTimeType.valueOf(transformedResponse);
} else {
return StringType.valueOf(transformedResponse);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


/**
* Implements the communcation with Intertechno devices via CUL devices.
* Implements the communication with Intertechno devices via CUL devices.
* Currently it is only possible to send commands.
*
* @author Till Klocke
Expand Down Expand Up @@ -75,7 +75,7 @@ public CULIntertechnoBinding() {
}

public void activate() {
bindCULHanlder();
bindCULHandler();
}

public void deactivate() {
Expand All @@ -91,11 +91,11 @@ private void setNewDeviceName(String newDeviceName) {
CULManager.close(cul);
}
deviceName = newDeviceName;
bindCULHanlder();
bindCULHandler();
}
}

private void bindCULHanlder() {
private void bindCULHandler() {
if (!StringUtils.isEmpty(deviceName)) {
try {
cul = CULManager.getOpenCULHandler(deviceName, CULMode.SLOW_RF);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public void validateItemType(Item item, String bindingConfig)

/**
* config of style
* {intertechno="type=<classic|fls|rev>;group=<group>;address=<address>"}
* <code>{{@literal intertechno="type=<classic|fls|rev>;group=<group>;address=<address>"}}</code><br>
*
* {@inheritDoc}
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class AbstractIntertechnoParser implements

/**
* Encode an integer as String for sending it via Intertechno. Numbers are
* repesented as "binary" Strings where each letter represents a byte. It si
* represented as "binary" Strings where each letter represents a byte. It is
* configurable which letters represents 0 and which represents 1.
*
* @param length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
import org.openhab.core.binding.AbstractActiveBinding;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
import org.openhab.io.net.http.HttpUtil;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedService;
Expand Down Expand Up @@ -112,7 +114,7 @@ protected void execute() {

try {
Object propertyValue = PropertyUtils.getProperty(resource, propertyName);
State state = createState(propertyValue.getClass(), propertyValue);
State state = createState(propertyValue);
if (state != null) {
eventPublisher.postUpdate(itemName, state);
}
Expand Down Expand Up @@ -211,22 +213,38 @@ private <R extends KoubachiResource> R findResource(String id, List<R> resources
}

/**
* Creates an openHAB {@link State} in accordance to the given {@code dataType}. Currently
* {@link Date} and {@link BigDecimal} are handled explicitly. All other {@code dataTypes}
* are mapped to {@link StringType}.
* Creates an openHAB {@link State} in accordance to the class of the given
* {@code propertyValue}. Currently {@link Date}, {@link BigDecimal} and
* {@link Boolean} are handled explicitly. All other {@code dataTypes} are
* mapped to {@link StringType}.
* <p>
* If {@code propertyValue} is {@code null}, {@link UnDefType#NULL} will be
* returned.
*
* @param dataType
* @param propertyValue
*
* @return the new {@link State} in accordance to {@code dataType}. Will never be {@code null}.
* @return the new {@link State} in accordance to {@code dataType}. Will
* never be {@code null}.
*/
private State createState(Class<?> dataType, Object propertyValue) {
private State createState(Object propertyValue) {
if(propertyValue == null) {
return UnDefType.NULL;
}

Class<?> dataType = propertyValue.getClass();

if (Date.class.isAssignableFrom(dataType)) {
Calendar calendar = Calendar.getInstance();
calendar.setTime((Date) propertyValue);
return new DateTimeType(calendar);
} else if (BigDecimal.class.isAssignableFrom(dataType)) {
return new DecimalType((BigDecimal) propertyValue);
} else if (Boolean.class.isAssignableFrom(dataType)) {
if((Boolean) propertyValue) {
return OnOffType.ON;
} else {
return OnOffType.OFF;
}
} else {
return new StringType(propertyValue.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.openhab.core.library.items.DateTimeItem;
import org.openhab.core.library.items.NumberItem;
import org.openhab.core.library.items.StringItem;
import org.openhab.core.library.items.SwitchItem;
import org.openhab.model.item.binding.AbstractGenericBindingProvider;
import org.openhab.model.item.binding.BindingConfigParseException;

Expand Down Expand Up @@ -49,10 +50,11 @@ public String getBindingType() {
*/
@Override
public void validateItemType(Item item, String bindingConfig) throws BindingConfigParseException {
if (!(item instanceof NumberItem || item instanceof StringItem || item instanceof DateTimeItem)) {
if (!(item instanceof NumberItem || item instanceof StringItem || item instanceof DateTimeItem
|| item instanceof SwitchItem)) {
throw new BindingConfigParseException("item '" + item.getName()
+ "' is of type '" + item.getClass().getSimpleName()
+ "', only Number-, String- and DateTimeItems are allowed - please check your *.items configuration");
+ "', only Number-, String-, DateTime- and SwitchItems are allowed - please check your *.items configuration");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,30 @@ public class Plant extends KoubachiResource {
Date lastWaterAt;
Date nextWaterAt;

Boolean vdmWaterPending;
String vdmWaterInstruction;
BigDecimal vdmWaterLevel;

Boolean vdmMistPending;
String vdmMistInstruction;
BigDecimal vdmMistLevel;

Boolean vdmFertilizerPending;
String vdmFertilizerInstruction;
BigDecimal vdmFertilizerLevel;

Boolean vdmTemperaturePending;
String vdmTemperatureAdvice;
String vdmTemperatureHint;
String vdmTemperatureInstruction;
BigDecimal vdmTemperatureLevel;

Boolean vdmLightPending;
String vdmLightAdvice;
String vdmLightHint;
String vdmLightInstruction;
BigDecimal vdmLightLevel;



public String getName() {
return name;
}
Expand Down Expand Up @@ -85,8 +95,12 @@ public Date getLastWaterAt() {
public Date getNextWaterAt() {
return nextWaterAt;
}



@JsonProperty("vdm_water_pending")
public Boolean getVdmWaterPending() {
return vdmWaterPending;
}

@JsonProperty("vdm_water_instruction")
public String getVdmWaterInstruction() {
return vdmWaterInstruction;
Expand All @@ -96,7 +110,12 @@ public String getVdmWaterInstruction() {
public BigDecimal getVdmWaterLevel() {
return vdmWaterLevel;
}


@JsonProperty("vdm_mist_pending")
public Boolean getVdmMistPending() {
return vdmMistPending;
}

@JsonProperty("vdm_mist_instruction")
public String getVdmMistInstruction() {
return vdmMistInstruction;
Expand All @@ -107,6 +126,11 @@ public BigDecimal getVdmMistLevel() {
return vdmMistLevel;
}

@JsonProperty("vdm_fertilizer_pending")
public Boolean getVdmFertilizerPending() {
return vdmFertilizerPending;
}

@JsonProperty("vdm_fertilizer_instruction")
public String getVdmFertilizerInstruction() {
return vdmFertilizerInstruction;
Expand All @@ -116,7 +140,17 @@ public String getVdmFertilizerInstruction() {
public BigDecimal getVdmFertilizerLevel() {
return vdmFertilizerLevel;
}


@JsonProperty("vdm_temperature_pending")
public Boolean getVdmTemperaturePending() {
return vdmTemperaturePending;
}

@JsonProperty("vdm_temperature_advice")
public String getVdmTemperatureAdvice() {
return vdmTemperatureAdvice;
}

@JsonProperty("vdm_temperature_hint")
public String getVdmTemperatureHint() {
return vdmTemperatureHint;
Expand All @@ -131,7 +165,17 @@ public String getVdmTemperatureInstruction() {
public BigDecimal getVdmTemperatureLevel() {
return vdmTemperatureLevel;
}


@JsonProperty("vdm_light_pending")
public Boolean getVdmLightPending() {
return vdmLightPending;
}

@JsonProperty("vdm_light_advice")
public String getVdmLightAdvice() {
return vdmLightAdvice;
}

@JsonProperty("vdm_light_hint")
public String getVdmLightHint() {
return vdmLightHint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public SerialMessage stopLevelChangeMessage() {
logger.debug("Creating new message for application command SWITCH_MULTILEVEL_STOP_LEVEL_CHANGE for node {}", this.getNode().getNodeId());
SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.SendData, SerialMessagePriority.Set);
byte[] newPayload = { (byte) this.getNode().getNodeId(),
3,
2,
(byte) getCommandClass().getKey(),
(byte) SWITCH_MULTILEVEL_STOP_LEVEL_CHANGE };
result.setMessagePayload(newPayload);
Expand Down
42 changes: 41 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
</modules>

<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-2</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>${tycho-groupid}</groupId>
Expand Down Expand Up @@ -265,6 +272,39 @@
<artifactId>org.apache.felix.fileinstall</artifactId>
<version>3.2.6</version>
</dependency>
</dependencies>
</dependencies>

<profiles>
<profile>
<id>deploy-p2</id>
<properties>
<wagon.version>1.0-beta-4</wagon.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-4</version>
<executions>
<execution>
<id>upload-p2-repo</id>
<phase>install</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<serverId>${p2.repo.serverid}</serverId>
<url>${p2.repo.url}</url>
<fromDir>${project.basedir}/products/org.openhab.runtime.product/target/repository</fromDir>
<toDir>${p2.repo.dir}</toDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

0 comments on commit b047c9a

Please sign in to comment.