mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
Start building HomeAssistant interface.
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.bwssystems.HABridge</groupId>
|
||||
<artifactId>ha-bridge</artifactId>
|
||||
<version>3.5.1e</version>
|
||||
<version>3.5.1f</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HA Bridge</name>
|
||||
|
||||
@@ -783,10 +783,10 @@ public class HueMulator implements HueErrorStringSet {
|
||||
else
|
||||
setCount = 1;
|
||||
// code for backwards compatibility
|
||||
if((callItems[i].getType() == null || callItems[i].getType().trim().length() == 0) && (device.getMapType() != null && device.getMapType().trim().length() > 0)) {
|
||||
if(device.getMapType() != null || device.getMapType().length() > 0)
|
||||
if((callItems[i].getType() == null || callItems[i].getType().trim().length() == 0)) {
|
||||
if(device.getMapType() != null && device.getMapType().length() > 0)
|
||||
callItems[i].setType(device.getMapType());
|
||||
else if(device.getDeviceType() != null || device.getDeviceType().length() > 0)
|
||||
else if(device.getDeviceType() != null && device.getDeviceType().length() > 0)
|
||||
callItems[i].setType(device.getDeviceType());
|
||||
else
|
||||
callItems[i].setType(DeviceMapTypes.CUSTOM_DEVICE[DeviceMapTypes.typeIndex]);
|
||||
|
||||
303
src/main/java/com/bwssystems/hass/Attributes.java
Normal file
303
src/main/java/com/bwssystems/hass/Attributes.java
Normal file
@@ -0,0 +1,303 @@
|
||||
package com.bwssystems.hass;
|
||||
import java.util.List;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Attributes {
|
||||
|
||||
@SerializedName("Vera Device Id")
|
||||
@Expose
|
||||
private Integer veraDeviceId;
|
||||
@SerializedName("friendly_name")
|
||||
@Expose
|
||||
private String friendlyName;
|
||||
@SerializedName("supported_features")
|
||||
@Expose
|
||||
private Integer supportedFeatures;
|
||||
@SerializedName("attribution")
|
||||
@Expose
|
||||
private String attribution;
|
||||
@SerializedName("entity_picture")
|
||||
@Expose
|
||||
private String entityPicture;
|
||||
@SerializedName("azimuth")
|
||||
@Expose
|
||||
private Double azimuth;
|
||||
@SerializedName("elevation")
|
||||
@Expose
|
||||
private Double elevation;
|
||||
@SerializedName("next_rising")
|
||||
@Expose
|
||||
private String nextRising;
|
||||
@SerializedName("next_setting")
|
||||
@Expose
|
||||
private String nextSetting;
|
||||
@SerializedName("current_power_mwh")
|
||||
@Expose
|
||||
private Integer currentPowerMwh;
|
||||
@SerializedName("auto")
|
||||
@Expose
|
||||
private Boolean auto;
|
||||
@SerializedName("entity_id")
|
||||
@Expose
|
||||
private List<String> entityId = null;
|
||||
@SerializedName("hidden")
|
||||
@Expose
|
||||
private Boolean hidden;
|
||||
@SerializedName("order")
|
||||
@Expose
|
||||
private Integer order;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The veraDeviceId
|
||||
*/
|
||||
public Integer getVeraDeviceId() {
|
||||
return veraDeviceId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param veraDeviceId
|
||||
* The Vera Device Id
|
||||
*/
|
||||
public void setVeraDeviceId(Integer veraDeviceId) {
|
||||
this.veraDeviceId = veraDeviceId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The friendlyName
|
||||
*/
|
||||
public String getFriendlyName() {
|
||||
return friendlyName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param friendlyName
|
||||
* The friendly_name
|
||||
*/
|
||||
public void setFriendlyName(String friendlyName) {
|
||||
this.friendlyName = friendlyName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The supportedFeatures
|
||||
*/
|
||||
public Integer getSupportedFeatures() {
|
||||
return supportedFeatures;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param supportedFeatures
|
||||
* The supported_features
|
||||
*/
|
||||
public void setSupportedFeatures(Integer supportedFeatures) {
|
||||
this.supportedFeatures = supportedFeatures;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The attribution
|
||||
*/
|
||||
public String getAttribution() {
|
||||
return attribution;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param attribution
|
||||
* The attribution
|
||||
*/
|
||||
public void setAttribution(String attribution) {
|
||||
this.attribution = attribution;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The entityPicture
|
||||
*/
|
||||
public String getEntityPicture() {
|
||||
return entityPicture;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param entityPicture
|
||||
* The entity_picture
|
||||
*/
|
||||
public void setEntityPicture(String entityPicture) {
|
||||
this.entityPicture = entityPicture;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The azimuth
|
||||
*/
|
||||
public Double getAzimuth() {
|
||||
return azimuth;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param azimuth
|
||||
* The azimuth
|
||||
*/
|
||||
public void setAzimuth(Double azimuth) {
|
||||
this.azimuth = azimuth;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The elevation
|
||||
*/
|
||||
public Double getElevation() {
|
||||
return elevation;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param elevation
|
||||
* The elevation
|
||||
*/
|
||||
public void setElevation(Double elevation) {
|
||||
this.elevation = elevation;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The nextRising
|
||||
*/
|
||||
public String getNextRising() {
|
||||
return nextRising;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nextRising
|
||||
* The next_rising
|
||||
*/
|
||||
public void setNextRising(String nextRising) {
|
||||
this.nextRising = nextRising;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The nextSetting
|
||||
*/
|
||||
public String getNextSetting() {
|
||||
return nextSetting;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nextSetting
|
||||
* The next_setting
|
||||
*/
|
||||
public void setNextSetting(String nextSetting) {
|
||||
this.nextSetting = nextSetting;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The currentPowerMwh
|
||||
*/
|
||||
public Integer getCurrentPowerMwh() {
|
||||
return currentPowerMwh;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param currentPowerMwh
|
||||
* The current_power_mwh
|
||||
*/
|
||||
public void setCurrentPowerMwh(Integer currentPowerMwh) {
|
||||
this.currentPowerMwh = currentPowerMwh;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The auto
|
||||
*/
|
||||
public Boolean getAuto() {
|
||||
return auto;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param auto
|
||||
* The auto
|
||||
*/
|
||||
public void setAuto(Boolean auto) {
|
||||
this.auto = auto;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The entityId
|
||||
*/
|
||||
public List<String> getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param entityId
|
||||
* The entity_id
|
||||
*/
|
||||
public void setEntityId(List<String> entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The hidden
|
||||
*/
|
||||
public Boolean getHidden() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param hidden
|
||||
* The hidden
|
||||
*/
|
||||
public void setHidden(Boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The order
|
||||
*/
|
||||
public Integer getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param order
|
||||
* The order
|
||||
*/
|
||||
public void setOrder(Integer order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
}
|
||||
29
src/main/java/com/bwssystems/hass/Field.java
Normal file
29
src/main/java/com/bwssystems/hass/Field.java
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
package com.bwssystems.hass;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Field {
|
||||
|
||||
@SerializedName("fields")
|
||||
@Expose
|
||||
private Map<String, JsonElement> fields;
|
||||
|
||||
public Field(Map<String, JsonElement> fields) {
|
||||
super();
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
public Map<String, JsonElement> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public void setFields(Map<String, JsonElement> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
}
|
||||
31
src/main/java/com/bwssystems/hass/FieldDeserializer.java
Normal file
31
src/main/java/com/bwssystems/hass/FieldDeserializer.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.bwssystems.hass;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class FieldDeserializer implements JsonDeserializer<Field> {
|
||||
private Map<String, JsonElement> fields;
|
||||
@Override
|
||||
public Field deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext ctx)
|
||||
{
|
||||
JsonObject obj = json.getAsJsonObject();
|
||||
String theKey;
|
||||
|
||||
fields = new HashMap<String, JsonElement>();
|
||||
for(Entry<String, JsonElement> entry:obj.entrySet()){
|
||||
theKey = entry.getKey();
|
||||
JsonElement theRawDetail = obj.get(theKey);
|
||||
fields.put(theKey, theRawDetail);
|
||||
}
|
||||
|
||||
return new Field(fields);
|
||||
}
|
||||
|
||||
}
|
||||
52
src/main/java/com/bwssystems/hass/FieldElement.java
Normal file
52
src/main/java/com/bwssystems/hass/FieldElement.java
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
package com.bwssystems.hass;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class FieldElement {
|
||||
|
||||
@SerializedName("description")
|
||||
@Expose
|
||||
private String description;
|
||||
@SerializedName("example")
|
||||
@Expose
|
||||
private String example;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param description
|
||||
* The description
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The example
|
||||
*/
|
||||
public String getExample() {
|
||||
return example;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param example
|
||||
* The example
|
||||
*/
|
||||
public void setExample(String example) {
|
||||
this.example = example;
|
||||
}
|
||||
|
||||
}
|
||||
60
src/main/java/com/bwssystems/hass/Service.java
Normal file
60
src/main/java/com/bwssystems/hass/Service.java
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
package com.bwssystems.hass;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Service {
|
||||
|
||||
@SerializedName("domain")
|
||||
@Expose
|
||||
private String domain;
|
||||
@SerializedName("services")
|
||||
@Expose
|
||||
private Map<String, ServiceElement> services;
|
||||
|
||||
public Service(String domain, Map<String, ServiceElement> services) {
|
||||
super();
|
||||
this.domain = domain;
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The domain
|
||||
*/
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param domain
|
||||
* The domain
|
||||
*/
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The services
|
||||
*/
|
||||
public Map<String, ServiceElement> getServices() {
|
||||
return services;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param domain
|
||||
* The services
|
||||
*/
|
||||
public void setServices(Map<String, ServiceElement> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
}
|
||||
36
src/main/java/com/bwssystems/hass/ServiceDeserializer.java
Normal file
36
src/main/java/com/bwssystems/hass/ServiceDeserializer.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.bwssystems.hass;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class ServiceDeserializer implements JsonDeserializer<Service> {
|
||||
private Map<String, ServiceElement> services;
|
||||
private String domain;
|
||||
@Override
|
||||
public Service deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext ctx)
|
||||
{
|
||||
JsonObject objServices = json.getAsJsonObject();
|
||||
String theKey;
|
||||
domain = objServices.get("domain").getAsString();
|
||||
JsonObject obj = objServices.get("services").getAsJsonObject();
|
||||
services = new HashMap<String, ServiceElement>();
|
||||
for(Entry<String, JsonElement> entry:obj.entrySet()){
|
||||
ServiceElement theServiceElement = new ServiceElement();
|
||||
theKey = entry.getKey();
|
||||
JsonObject theRawDetail = obj.getAsJsonObject(theKey);
|
||||
|
||||
theServiceElement.setDescription(theRawDetail.get("description").getAsString());
|
||||
theServiceElement.setField(ctx.deserialize(theRawDetail.get("fields"), Field.class));
|
||||
services.put(theKey, theServiceElement);
|
||||
}
|
||||
return new Service(domain, services);
|
||||
}
|
||||
|
||||
}
|
||||
52
src/main/java/com/bwssystems/hass/ServiceElement.java
Normal file
52
src/main/java/com/bwssystems/hass/ServiceElement.java
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
package com.bwssystems.hass;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class ServiceElement {
|
||||
|
||||
@SerializedName("description")
|
||||
@Expose
|
||||
private String description;
|
||||
@SerializedName("fields")
|
||||
@Expose
|
||||
private Field fields;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param description
|
||||
* The description
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The fields
|
||||
*/
|
||||
public Field getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fields
|
||||
* The fields
|
||||
*/
|
||||
public void setField(Field fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
}
|
||||
114
src/main/java/com/bwssystems/hass/State.java
Normal file
114
src/main/java/com/bwssystems/hass/State.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package com.bwssystems.hass;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class State {
|
||||
|
||||
@SerializedName("attributes")
|
||||
@Expose
|
||||
private Attributes attributes;
|
||||
@SerializedName("entity_id")
|
||||
@Expose
|
||||
private String entityId;
|
||||
@SerializedName("last_changed")
|
||||
@Expose
|
||||
private String lastChanged;
|
||||
@SerializedName("last_updated")
|
||||
@Expose
|
||||
private String lastUpdated;
|
||||
@SerializedName("state")
|
||||
@Expose
|
||||
private String state;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The attributes
|
||||
*/
|
||||
public Attributes getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param attributes
|
||||
* The attributes
|
||||
*/
|
||||
public void setAttributes(Attributes attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The entityId
|
||||
*/
|
||||
public String getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param entityId
|
||||
* The entity_id
|
||||
*/
|
||||
public void setEntityId(String entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The lastChanged
|
||||
*/
|
||||
public String getLastChanged() {
|
||||
return lastChanged;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param lastChanged
|
||||
* The last_changed
|
||||
*/
|
||||
public void setLastChanged(String lastChanged) {
|
||||
this.lastChanged = lastChanged;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The lastUpdated
|
||||
*/
|
||||
public String getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param lastUpdated
|
||||
* The last_updated
|
||||
*/
|
||||
public void setLastUpdated(String lastUpdated) {
|
||||
this.lastUpdated = lastUpdated;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* The state
|
||||
*/
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param state
|
||||
* The state
|
||||
*/
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
}
|
||||
32
src/main/java/com/bwssystems/hass/TestService.java
Normal file
32
src/main/java/com/bwssystems/hass/TestService.java
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user