mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
commit for any latent changes.
This commit is contained in:
@@ -76,6 +76,7 @@ public class DeviceRepository {
|
||||
JsonTransformer aRenderer = new JsonTransformer();
|
||||
String jsonValue = aRenderer.render(findAll());
|
||||
repositoryWriter(jsonValue, repositoryPath);
|
||||
log.debug("Save device: " + aDescriptor.getName());
|
||||
}
|
||||
|
||||
public String delete(DeviceDescriptor aDescriptor) {
|
||||
|
||||
@@ -56,22 +56,24 @@ public class DeviceResource {
|
||||
log.debug("Create a Device - device json off URL:" + deviceEntry.getOffUrl());
|
||||
|
||||
deviceRepository.save(deviceEntry);
|
||||
log.debug("Created a Device");
|
||||
log.debug("Created a Device: " + request.body());
|
||||
|
||||
response.status(201);
|
||||
return deviceEntry;
|
||||
}, new JsonTransformer());
|
||||
|
||||
put (API_CONTEXT + "/:id", "application/json", (request, response) -> {
|
||||
log.debug("Saved a Device");
|
||||
DeviceDescriptor device = new Gson().fromJson(request.body(), DeviceDescriptor.class);
|
||||
DeviceDescriptor deviceEntry = deviceRepository.findOne(request.params(":id"));
|
||||
if(deviceEntry == null){
|
||||
log.debug("Could not save an edited Device Id: " + request.params(":id"));
|
||||
return null;
|
||||
}
|
||||
log.debug("Saving an edited Device: " + deviceEntry.getName());
|
||||
|
||||
deviceEntry.setName(device.getName());
|
||||
deviceEntry.setDeviceType(device.getDeviceType());
|
||||
if(device.getDeviceType() != null)
|
||||
deviceEntry.setDeviceType(device.getDeviceType());
|
||||
deviceEntry.setOnUrl(device.getOnUrl());
|
||||
deviceEntry.setOffUrl(device.getOffUrl());
|
||||
|
||||
|
||||
@@ -129,14 +129,13 @@ public class HueMulator {
|
||||
*/
|
||||
String userId = request.params(":userid");
|
||||
String lightId = request.params(":id");
|
||||
log.info("hue state change requested: " + userId + " from " + request.ip());
|
||||
log.info("hue stage change body: " + request.body() );
|
||||
log.info("hue state change requested: " + userId + " from " + request.ip() + " body: " + request.body());
|
||||
|
||||
DeviceState state = null;
|
||||
try {
|
||||
state = mapper.readValue(request.body(), DeviceState.class);
|
||||
} catch (IOException e) {
|
||||
log.info("object mapper barfed on input", e);
|
||||
log.error("Object mapper barfed on input of body.", e);
|
||||
response.status(400);
|
||||
return null;
|
||||
}
|
||||
@@ -144,6 +143,7 @@ public class HueMulator {
|
||||
DeviceDescriptor device = repository.findOne(lightId);
|
||||
if (device == null) {
|
||||
response.status(404);
|
||||
log.error("Could not find devcie: " + lightId);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -178,6 +178,7 @@ public class HueMulator {
|
||||
//make call
|
||||
if(!doHttpGETRequest(url)){
|
||||
response.status(503);
|
||||
log.error("Error on calling url to change device state: " + url);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
|
||||
<li><a href="http://www.bwssystems.com" target="_blank">Developed by BWS Systems</a></li>
|
||||
<li><a href="http://www.amazon.com/echo" target="_blank">Amazon Echo</a></li>
|
||||
<li><a href="#">HA Bridge Version 0.3.0</a></li>
|
||||
<li><a href="#">HA Bridge Version 0.3.1</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user