use of org.openhab.io.imperihome.internal.model.device.AbstractDevice in project openhab-addons by openhab.
the class SetModeAction method perform.
@Override
public void perform(AbstractDevice device, Item item, String value) {
String modeDeviceName = device.getLinks().get("curmode");
AbstractDevice modeDevice = deviceRegistry.getDevice(ItemProcessor.getDeviceId(modeDeviceName));
if (modeDevice == null) {
logger.error("Couldn't resolve linked CurMode device '{}', make sure the Item has iss tags", modeDeviceName);
return;
}
Item modeItem = modeDevice.getItem();
ItemCommandEvent event = ItemEventFactory.createCommandEvent(modeItem.getName(), new StringType(value), COMMAND_SOURCE);
eventPublisher.post(event);
}
use of org.openhab.io.imperihome.internal.model.device.AbstractDevice in project openhab-addons by openhab.
the class DeviceActionHandler method handle.
public void handle(HttpServletRequest req, Matcher urlMatcher) {
String deviceId, action, value;
deviceId = URLDecoder.decode(urlMatcher.group(1), StandardCharsets.UTF_8);
action = URLDecoder.decode(urlMatcher.group(2), StandardCharsets.UTF_8);
if (urlMatcher.group(3) == null) {
value = null;
} else {
value = URLDecoder.decode(urlMatcher.group(3), StandardCharsets.UTF_8);
}
logger.debug("Action request for device {}: [{}] [{}]", deviceId, action, value);
AbstractDevice device = deviceRegistry.getDevice(deviceId);
if (device == null) {
logger.warn("Received action request for unknown device: {}", urlMatcher.group(0));
} else {
device.performAction(action, value);
}
}
use of org.openhab.io.imperihome.internal.model.device.AbstractDevice in project openhab-addons by openhab.
the class DeviceHistoryHandler method handle.
public HistoryList handle(HttpServletRequest req, Matcher urlMatcher) {
String deviceId, field;
long start, end;
try {
deviceId = URLDecoder.decode(urlMatcher.group(1), StandardCharsets.UTF_8);
field = URLDecoder.decode(urlMatcher.group(2), StandardCharsets.UTF_8);
start = Long.parseLong(urlMatcher.group(3));
end = Long.parseLong(urlMatcher.group(4));
} catch (NumberFormatException e) {
throw new RuntimeException("Could not decode request params", e);
}
logger.debug("History request for device {}, field {}: {}-{}", deviceId, field, start, end);
AbstractDevice device = deviceRegistry.getDevice(deviceId);
if (device == null) {
logger.warn("Received history request for unknown device: {}", urlMatcher.group(0));
return null;
}
PersistenceService persistence = persistenceServiceRegistry.getDefault();
if (persistence == null) {
logger.warn("Could not retrieve default persistence service; can't serve history request");
return null;
}
if (!(persistence instanceof QueryablePersistenceService)) {
logger.warn("Default persistence service is not queryable; can't serve history request");
return null;
}
return serveHistory(device, (QueryablePersistenceService) persistence, start, end);
}
use of org.openhab.io.imperihome.internal.model.device.AbstractDevice in project openhab-addons by openhab.
the class DevicesListHandler method handle.
public DeviceList handle(HttpServletRequest req) {
DeviceList response = new DeviceList();
Collection<AbstractDevice> devices = deviceRegistry.getDevices().values();
for (AbstractDevice device : devices) {
device.updateParams();
}
response.setDevices(devices);
logger.debug("Device list response: {}", response);
return response;
}
use of org.openhab.io.imperihome.internal.model.device.AbstractDevice in project openhab-addons by openhab.
the class DeviceRegistry method clear.
public void clear() {
for (AbstractDevice device : devices.values()) {
device.destroy();
}
devices.clear();
if (rooms != null) {
rooms.clear();
}
logger.debug("Device registry cleared");
}
Aggregations