mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-21 17:18:49 +00:00
Adding new classes to handle vera and updated distribution to include js
and css files in the jar.
This commit is contained in:
42
src/main/java/com/bwssystems/HABridge/BridgeSettings.java
Normal file
42
src/main/java/com/bwssystems/HABridge/BridgeSettings.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.bwssystems.HABridge;
|
||||
|
||||
public class BridgeSettings {
|
||||
private String upnpconfigaddress;
|
||||
private String serverport;
|
||||
private String upnpresponseport;
|
||||
private String upnpdevicedb;
|
||||
private String veraaddress;
|
||||
|
||||
public String getUpnpConfigAddress() {
|
||||
return upnpconfigaddress;
|
||||
}
|
||||
public void setUpnpConfigAddress(String upnpConfigAddress) {
|
||||
this.upnpconfigaddress = upnpConfigAddress;
|
||||
}
|
||||
public String getServerPort() {
|
||||
return serverport;
|
||||
}
|
||||
public void setServerPort(String serverPort) {
|
||||
this.serverport = serverPort;
|
||||
}
|
||||
public String getUpnpResponsePort() {
|
||||
return upnpresponseport;
|
||||
}
|
||||
public void setUpnpResponsePort(String upnpResponsePort) {
|
||||
this.upnpresponseport = upnpResponsePort;
|
||||
}
|
||||
public String getUpnpDeviceDb() {
|
||||
return upnpdevicedb;
|
||||
}
|
||||
public void setUpnpDeviceDb(String upnpDeviceDb) {
|
||||
this.upnpdevicedb = upnpDeviceDb;
|
||||
}
|
||||
public String getVeraAddress() {
|
||||
return veraaddress;
|
||||
}
|
||||
public void setVeraAddress(String veraAddress) {
|
||||
this.veraaddress = veraAddress;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
19
src/main/java/com/bwssystems/luupRequests/Categorie.java
Normal file
19
src/main/java/com/bwssystems/luupRequests/Categorie.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.bwssystems.luupRequests;
|
||||
|
||||
public class Categorie {
|
||||
private String name;
|
||||
private String id;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
83
src/main/java/com/bwssystems/luupRequests/Device.java
Normal file
83
src/main/java/com/bwssystems/luupRequests/Device.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package com.bwssystems.luupRequests;
|
||||
|
||||
public class Device {
|
||||
|
||||
private String name;
|
||||
private String altid;
|
||||
private String id;
|
||||
private String category;
|
||||
private String subcategory;
|
||||
private String room;
|
||||
private String parent;
|
||||
private String status;
|
||||
private String level;
|
||||
private String state;
|
||||
private String comment;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getAltid() {
|
||||
return altid;
|
||||
}
|
||||
public void setAltid(String altid) {
|
||||
this.altid = altid;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
public String getSubcategory() {
|
||||
return subcategory;
|
||||
}
|
||||
public void setSubcategory(String subcategory) {
|
||||
this.subcategory = subcategory;
|
||||
}
|
||||
public String getRoom() {
|
||||
return room;
|
||||
}
|
||||
public void setRoom(String room) {
|
||||
this.room = room;
|
||||
}
|
||||
public String getParent() {
|
||||
return parent;
|
||||
}
|
||||
public void setParent(String parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
}
|
||||
26
src/main/java/com/bwssystems/luupRequests/Room.java
Normal file
26
src/main/java/com/bwssystems/luupRequests/Room.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.bwssystems.luupRequests;
|
||||
|
||||
public class Room {
|
||||
private String name;
|
||||
private String id;
|
||||
private String section;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getSection() {
|
||||
return section;
|
||||
}
|
||||
public void setSection(String section) {
|
||||
this.section = section;
|
||||
}
|
||||
}
|
||||
33
src/main/java/com/bwssystems/luupRequests/Scene.java
Normal file
33
src/main/java/com/bwssystems/luupRequests/Scene.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.bwssystems.luupRequests;
|
||||
|
||||
public class Scene {
|
||||
private String active;
|
||||
private String name;
|
||||
private String id;
|
||||
private String room;
|
||||
public String getActive() {
|
||||
return active;
|
||||
}
|
||||
public void setActive(String active) {
|
||||
this.active = active;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getRoom() {
|
||||
return room;
|
||||
}
|
||||
public void setRoom(String room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
}
|
||||
140
src/main/java/com/bwssystems/luupRequests/Sdata.java
Normal file
140
src/main/java/com/bwssystems/luupRequests/Sdata.java
Normal file
@@ -0,0 +1,140 @@
|
||||
package com.bwssystems.luupRequests;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Sdata {
|
||||
private String full;
|
||||
private String version;
|
||||
private String model;
|
||||
private String zwave_heal;
|
||||
private String temperature;
|
||||
private String serial_number;
|
||||
private String fwd1;
|
||||
private String fwd2;
|
||||
private String ir;
|
||||
private String irtx;
|
||||
private String loadtime;
|
||||
private String dataversion;
|
||||
private String state;
|
||||
private String comment;
|
||||
private List<Section> sections;
|
||||
private List<Room> rooms;
|
||||
private List<Scene> scenes;
|
||||
private List<Device> devices;
|
||||
private List<Categorie> categories;
|
||||
|
||||
public String getFull() {
|
||||
return full;
|
||||
}
|
||||
public void setFull(String full) {
|
||||
this.full = full;
|
||||
}
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
public String getZwave_heal() {
|
||||
return zwave_heal;
|
||||
}
|
||||
public void setZwave_heal(String zwave_heal) {
|
||||
this.zwave_heal = zwave_heal;
|
||||
}
|
||||
public String getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
public void setTemperature(String temperature) {
|
||||
this.temperature = temperature;
|
||||
}
|
||||
public String getSerial_number() {
|
||||
return serial_number;
|
||||
}
|
||||
public void setSerial_number(String serial_number) {
|
||||
this.serial_number = serial_number;
|
||||
}
|
||||
public String getFwd1() {
|
||||
return fwd1;
|
||||
}
|
||||
public void setFwd1(String fwd1) {
|
||||
this.fwd1 = fwd1;
|
||||
}
|
||||
public String getFwd2() {
|
||||
return fwd2;
|
||||
}
|
||||
public void setFwd2(String fwd2) {
|
||||
this.fwd2 = fwd2;
|
||||
}
|
||||
public String getIr() {
|
||||
return ir;
|
||||
}
|
||||
public void setIr(String ir) {
|
||||
this.ir = ir;
|
||||
}
|
||||
public String getIrtx() {
|
||||
return irtx;
|
||||
}
|
||||
public void setIrtx(String irtx) {
|
||||
this.irtx = irtx;
|
||||
}
|
||||
public String getLoadtime() {
|
||||
return loadtime;
|
||||
}
|
||||
public void setLoadtime(String loadtime) {
|
||||
this.loadtime = loadtime;
|
||||
}
|
||||
public String getDataversion() {
|
||||
return dataversion;
|
||||
}
|
||||
public void setDataversion(String dataversion) {
|
||||
this.dataversion = dataversion;
|
||||
}
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
public List<Section> getSections() {
|
||||
return sections;
|
||||
}
|
||||
public void setSections(List<Section> sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
public List<Room> getRooms() {
|
||||
return rooms;
|
||||
}
|
||||
public void setRooms(List<Room> rooms) {
|
||||
this.rooms = rooms;
|
||||
}
|
||||
public List<Scene> getScenes() {
|
||||
return scenes;
|
||||
}
|
||||
public void setScenes(List<Scene> scenes) {
|
||||
this.scenes = scenes;
|
||||
}
|
||||
public List<Device> getDevices() {
|
||||
return devices;
|
||||
}
|
||||
public void setDevices(List<Device> devices) {
|
||||
this.devices = devices;
|
||||
}
|
||||
public List<Categorie> getCategoriess() {
|
||||
return categories;
|
||||
}
|
||||
public void setCategoriess(List<Categorie> categories) {
|
||||
this.categories = categories;
|
||||
}
|
||||
}
|
||||
19
src/main/java/com/bwssystems/luupRequests/Section.java
Normal file
19
src/main/java/com/bwssystems/luupRequests/Section.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.bwssystems.luupRequests;
|
||||
|
||||
public class Section {
|
||||
private String name;
|
||||
private String id;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
56
src/main/java/com/bwssystems/vera/VeraInfo.java
Normal file
56
src/main/java/com/bwssystems/vera/VeraInfo.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.bwssystems.vera;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.bwssystems.luupRequests.Sdata;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
|
||||
public class VeraInfo {
|
||||
private static final Logger log = LoggerFactory.getLogger(VeraInfo.class);
|
||||
private HttpClient httpClient;
|
||||
private static final String SDATA_REQUEST = ":3480/data_request?id=sdata&output_format=json";
|
||||
private String veraAddressString;
|
||||
|
||||
public VeraInfo(String addressString) {
|
||||
super();
|
||||
httpClient = HttpClients.createMinimal();
|
||||
veraAddressString = addressString;
|
||||
}
|
||||
|
||||
public Sdata getSdata() {
|
||||
String theUrl = "http://" + veraAddressString + SDATA_REQUEST;
|
||||
String theData;
|
||||
|
||||
theData = doHttpGETRequest(theUrl);
|
||||
Sdata theSdata = new Gson().fromJson(theData, Sdata.class);
|
||||
log.debug("GET sdata - full: " + theSdata.getFull() + ", version: " + theSdata.getVersion());
|
||||
return theSdata;
|
||||
}
|
||||
|
||||
// This function executes the url against the vera
|
||||
protected String doHttpGETRequest(String url) {
|
||||
log.info("calling GET on URL: " + url);
|
||||
HttpGet httpGet = new HttpGet(url);
|
||||
try {
|
||||
HttpResponse response = httpClient.execute(httpGet);
|
||||
String theContent = EntityUtils.toString(response.getEntity()); //read content for data
|
||||
EntityUtils.consume(response.getEntity()); //close out inputstream ignore content
|
||||
log.info("GET on URL responded: " + response.getStatusLine().getStatusCode());
|
||||
if(response.getStatusLine().getStatusCode() == 200){
|
||||
return theContent;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Error calling out to HA gateway", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user