state = new PercentType(convertStatus);
updateState(CHANNEL_DIMMER, state);
} else {
- logger.warn("updateTouchWandUnitState incompatible TouchWandUnitData instance");
+ logger.debug("updateTouchWandUnitState incompatible TouchWandUnitData instance");
}
}
}
state = new PercentType(convertStatus);
updateState(CHANNEL_SHUTTER, state);
} else {
- logger.warn("updateTouchWandUnitState incompatible TouchWandUnitData instance");
+ logger.debug("updateTouchWandUnitState incompatible TouchWandUnitData instance");
}
}
}
}
updateState(CHANNEL_SWITCH, state);
} else {
- logger.warn("updateTouchWandUnitState incompatible TouchWandUnitData instance");
+ logger.debug("updateTouchWandUnitState incompatible TouchWandUnitData instance");
}
}
triggerChannel(CHANNEL_WALLCONTROLLER_ACTION, action);
}
timeLastEventMs = status.getTs();
+ } else {
+ logger.debug("updateTouchWandUnitState incompatible TouchWandUnitData instance");
}
}
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonSyntaxException;
+
/**
* The {@link TouchWandControllerDiscoveryService} Discovery service for Touchwand Controllers.
*
mySocket.receive(datagram);
InetAddress address = datagram.getAddress();
String sentence = new String(dgram.getData(), 0, dgram.getLength(), StandardCharsets.US_ASCII);
- addDeviceDiscoveryResult(sentence, address.getHostAddress().toString());
+ JsonObject bridge = JsonParser.parseString(sentence).getAsJsonObject();//
+ String name = bridge.get("name").getAsString();
+ addDeviceDiscoveryResult(name, address.getHostAddress().toString());
logger.debug("Received Datagram from {}:{} on Port {} message {}", address.getHostAddress(),
dgram.getPort(), mySocket.getLocalPort(), sentence);
}
- } catch (IOException e) {
+ } catch (IOException | JsonSyntaxException e) {
if (!isInterrupted()) {
- logger.warn("Error while receiving {}", e.getMessage());
+ logger.debug("Error while receiving {}", e.getMessage());
} else {
logger.debug("Receiver thread was interrupted {}", e.getMessage());
}
@Override
protected void startScan() {
if (touchWandBridgeHandler.getThing().getStatus() != ThingStatus.ONLINE) {
- logger.warn("Could not scan units while bridge offline");
+ logger.debug("Could not scan units while bridge offline");
return;
}
break;
case TYPE_SWITCH:
addDeviceDiscoveryResult(touchWandUnit, THING_TYPE_SWITCH);
- notifyListeners(touchWandUnit);
break;
case TYPE_DIMMER:
addDeviceDiscoveryResult(touchWandUnit, THING_TYPE_DIMMER);
- notifyListeners(touchWandUnit);
break;
case TYPE_SHUTTER:
addDeviceDiscoveryResult(touchWandUnit, THING_TYPE_SHUTTER);
default:
continue;
}
+ notifyListeners(touchWandUnit);
}
} catch (JsonSyntaxException e) {
logger.warn("Could not parse unit {}", e.getMessage());
@NonNullByDefault
public class TouchWandShutterSwitchUnitData extends TouchWandUnitData {
- private Integer currStatus = 0;
+ private int currStatus = 0;
@Override
public Integer getCurrStatus() {
*/
package org.openhab.binding.touchwand.internal.dto;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-
/**
* The {@link TouchWandUnitDataWallController} implements WallController unit
* property.
*
* @author Roie Geron - Initial contribution
*/
-@NonNullByDefault
public class TouchWandUnitDataWallController extends TouchWandUnitData {
private CurrStatus currStatus = new CurrStatus();
+ // currStatus can be null since the object is created by gson fromJson
+ // in case the key is null or not exist , the variable will be null.
+ // if this is the case , default status is created
+
@Override
public Csc getCurrStatus() {
+ if (currStatus == null) {
+ currStatus = new CurrStatus();
+ }
return currStatus.getCsc();
}
type = TYPE_UNKNOWN;
}
- if (!jsonUnit.has("currStatus") || (jsonUnit.get("currStatus") == null)) {
- type = TYPE_UNKNOWN;
- }
-
switch (type) {
case TYPE_WALLCONTROLLER:
touchWandUnit = gson.fromJson(jsonUnit, TouchWandUnitDataWallController.class);