@Test
public void testParseOperationHours() {
- String s = "390001120201004004DC0B00004104F40300004204642300004304000000004404000000004504000000004604000000004704000000004800";
-
MadokaValue mv = new MadokaValue(0, 4, new byte[] { (byte) 0xF4, 0x03, 0x00, 0x00 });
- // MadokaValue mv = new MadokaValue(0, 4, new byte[] { 0x00, 0x00, 0x03, (byte) 0xF4 });
-
Long v = mv.getComputedValue(ByteOrder.LITTLE_ENDIAN);
assertEquals(1012, v);
}
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
-import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
}
private void changeHomekitMode(String homekitmode) throws DaikinCommunicationException {
- ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (HomekitMode.OFF.getValue().equals(homekitmode)) {
changePower(false);
} else {
// Some devices report crappy UPnP device description so manufacturer and model are ""
// In this case we try to find the match in friendlyName
final String uname = friendlyName.toUpperCase();
- for (Map.Entry<String, Set<String>> entry : SUPPORTED_RADIO_MODELS.entrySet()) {
- for (Set<String> set : SUPPORTED_RADIO_MODELS.values()) {
- for (String model : set) {
- if ((model != null) && !model.isEmpty() && uname.contains(model)) {
- return new ThingUID(THING_TYPE_RADIO, serialNumber);
- }
+ for (Set<String> set : SUPPORTED_RADIO_MODELS.values()) {
+ for (String model : set) {
+ if ((model != null) && !model.isEmpty() && uname.contains(model)) {
+ return new ThingUID(THING_TYPE_RADIO, serialNumber);
}
}
}
httpHeaders.setProperty("Cookie", "logintype-88=01");
try {
- String response = HttpUtil.executeUrl(httpMethod, url, httpHeaders, stream,
+ HttpUtil.executeUrl(httpMethod, url, httpHeaders, stream,
"application/x-www-form-urlencoded; charset=UTF-8", timeout);
} catch (IOException e) {
logger.debug("Communication with device failed", e);
import org.oasis_open.docs.wsn.b_2.SubscribeResponse;
import org.oasis_open.docs.wsn.b_2.TopicExpressionType;
import org.oasis_open.docs.wsn.b_2.Unsubscribe;
-import org.oasis_open.docs.wsn.b_2.UnsubscribeResponse;
import org.oasis_open.docs.wsn.bw_2.InvalidFilterFault;
import org.oasis_open.docs.wsn.bw_2.InvalidMessageContentExpressionFault;
import org.oasis_open.docs.wsn.bw_2.InvalidProducerPropertiesExpressionFault;
public void unsubscribe() {
if (subscription != null) {
try {
- UnsubscribeResponse response = subscription.unsubscribe(new Unsubscribe());
+ subscription.unsubscribe(new Unsubscribe());
logger.debug("Unsubscribing the subscription with ID '{}' for '{}' ", getSubscriptionID(),
getThing().getUID());
} catch (UnableToDestroySubscriptionFault | ResourceUnknownFault e) {
import org.openhab.binding.innogysmarthome.internal.InnogyBindingConstants;
import org.openhab.binding.innogysmarthome.internal.client.InnogyClient;
import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
-import org.openhab.binding.innogysmarthome.internal.client.entity.capability.State;
import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
import org.openhab.binding.innogysmarthome.internal.client.entity.link.Link;
import org.openhab.binding.innogysmarthome.internal.client.entity.message.Message;
if (d.isRadioDevice() && !d.isReachable()) {
logger.debug(">> CAP-State: unknown (device NOT REACHABLE).");
} else {
- if (c.hasState()) {
- final State state = c.getCapabilityState().getState();
- } else {
+ if (!c.hasState()) {
logger.debug(">> CAP-State: unknown (NULL)");
}
}
Matcher matcher = RESPONSE_PATTERN.matcher(response);
if (matcher.matches()) {
- String byteCountAsString = matcher.group(1);
message = matcher.group(2);
}
new Object[] { new String(theBuffer.array()),
theChannel.getLocalAddress(),
theChannel.getRemoteAddress() });
- int byteswritten = theChannel.write(theBuffer);
+ theChannel.write(theBuffer);
} catch (NotYetConnectedException e) {
theHandler.updateStatus(ThingStatus.OFFLINE,
ThingStatusDetail.COMMUNICATION_ERROR,
import org.apache.commons.lang3.StringUtils;
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceClassObject;
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceMetaData;
-import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceOperation;
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.DeviceProperty;
import org.openhab.binding.miele.internal.handler.MieleBridgeHandler.HomeDevice;
import org.openhab.core.thing.Bridge;
// Ignore - this is due to an unrecognized and not yet reverse-engineered array property
}
}
-
- for (JsonElement operation : dco.Operations.getAsJsonArray()) {
- try {
- DeviceOperation devop = gson.fromJson(operation, DeviceOperation.class);
- DeviceMetaData pmd = gson.fromJson(devop.Metadata, DeviceMetaData.class);
- } catch (Exception p) {
- // Ignore - this is due to an unrecognized and not yet reverse-engineered array property
- }
- }
}
}
}
*/
@Test
public void testCopyIfStampAfterEqual() {
- Object key = new Object();
Object val = new Object();
AtomicStampedValue<Object> keyValue = new AtomicStampedValue<>(42L, val);
AtomicStampedValue<Object> copy = keyValue.copyIfStampAfter(42L);
assertThat(keyValue.getValue(), is(equalTo(copy.getValue())));
// after update they live life of their own
- Object key2 = new Object();
Object val2 = new Object();
copy.update(-99L, val2);
assertThat(keyValue.getValue(), is(equalTo(copy.getValue())));
// after update they live life of their own
- Object key2 = new Object();
Object val2 = new Object();
copy.update(-99L, val2);
* @param topic the topic (as specified during registration)
*/
public final void unregisterDiscoveryListener(MQTTTopicDiscoveryParticipant listener, String topic) {
- Map<MQTTTopicDiscoveryParticipant, @Nullable TopicSubscribe> topicListeners = discoveryTopics.compute(topic,
- (k, v) -> {
- if (v == null) {
- logger.warn(
- "Tried to unsubscribe {} from discovery topic {} on broker {} but topic not registered at all. Check discovery logic!",
- listener, topic, thing.getUID());
- return null;
- }
- v.compute(listener, (l, w) -> {
- if (w == null) {
- logger.warn(
- "Tried to unsubscribe {} from discovery topic {} on broker {} but topic not registered for listener. Check discovery logic!",
- listener, topic, thing.getUID());
- } else {
- w.stop();
- logger.trace("Unsubscribed {} from discovery topic {} on broker {}", listener, topic,
- thing.getUID());
- }
- return null;
- });
- return v.isEmpty() ? null : v;
- });
+ discoveryTopics.compute(topic, (k, v) -> {
+ if (v == null) {
+ logger.warn(
+ "Tried to unsubscribe {} from discovery topic {} on broker {} but topic not registered at all. Check discovery logic!",
+ listener, topic, thing.getUID());
+ return null;
+ }
+ v.compute(listener, (l, w) -> {
+ if (w == null) {
+ logger.warn(
+ "Tried to unsubscribe {} from discovery topic {} on broker {} but topic not registered for listener. Check discovery logic!",
+ listener, topic, thing.getUID());
+ } else {
+ w.stop();
+ logger.trace("Unsubscribed {} from discovery topic {} on broker {}", listener, topic,
+ thing.getUID());
+ }
+ return null;
+ });
+ return v.isEmpty() ? null : v;
+ });
}
/**
updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_CONTACT,
getString(sdata.sensor.state).equalsIgnoreCase(SHELLY_API_DWSTATE_OPEN) ? OpenClosedType.OPEN
: OpenClosedType.CLOSED);
- String sensorError = getString(sdata.sensorError);
boolean changed = thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_ERROR,
getStringType(sdata.sensorError));
if (changed) {
actionUrl = buildActionUrl(uid, action);
} else {
try {
- String result = api.resetStaCache();
+ api.resetStaCache();
message = getMessage("action.resetsta-confirm");
} catch (ShellyApiException e) {
message = getMessageP("action.resetsta-failed", e.toString());
actionUrl = buildActionUrl(uid, action);
} else {
try {
- String result = api.setWiFiRecovery(enable);
+ api.setWiFiRecovery(enable);
message = getMessage("action.setwifirec-confirm", enable ? "enabled" : "disabled");
} catch (ShellyApiException e) {
message = getMessage("action.setwifirec-failed", e.toString());
actionUrl = buildActionUrl(uid, action);
} else {
try {
- String result = api.setApRoaming(enable);
+ api.setApRoaming(enable);
message = getMessage("action.aproaming-confirm", enable ? "enabled" : "disabled");
} catch (ShellyApiException e) {
message = getMessage("action.aproaming-failed", e.toString());
long currentTime = new Date().getTime();
for (K key : timeMap.keySet()) {
if (currentTime > (timeMap.get(key) + expiryInMillis)) {
- V value = remove(key);
+ remove(key);
timeMap.remove(key);
}
}
BigDecimal bdTempIncoming = getTemperature(bytes, 138);
int iHumidity = getNumberBE(bytes, 148);
+ @SuppressWarnings("unused")
int iCo2 = getNumberBE(bytes, 150);
int iStateOrig = getNumberBE(bytes, 214);
@Override
public Item add(Item element) {
- Item put = items.put(element.getUID(), element);
+ items.put(element.getUID(), element);
for (RegistryChangeListener<Item> l : listeners) {
l.added(element);
}
@Override
public Metadata add(Metadata element) {
- Metadata put = items.put(element.getUID(), element);
+ items.put(element.getUID(), element);
for (RegistryChangeListener<Metadata> l : listeners) {
l.added(element);
}
@Override
public Rule add(Rule element) {
- Rule put = items.put(element.getUID(), element);
+ items.put(element.getUID(), element);
for (RegistryChangeListener<Rule> l : listeners) {
l.added(element);
}
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.thing.ThingStatusInfo;
import org.openhab.core.thing.ThingUID;
-import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.builder.BridgeBuilder;
import org.openhab.core.thing.binding.builder.ChannelBuilder;
import org.openhab.core.thing.binding.builder.ThingBuilder;
}
private Bridge createTcpMock() {
- ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502, false);
Bridge tcpBridge = ModbusPollerThingHandlerTest.createTcpThingBuilder("tcp1").build();
ModbusTcpThingHandler tcpThingHandler = Mockito.mock(ModbusTcpThingHandler.class);
tcpBridge.setStatusInfo(new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, ""));
assertThat(dataHandler.getThing().getStatus(), is(equalTo(ThingStatus.ONLINE)));
verify(comms, never()).submitOneTimePoll(eq(request), notNull(), notNull());
- ModbusPollerThingHandler handler = (ModbusPollerThingHandler) poller.getHandler();
// Wait for all channels to receive the REFRESH command (initiated by the core)
waitForAssert(
() -> verify((ModbusPollerThingHandler) poller.getHandler(), times(CHANNEL_TO_ACCEPTED_TYPE.size()))
Bridge parent;
if (pollerFunctionCode == null) {
parent = createTcpMock();
- ThingHandler foo = parent.getHandler();
addThing(parent);
} else {
ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502, false);
import static org.hamcrest.MatcherAssert.assertThat;
import org.openhab.binding.wemo.internal.WemoBindingConstants;
-import org.openhab.binding.wemo.internal.handler.AbstractWemoHandler;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
-import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.builder.BridgeBuilder;
import org.openhab.core.thing.binding.builder.ChannelBuilder;
import org.openhab.core.thing.binding.builder.ThingBuilder;
.withBridge(bridgeUID).build();
managedThingProvider.add(thing);
-
- ThingHandler handler = thing.getHandler();
- if (handler != null) {
- AbstractWemoHandler h = (AbstractWemoHandler) handler;
- }
-
return thing;
}