diff --git a/ESH-INF/thing/thing-types.xml b/ESH-INF/thing/thing-types.xml index 3b9bf05abad0af5969c68a5aa0a5c7d2842f2939..9ff3102aaa716b9d3f457003724966faa9361aab 100644 --- a/ESH-INF/thing/thing-types.xml +++ b/ESH-INF/thing/thing-types.xml @@ -188,6 +188,15 @@ <channels> <channel typeId="brightness-type" id="brightness" /> + <channel typeId="acceleration-type" id="acceleration-x"> + <label>Acceleration X</label> + </channel> + <channel typeId="acceleration-type" id="acceleration-y"> + <label>Acceleration Y</label> + </channel> + <channel typeId="acceleration-type" id="acceleration-z"> + <label>Acceleration Z</label> + </channel> <channel typeId="rotation-type" id="rotation-x"> <label>Rotation X</label> </channel> diff --git a/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartWatchHandler.java b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartWatchHandler.java index 1369c672e224572aa2631e9341589c9759db1448..5e7c953b029315a1a0b049bd210ed5ecb70a0db9 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartWatchHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartWatchHandler.java @@ -24,6 +24,7 @@ import org.eclipse.smarthome.core.library.types.DecimalType; import org.eclipse.smarthome.core.thing.ChannelUID; import org.eclipse.smarthome.core.thing.Thing; import org.eclipse.smarthome.core.types.Command; +import org.eclipse.smarthome.core.types.RefreshType; import org.openhab.binding.openlicht.internal.ConfigurationHolder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,13 +69,10 @@ public abstract class AbstractSmartWatchHandler extends AbstractMqttHandler { @Override public void handleCommand(ChannelUID channelUID, Command command) { + if (command instanceof RefreshType) { + return; + } logger.debug("Got command for read-only thing: {} {}", channelUID.getAsString(), command.toFullString()); - // TODO: handle command - - // Note: if communication with thing fails for some reason, - // indicate that by setting the status with detail information - // updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, - // "Could not control device at IP address x.x.x.x"); } @Override diff --git a/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartphoneHandler.java b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartphoneHandler.java index 52f92aa3f78ea95bd64bf0f4aae30e09f7becbdb..6ba499cc529d2c10552ecedb9ef7625c5345b254 100644 --- a/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartphoneHandler.java +++ b/src/main/java/org/openhab/binding/openlicht/handler/AbstractSmartphoneHandler.java @@ -64,6 +64,11 @@ public abstract class AbstractSmartphoneHandler extends AbstractMqttHandler { case MQTT_CATEGORY_BRIGHTNESS: updateState(CHANNEL_BRIGHTNESS, new DecimalType(buffer.getFloat())); break; + case MQTT_CATEGORY_ACCELERATION: + doubleBuffer = buffer.asDoubleBuffer(); + updateState(CHANNEL_ACCELERATION_X, new DecimalType(doubleBuffer.get(0))); + updateState(CHANNEL_ACCELERATION_Y, new DecimalType(doubleBuffer.get(1))); + updateState(CHANNEL_ACCELERATION_Z, new DecimalType(doubleBuffer.get(2))); case MQTT_CATEGORY_ROTATION: doubleBuffer = buffer.asDoubleBuffer(); updateState(CHANNEL_ROTATION_X, new DecimalType(doubleBuffer.get(0))); @@ -78,6 +83,9 @@ public abstract class AbstractSmartphoneHandler extends AbstractMqttHandler { case MQTT_CATEGORY_BRIGHTNESS: updateState(CHANNEL_BRIGHTNESS, new DecimalType(Double.parseDouble(message))); break; + case MQTT_CATEGORY_ACCELERATION: + MqttUtils.handleAcceleration(message, this::updateState); + break; case MQTT_CATEGORY_ROTATION: MqttUtils.handleRotation(message, this::updateState); break;