Skip to content
Snippets Groups Projects
Commit 6f5b3495 authored by René Schöne's avatar René Schöne
Browse files

Add acceleration to SmartPhone thing definition.

parent 9e26beb0
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment