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