MQTT publish implementation, still without password.

This commit is contained in:
Admin
2016-11-16 16:58:11 -06:00
parent 90f2bce282
commit 68f38e1d95
23 changed files with 282 additions and 19 deletions

View File

@@ -26,6 +26,7 @@ import com.bwssystems.harmony.HarmonyHome;
import com.bwssystems.hue.HueHome;
import com.bwssystems.luupRequests.Device;
import com.bwssystems.luupRequests.Scene;
import com.bwssystems.mqtt.MQTTHome;
import com.bwssystems.util.JsonTransformer;
import com.bwssystems.vera.VeraHome;
import com.google.gson.Gson;
@@ -42,9 +43,10 @@ public class DeviceResource {
private NestHome nestHome;
private HueHome hueHome;
private HalHome halHome;
private MQTTHome mqttHome;
private static final Set<String> supportedVerbs = new HashSet<>(Arrays.asList("get", "put", "post"));
public DeviceResource(BridgeSettingsDescriptor theSettings, HarmonyHome theHarmonyHome, NestHome aNestHome, HueHome aHueHome, HalHome aHalHome) {
public DeviceResource(BridgeSettingsDescriptor theSettings, HarmonyHome theHarmonyHome, NestHome aNestHome, HueHome aHueHome, HalHome aHalHome, MQTTHome aMqttHome) {
this.deviceRepository = new DeviceRepository(theSettings.getUpnpDeviceDb());
if(theSettings.isValidVera())
@@ -72,6 +74,11 @@ public class DeviceResource {
else
this.halHome = null;
if(theSettings.isValidMQTT())
this.mqttHome = aMqttHome;
else
this.mqttHome = null;
setupEndpoints();
}
@@ -280,6 +287,16 @@ public class DeviceResource {
return halHome.getDevices();
}, new JsonTransformer());
get (API_CONTEXT + "/mqtt/devices", "application/json", (request, response) -> {
log.debug("Get MQTT brokers");
if(mqttHome == null) {
response.status(HttpStatus.SC_NOT_FOUND);
return new ErrorMessage("A MQTT config is not available.");
}
response.status(HttpStatus.SC_OK);
return mqttHome.getBrokers();
}, new JsonTransformer());
// http://ip_address:port/api/devices/exec/renumber CORS request
options(API_CONTEXT + "/exec/renumber", "application/json", (request, response) -> {
response.status(HttpStatus.SC_OK);