mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
fix autorization in requests and many changes. All working, except device statuses. Dont know how to do that.
This commit is contained in:
@@ -2,8 +2,8 @@ package com.bwssystems.HABridge;
|
||||
|
||||
public class NamedIP {
|
||||
private String name;
|
||||
private String ip;
|
||||
private String webhook;
|
||||
private String ip;
|
||||
private String webhook;
|
||||
private String port;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.bwssystems.HABridge.plugins.fibaro;
|
||||
|
||||
public class Device
|
||||
{
|
||||
public int id;
|
||||
public String name;
|
||||
public int roomID;
|
||||
public String type;
|
||||
public String baseType;
|
||||
public boolean enabled;
|
||||
public boolean visible;
|
||||
public boolean isPlugin;
|
||||
public int parentId;
|
||||
public int remoteGatewayId;
|
||||
public boolean viewXml;
|
||||
public boolean configXml;
|
||||
public Object interfaces;
|
||||
public Properties properties;
|
||||
public Object actions;
|
||||
public int created;
|
||||
public int modified;
|
||||
public int sortOrder;
|
||||
|
||||
public class Properties {
|
||||
public String UIMessageSendTime;
|
||||
public String autoConfig;
|
||||
public String date;
|
||||
public String dead;
|
||||
public String deviceControlType;
|
||||
public String deviceIcon;
|
||||
public String disabled;
|
||||
public String emailNotificationID;
|
||||
public String emailNotificationType;
|
||||
public String endPoint;
|
||||
public String liliOffCommand;
|
||||
public String liliOnCommand;
|
||||
public String log;
|
||||
public String logTemp;
|
||||
public String manufacturer;
|
||||
public String markAsDead;
|
||||
public String model;
|
||||
public String nodeID;
|
||||
public String pollingDeadDevice;
|
||||
public String pollingTime;
|
||||
public String pollingTimeNext;
|
||||
public int pollingTimeSec;
|
||||
public String productInfo;
|
||||
public String pushNotificationID;
|
||||
public String pushNotificationType;
|
||||
public String remoteGatewayId;
|
||||
public String requestNodeNeighborStat;
|
||||
public String requestNodeNeighborStatTimeStemp;
|
||||
public String requestNodeNeighborState;
|
||||
public String requestNodeNeighborStateTimeStemp;
|
||||
public String saveLogs;
|
||||
public String showChildren;
|
||||
public String smsNotificationID;
|
||||
public String smsNotificationType;
|
||||
public String status;
|
||||
public String sunriseHour;
|
||||
public String sunsetHour;
|
||||
public String userDescription;
|
||||
public String value;
|
||||
public String zwaveBuildVersion;
|
||||
public String zwaveCompany;
|
||||
public String zwaveInfo;
|
||||
public String zwaveRegion;
|
||||
public double zwaveVersion;
|
||||
}
|
||||
|
||||
public String room;
|
||||
public String category;
|
||||
public String fibaroaddress;
|
||||
public String fibaroname;
|
||||
}
|
||||
@@ -16,6 +16,8 @@ import com.bwssystems.HABridge.NamedIP;
|
||||
import com.bwssystems.HABridge.api.CallItem;
|
||||
import com.bwssystems.HABridge.dao.DeviceDescriptor;
|
||||
import com.bwssystems.HABridge.hue.MultiCommandUtil;
|
||||
import com.bwssystems.HABridge.plugins.fibaro.json.Device;
|
||||
import com.bwssystems.HABridge.plugins.fibaro.json.Scene;
|
||||
|
||||
public class FibaroHome implements Home
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.bwssystems.HABridge.plugins.fibaro;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
@@ -10,60 +11,133 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.bwssystems.HABridge.NamedIP;
|
||||
import com.bwssystems.HABridge.plugins.fibaro.json.Device;
|
||||
import com.bwssystems.HABridge.plugins.fibaro.json.Room;
|
||||
import com.bwssystems.HABridge.plugins.fibaro.json.Scene;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class FibaroInfo
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(FibaroInfo.class);
|
||||
private NamedIP fibaroAddress;
|
||||
|
||||
// You can disable it if you want
|
||||
private final NamedIP fibaroAddress;
|
||||
private final String fibaroAuth;
|
||||
private final Gson gson;
|
||||
|
||||
// You can disable it if you want TODO config
|
||||
boolean useSaveLogs = true; // This can be used to exclude some devices from list
|
||||
boolean useUserDescription = true;
|
||||
boolean removeDigits = true;
|
||||
boolean replaceTrash = true;
|
||||
boolean scenesWithLiliCommandOnly = true;
|
||||
|
||||
public FibaroInfo(NamedIP addressName)
|
||||
{
|
||||
super();
|
||||
fibaroAddress = addressName;
|
||||
fibaroAuth = "Basic " + new String(Base64.encodeBase64((addressName.getUsername() + ":" + addressName.getPassword()).getBytes()));
|
||||
gson = new Gson();
|
||||
}
|
||||
|
||||
private String request(String request)
|
||||
{
|
||||
String result = null;
|
||||
try
|
||||
{
|
||||
URL url = new URL("http://" + fibaroAddress.getIp() + ":" + fibaroAddress.getPort() + request);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setRequestProperty("Authorization", fibaroAuth);
|
||||
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8");
|
||||
connection.connect();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
String line;
|
||||
while((line = br.readLine()) != null)
|
||||
{
|
||||
buffer.append(line).append("\n");
|
||||
}
|
||||
br.close();
|
||||
result = buffer.toString();
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
log.warn("Error while get getJson: {} ", request, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean sendCommand(String request)
|
||||
{
|
||||
try
|
||||
{
|
||||
URL url = new URL("http://" + fibaroAddress.getIp() + ":" + fibaroAddress.getPort() + request);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setRequestProperty("Authorization", fibaroAuth);
|
||||
connection.getResponseMessage();
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
log.warn("Error while get getJson: {} ", request, e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String replaceTrash(String name)
|
||||
{
|
||||
String sanitizedName = name.replaceAll("[0-9:/-]", "");
|
||||
sanitizedName = name.replaceAll("\\s+", " ");
|
||||
return sanitizedName.trim();
|
||||
}
|
||||
|
||||
private Room[] getRooms()
|
||||
{
|
||||
String result = request("/api/rooms");
|
||||
Room[] rooms = result == null ? new Room[0] : gson.fromJson(result, Room[].class);
|
||||
if(replaceTrash)
|
||||
for(Room r : rooms)
|
||||
r.setName(replaceTrash(r.getName()));
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public Device[] getDevices()
|
||||
{
|
||||
Room[] rooms = getRooms();
|
||||
|
||||
log.debug("Founded: " + rooms.length + ", rooms");
|
||||
log.info("Found: " + rooms.length + " rooms");
|
||||
|
||||
String result = request("/api/devices?enabled=true&visible=true");
|
||||
Device[] all_devices = result == null ? new Device[0] : gson.fromJson(result, Device[].class);
|
||||
|
||||
Device[] all_devices = getAllDevices();
|
||||
int count = 0;
|
||||
for(Device d : all_devices)
|
||||
if(d.roomID > 0 && useSaveLogs ? "true".equals(d.properties.saveLogs) : true)
|
||||
if(d.getRoomID() > 0 && (useSaveLogs ? "true".equals(d.getProperties().getSaveLogs()) : true))
|
||||
count++;
|
||||
|
||||
Device[] devices = new Device[count];
|
||||
int i = 0;
|
||||
for(Device d : all_devices)
|
||||
if(d.roomID > 0 && useSaveLogs ? "true".equals(d.properties.saveLogs) : true)
|
||||
if(d.getRoomID() > 0 && (useSaveLogs ? "true".equals(d.getProperties().getSaveLogs()) : true))
|
||||
{
|
||||
if(useUserDescription && d.properties.userDescription != null && !d.properties.userDescription.isEmpty())
|
||||
d.name = d.properties.userDescription;
|
||||
if(removeDigits)
|
||||
d.name = replaceDigits(d.name);
|
||||
if(useUserDescription && d.getProperties().getUserDescription() != null && !d.getProperties().getUserDescription().isEmpty())
|
||||
d.setName(d.getProperties().getUserDescription());
|
||||
if(replaceTrash)
|
||||
d.setName(replaceTrash(d.getName()));
|
||||
|
||||
devices[i++] = d;
|
||||
|
||||
for(Room room : rooms)
|
||||
if(d.roomID == room.id)
|
||||
{
|
||||
d.room = room.name.trim();
|
||||
d.category = String.valueOf(room.sectionID); // TODO load name of section
|
||||
}
|
||||
if(d.getRoomID() == room.getId())
|
||||
d.setRoomName(room.getName());
|
||||
|
||||
d.fibaroaddress = fibaroAddress.getIp();
|
||||
d.fibaroport = fibaroAddress.getPort();
|
||||
d.fibaroAuth = fibaroAuth;
|
||||
d.fibaroname = fibaroAddress.getName();
|
||||
}
|
||||
|
||||
log.info("Founded: " + devices.length + " devices");
|
||||
log.info("Found: " + devices.length + " devices");
|
||||
|
||||
return devices;
|
||||
}
|
||||
@@ -71,105 +145,34 @@ public class FibaroInfo
|
||||
public Scene[] getScenes()
|
||||
{
|
||||
Room[] rooms = getRooms();
|
||||
|
||||
String result = request("/api/scenes?enabled=true&visible=true");
|
||||
Scene[] all_scenes = result == null ? new Scene[0] : gson.fromJson(result, Scene[].class);
|
||||
|
||||
int count = 0;
|
||||
Scene[] scenes = getAllScenes();
|
||||
for(Scene s : scenes)
|
||||
if(!scenesWithLiliCommandOnly || s.liliStartCommand != null && !s.liliStartCommand.isEmpty())
|
||||
for(Scene s : all_scenes)
|
||||
if(!scenesWithLiliCommandOnly || s.getLiliStartCommand() != null && !s.getLiliStartCommand().isEmpty())
|
||||
count++;
|
||||
Scene[] result = new Scene[count];
|
||||
Scene[] scenes = new Scene[count];
|
||||
int i = 0;
|
||||
for(Scene s : scenes)
|
||||
if(!scenesWithLiliCommandOnly || s.liliStartCommand != null && !s.liliStartCommand.isEmpty())
|
||||
for(Scene s : all_scenes)
|
||||
if(!scenesWithLiliCommandOnly || s.getLiliStartCommand() != null && !s.getLiliStartCommand().isEmpty())
|
||||
{
|
||||
result[i++] = s;
|
||||
if(replaceTrash)
|
||||
s.setName(replaceTrash(s.getName()));
|
||||
|
||||
scenes[i++] = s;
|
||||
|
||||
for(Room room : rooms)
|
||||
if(s.roomID == room.id)
|
||||
{
|
||||
s.room = room.name.trim();
|
||||
s.category = String.valueOf(room.sectionID); // TODO load name of section
|
||||
}
|
||||
if(s.getRoomID() == room.getId())
|
||||
s.setRoomName(room.getName());
|
||||
|
||||
s.fibaroaddress = fibaroAddress.getIp();
|
||||
s.fibaroport = fibaroAddress.getPort();
|
||||
s.fibaroAuth = fibaroAuth;
|
||||
s.fibaroname = fibaroAddress.getName();
|
||||
}
|
||||
log.info("Founded: " + count + " scenes");
|
||||
return result;
|
||||
}
|
||||
|
||||
private Device[] getAllDevices()
|
||||
{
|
||||
String result = request("devices?enabled=true&visible=true");
|
||||
if(result == null)
|
||||
return new Device[0];
|
||||
Device[] devices = new Gson().fromJson(result, Device[].class);
|
||||
return devices;
|
||||
}
|
||||
|
||||
private Scene[] getAllScenes()
|
||||
{
|
||||
String result = request("scenes?enabled=true&visible=true");
|
||||
if(result == null)
|
||||
return new Scene[0];
|
||||
Scene[] scenes = new Gson().fromJson(result, Scene[].class);
|
||||
log.info("Found: " + count + " scenes");
|
||||
return scenes;
|
||||
}
|
||||
|
||||
private Room[] getRooms()
|
||||
{
|
||||
String result = request("rooms");
|
||||
if(result == null)
|
||||
return new Room[0];
|
||||
return new Gson().fromJson(result, Room[].class);
|
||||
}
|
||||
|
||||
private String request(String theUrl)
|
||||
{
|
||||
theUrl = "http://" + fibaroAddress.getIp() + "/api/" + theUrl;
|
||||
String auth = new String(Base64.encodeBase64((fibaroAddress.getUsername() + ":" + fibaroAddress.getPassword()).getBytes()));
|
||||
java.net.URL url;
|
||||
java.net.HttpURLConnection connection;
|
||||
String result = null;
|
||||
try
|
||||
{
|
||||
url = new URL(theUrl);
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setRequestProperty("Authorization", "Basic " + auth);
|
||||
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8");
|
||||
connection.setRequestProperty("X-Requested-With", "XMLHttpRequest");
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36");
|
||||
connection.connect();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
String line;
|
||||
while((line = br.readLine()) != null)
|
||||
buffer.append(line).append("\n");
|
||||
br.close();
|
||||
result = buffer.toString();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.info("Error while get getJson: " + theUrl);
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String replaceDigits(String name)
|
||||
{
|
||||
name = name.replaceAll("1", "");
|
||||
name = name.replaceAll("2", "");
|
||||
name = name.replaceAll("3", "");
|
||||
name = name.replaceAll("4", "");
|
||||
name = name.replaceAll("5", "");
|
||||
name = name.replaceAll("6", "");
|
||||
name = name.replaceAll("7", "");
|
||||
name = name.replaceAll("8", "");
|
||||
name = name.replaceAll("9", "");
|
||||
name = name.replaceAll("0", "");
|
||||
name = name.trim();
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.bwssystems.HABridge.plugins.fibaro;
|
||||
|
||||
public enum ModeType {
|
||||
OFF(0, "Off"),
|
||||
HEAT(1, "Heat"),
|
||||
COOL(2, "Cool"),
|
||||
AUTO(3, "Auto"),
|
||||
AUX_HEAT(4, "Aux Heat"),
|
||||
RESUME(5, "Resume"),
|
||||
FAN_ONLY(6, "Fan Only"),
|
||||
FURNANCE(7, "Furnace"),
|
||||
DRY_AIR(8, "Dry Air"),
|
||||
MOIST_AIR(9, "Moist Air"),
|
||||
AUTO_CHANGEOVER(10, "Auto Changeover"),
|
||||
HEAT_ECON(11, "Heat Econ"),
|
||||
COOL_ECON(12, "Cool Econ"),
|
||||
AWAY(13, "Away"),
|
||||
MANUAL(31, "Manual");
|
||||
|
||||
private int key;
|
||||
private String label;
|
||||
|
||||
private ModeType(int key, String label) {
|
||||
this.key = key;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public int getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.bwssystems.HABridge.plugins.fibaro;
|
||||
|
||||
public class Room
|
||||
{
|
||||
public int id;
|
||||
public String name;
|
||||
public int sectionID;
|
||||
public String icon;
|
||||
public Sensor defaultSensors;
|
||||
public int defaultThermostat;
|
||||
public int sortOrder;
|
||||
|
||||
public class Sensor
|
||||
{
|
||||
public int temperature;
|
||||
public int humidity;
|
||||
public int light;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.bwssystems.HABridge.plugins.fibaro;
|
||||
|
||||
public class Scene
|
||||
{
|
||||
public int id;
|
||||
public String name;
|
||||
public String type;
|
||||
public String properties;
|
||||
public int roomID;
|
||||
public int iconID;
|
||||
public String runConfig;
|
||||
public boolean autostart;
|
||||
public boolean protectedByPIN;
|
||||
public boolean killable;
|
||||
public int maxRunningInstances;
|
||||
public int runningInstances;
|
||||
public boolean visible;
|
||||
public boolean isLua;
|
||||
public Triggers triggers;
|
||||
public String liliStartCommand;
|
||||
public String liliStopCommand;
|
||||
public int sortOrder;
|
||||
|
||||
public class Triggers {
|
||||
public Properties[] properties;
|
||||
public String[] globals;
|
||||
public String[] events;
|
||||
}
|
||||
|
||||
public class Properties {
|
||||
public String id;
|
||||
public String name;
|
||||
}
|
||||
|
||||
public String room;
|
||||
public String category;
|
||||
public String fibaroaddress;
|
||||
public String fibaroname;
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.bwssystems.HABridge.plugins.fibaro.json;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Device {
|
||||
private String roomName;
|
||||
|
||||
@SerializedName("id")
|
||||
private String id;
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("roomID")
|
||||
private int roomID;
|
||||
|
||||
@SerializedName("type")
|
||||
private String type;
|
||||
|
||||
@SerializedName("baseType")
|
||||
private String baseType;
|
||||
|
||||
@SerializedName("enabled")
|
||||
private boolean enabled;
|
||||
|
||||
@SerializedName("visible")
|
||||
private boolean visible;
|
||||
|
||||
@SerializedName("isPlugin")
|
||||
private boolean isPlugin;
|
||||
|
||||
@SerializedName("parentId")
|
||||
private int parentId;
|
||||
|
||||
@SerializedName("remoteGatewayId")
|
||||
private int remoteGatewayId;
|
||||
|
||||
@SerializedName("viewXml")
|
||||
private boolean viewXml;
|
||||
|
||||
@SerializedName("configXml")
|
||||
private boolean configXml;
|
||||
|
||||
@SerializedName("interfaces")
|
||||
private Object interfaces;
|
||||
|
||||
@SerializedName("properties")
|
||||
private DeviceProperties properties;
|
||||
|
||||
@SerializedName("actions")
|
||||
private Object actions;
|
||||
|
||||
@SerializedName("created")
|
||||
private int created;
|
||||
|
||||
@SerializedName("modified")
|
||||
private int modified;
|
||||
|
||||
@SerializedName("sortOrder")
|
||||
private int sortOrder;
|
||||
|
||||
public String getRoomName() {
|
||||
return roomName;
|
||||
}
|
||||
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getRoomID() {
|
||||
return roomID;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public DeviceProperties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public boolean isThermostat() {
|
||||
return type.equals("com.fibaro.setPoint") || type.equals("com.fibaro.thermostatDanfoss")
|
||||
|| type.equals("com.fibaro.thermostatHorstmann");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" + id + ", " + name + "}";
|
||||
}
|
||||
|
||||
public String fibaroaddress;
|
||||
public String fibaroport;
|
||||
public String fibaroAuth;
|
||||
public String fibaroname;
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
package com.bwssystems.HABridge.plugins.fibaro.json;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class DeviceProperties {
|
||||
@SerializedName("batteryLevel")
|
||||
private String batteryLevel;
|
||||
|
||||
@SerializedName("UIMessageSendTime")
|
||||
private String UIMessageSendTime;
|
||||
|
||||
@SerializedName("autoConfig")
|
||||
private String autoConfig;
|
||||
|
||||
@SerializedName("color")
|
||||
private String color;
|
||||
|
||||
@SerializedName("date")
|
||||
private String date;
|
||||
|
||||
@SerializedName("dead")
|
||||
private String dead;
|
||||
|
||||
@SerializedName("deviceControlType")
|
||||
private String deviceControlType;
|
||||
|
||||
@SerializedName("deviceIcon")
|
||||
private String deviceIcon;
|
||||
|
||||
@SerializedName("disabled")
|
||||
private String disabled;
|
||||
|
||||
@SerializedName("emailNotificationID")
|
||||
private String emailNotificationID;
|
||||
|
||||
@SerializedName("emailNotificationType")
|
||||
private String emailNotificationType;
|
||||
|
||||
@SerializedName("endPoint")
|
||||
private String endPoint;
|
||||
|
||||
@SerializedName("energy")
|
||||
private String energy;
|
||||
|
||||
@SerializedName("liliOffCommand")
|
||||
private String liliOffCommand;
|
||||
|
||||
@SerializedName("liliOnCommand")
|
||||
private String liliOnCommand;
|
||||
|
||||
@SerializedName("log")
|
||||
private String log;
|
||||
|
||||
@SerializedName("logTemp")
|
||||
private String logTemp;
|
||||
|
||||
@SerializedName("manufacturer")
|
||||
private String manufacturer;
|
||||
|
||||
@SerializedName("markAsDead")
|
||||
private String markAsDead;
|
||||
|
||||
@SerializedName("mode")
|
||||
private String mode;
|
||||
|
||||
@SerializedName("model")
|
||||
private String model;
|
||||
|
||||
@SerializedName("nodeID")
|
||||
private String nodeID;
|
||||
|
||||
@SerializedName("pollingDeadDevice")
|
||||
private String pollingDeadDevice;
|
||||
|
||||
@SerializedName("pollingTime")
|
||||
private String pollingTime;
|
||||
|
||||
@SerializedName("pollingTimeNext")
|
||||
private String pollingTimeNext;
|
||||
|
||||
@SerializedName("pollingTimeSec")
|
||||
private int pollingTimeSec;
|
||||
|
||||
@SerializedName("power")
|
||||
private String power;
|
||||
|
||||
@SerializedName("productInfo")
|
||||
private String productInfo;
|
||||
|
||||
@SerializedName("pushNotificationID")
|
||||
private String pushNotificationID;
|
||||
|
||||
@SerializedName("pushNotificationType")
|
||||
private String pushNotificationType;
|
||||
|
||||
@SerializedName("remoteGatewayId")
|
||||
private String remoteGatewayId;
|
||||
|
||||
@SerializedName("requestNodeNeighborStat")
|
||||
private String requestNodeNeighborStat;
|
||||
|
||||
@SerializedName("requestNodeNeighborStatTimeStemp")
|
||||
private String requestNodeNeighborStatTimeStemp;
|
||||
|
||||
@SerializedName("requestNodeNeighborState")
|
||||
private String requestNodeNeighborState;
|
||||
|
||||
@SerializedName("requestNodeNeighborStateTimeStemp")
|
||||
private String requestNodeNeighborStateTimeStemp;
|
||||
|
||||
@SerializedName("saveLogs")
|
||||
private String saveLogs;
|
||||
|
||||
@SerializedName("showChildren")
|
||||
private String showChildren;
|
||||
|
||||
@SerializedName("smsNotificationID")
|
||||
private String smsNotificationID;
|
||||
|
||||
@SerializedName("smsNotificationType")
|
||||
private String smsNotificationType;
|
||||
|
||||
@SerializedName("supportedModes")
|
||||
private String supportedModes;
|
||||
|
||||
@SerializedName("targetLevel")
|
||||
private String targetLevel;
|
||||
|
||||
@SerializedName("unit")
|
||||
private String unit;
|
||||
|
||||
@SerializedName("useTemplate")
|
||||
private String useTemplate;
|
||||
|
||||
@SerializedName("status")
|
||||
private String status;
|
||||
|
||||
@SerializedName("sunriseHour")
|
||||
private String sunriseHour;
|
||||
|
||||
@SerializedName("sunsetHour")
|
||||
private String sunsetHour;
|
||||
|
||||
@SerializedName("userDescription")
|
||||
private String userDescription;
|
||||
|
||||
@SerializedName("value")
|
||||
private String value;
|
||||
|
||||
@SerializedName("zwaveBuildVersion")
|
||||
private String zwaveBuildVersion;
|
||||
|
||||
@SerializedName("zwaveCompany")
|
||||
private String zwaveCompany;
|
||||
|
||||
@SerializedName("zwaveInfo")
|
||||
private String zwaveInfo;
|
||||
|
||||
@SerializedName("zwaveRegion")
|
||||
private String zwaveRegion;
|
||||
|
||||
@SerializedName("zwaveVersion")
|
||||
private double zwaveVersion;
|
||||
|
||||
public String getBatteryLevel() {
|
||||
return batteryLevel;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public String getDeviceControlType() {
|
||||
return deviceControlType;
|
||||
}
|
||||
|
||||
public String getEnergy() {
|
||||
return energy;
|
||||
}
|
||||
|
||||
public String getPower() {
|
||||
return power;
|
||||
}
|
||||
|
||||
public String getTargetLevel() {
|
||||
return targetLevel;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
// --- begin yrWeather plugin ---
|
||||
@SerializedName("Humidity")
|
||||
private String Humidity;
|
||||
|
||||
@SerializedName("Pressure")
|
||||
private String Pressure;
|
||||
|
||||
@SerializedName("Temperature")
|
||||
private String Temperature;
|
||||
|
||||
@SerializedName("WeatherCondition")
|
||||
private String WeatherCondition;
|
||||
|
||||
@SerializedName("Wind")
|
||||
private String Wind;
|
||||
|
||||
public String getHumidity() {
|
||||
return Humidity;
|
||||
}
|
||||
|
||||
public String getPressure() {
|
||||
return Pressure;
|
||||
}
|
||||
|
||||
public String getSaveLogs()
|
||||
{
|
||||
return saveLogs;
|
||||
}
|
||||
|
||||
public String getTemperature() {
|
||||
return Temperature;
|
||||
}
|
||||
|
||||
public String getWeatherCondition() {
|
||||
return WeatherCondition;
|
||||
}
|
||||
|
||||
public String getWind() {
|
||||
return Wind;
|
||||
}
|
||||
// --- end yrWeather plugin ---
|
||||
|
||||
public String getUserDescription()
|
||||
{
|
||||
return userDescription;
|
||||
}
|
||||
|
||||
public void setUserDescription(String userDescription)
|
||||
{
|
||||
this.userDescription = userDescription;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.bwssystems.HABridge.plugins.fibaro.json;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Room {
|
||||
@SerializedName("id")
|
||||
private int id;
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("sectionID")
|
||||
private int sectionID;
|
||||
|
||||
@SerializedName("icon")
|
||||
private String icon;
|
||||
|
||||
@SerializedName("defaultSensors")
|
||||
private Sensor defaultSensors;
|
||||
|
||||
@SerializedName("defaultThermostat")
|
||||
private int defaultThermostat;
|
||||
|
||||
@SerializedName("sortOrder")
|
||||
private int sortOrder;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getSectionID()
|
||||
{
|
||||
return sectionID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.bwssystems.HABridge.plugins.fibaro.json;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Scene {
|
||||
private String roomName;
|
||||
|
||||
@SerializedName("id")
|
||||
private String id;
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("type")
|
||||
private String type;
|
||||
|
||||
@SerializedName("properties")
|
||||
private String properties;
|
||||
|
||||
@SerializedName("roomID")
|
||||
private int roomID;
|
||||
|
||||
@SerializedName("iconID")
|
||||
private int iconID;
|
||||
|
||||
@SerializedName("runConfig")
|
||||
private String runConfig;
|
||||
|
||||
@SerializedName("autostart")
|
||||
private boolean autostart;
|
||||
|
||||
@SerializedName("protectedByPIN")
|
||||
private boolean protectedByPIN;
|
||||
|
||||
@SerializedName("killable")
|
||||
private boolean killable;
|
||||
|
||||
@SerializedName("maxRunningInstances")
|
||||
private int maxRunningInstances;
|
||||
|
||||
@SerializedName("runningInstances")
|
||||
private int runningInstances;
|
||||
|
||||
@SerializedName("visible")
|
||||
private boolean visible;
|
||||
|
||||
@SerializedName("isLua")
|
||||
private boolean isLua;
|
||||
|
||||
@SerializedName("triggers")
|
||||
private SceneTriggers triggers;
|
||||
|
||||
@SerializedName("liliStartCommand")
|
||||
private String liliStartCommand;
|
||||
|
||||
@SerializedName("liliStopCommand")
|
||||
private String liliStopCommand;
|
||||
|
||||
@SerializedName("sortOrder")
|
||||
private int sortOrder;
|
||||
|
||||
public String getRoomName() {
|
||||
return roomName;
|
||||
}
|
||||
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getRoomID() {
|
||||
return roomID;
|
||||
}
|
||||
|
||||
public String getLiliStartCommand()
|
||||
{
|
||||
return liliStartCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" + id + ", " + name + "}";
|
||||
}
|
||||
|
||||
public String fibaroaddress;
|
||||
public String fibaroport;
|
||||
public String fibaroAuth;
|
||||
public String fibaroname;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.bwssystems.HABridge.plugins.fibaro.json;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class SceneProperties {
|
||||
@SerializedName("id")
|
||||
private String id;
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.bwssystems.HABridge.plugins.fibaro.json;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class SceneTriggers {
|
||||
@SerializedName("properties")
|
||||
private SceneProperties[] properties;
|
||||
|
||||
@SerializedName("globals")
|
||||
private String[] globals;
|
||||
|
||||
@SerializedName("events")
|
||||
private String[] events;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.bwssystems.HABridge.plugins.fibaro.json;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Sensor {
|
||||
@SerializedName("temperature")
|
||||
private int temperature;
|
||||
|
||||
@SerializedName("humidity")
|
||||
private int humidity;
|
||||
|
||||
@SerializedName("light")
|
||||
private int light;
|
||||
}
|
||||
@@ -1337,20 +1337,21 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
}
|
||||
}
|
||||
};
|
||||
$scope.addFibarotoSettings = function (newfibaroname, newfibaroip, newfibarousername, newfibaropassword) {
|
||||
$scope.addFibarotoSettings = function (newfibaroname, newfibaroip, newfibaroport, newfibarousername, newfibaropassword) {
|
||||
if($scope.bridge.settings.fibaroaddress === undefined || $scope.bridge.settings.fibaroaddress === null) {
|
||||
$scope.bridge.settings.fibaroaddress = { devices: [] };
|
||||
}
|
||||
var newFibaro = {name: newfibaroname, ip: newfibaroip, username: newfibarousername, password: newfibaropassword }
|
||||
var newFibaro = {name: newfibaroname, ip: newfibaroip, port: newfibaroport, username: newfibarousername, password: newfibaropassword }
|
||||
$scope.bridge.settings.fibaroaddress.devices.push(newFibaro);
|
||||
$scope.newfibaroname = null;
|
||||
$scope.newfibaroip = null;
|
||||
$scope.newfibaroport = null;
|
||||
$scope.newfibarousername = null;
|
||||
$scope.newfibaropassword = null;
|
||||
};
|
||||
$scope.removeFibarotoSettings = function (fibaroname, fibaroip) {
|
||||
$scope.removeFibarotoSettings = function (fibaroname, fibaroip, fibaroport) {
|
||||
for(var i = $scope.bridge.settings.fibaroaddress.devices.length - 1; i >= 0; i--) {
|
||||
if($scope.bridge.settings.fibaroaddress.devices[i].name === fibaroname && $scope.bridge.settings.fibaroaddress.devices[i].ip === fibaroip) {
|
||||
if($scope.bridge.settings.fibaroaddress.devices[i].name === fibaroname && $scope.bridge.settings.fibaroaddress.devices[i].ip === fibaroip && $scope.bridge.settings.fibaroaddress.devices[i].port === fibaroport) {
|
||||
$scope.bridge.settings.fibaroaddress.devices.splice(i, 1);
|
||||
}
|
||||
}
|
||||
@@ -1988,14 +1989,13 @@ app.controller('FibaroController', function ($scope, $location, bridgeService, n
|
||||
|
||||
$scope.buildDeviceUrls = function (fibarodevice, dim_control, buildonly) {
|
||||
if(dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0)
|
||||
dimpayload = "http://" + fibarodevice.fibaroaddress + ":" + $scope.fibaro.port + "/api/callAction?deviceID=" + fibarodevice.id + "&name=setValue&arg1=" + dim_control;
|
||||
else
|
||||
dimpayload = "http://" + fibarodevice.fibaroaddress + ":" + $scope.fibaro.port + "/api/callAction?deviceID=" + fibarodevice.id + "&name=turnOn";
|
||||
dimpayload = "http://" + fibarodevice.fibaroaddress + ":" + fibarodevice.fibaroport + "/api/callAction?deviceID=" + fibarodevice.id + "&name=setValue&arg1=" + dim_control;
|
||||
|
||||
onpayload = "http://" + fibarodevice.fibaroaddress + ":" + $scope.fibaro.port + "/api/callAction?deviceID=" + fibarodevice.id + "&name=turnOn";
|
||||
offpayload = "http://" + fibarodevice.fibaroaddress + ":" + $scope.fibaro.port + "/api/callAction?deviceID=" + fibarodevice.id + "&name=turnOff";
|
||||
onpayload = "http://" + fibarodevice.fibaroaddress + ":" + fibarodevice.fibaroport + "/api/callAction?deviceID=" + fibarodevice.id + "&name=turnOn";
|
||||
offpayload = "http://" + fibarodevice.fibaroaddress + ":" + fibarodevice.fibaroport + "/api/callAction?deviceID=" + fibarodevice.id + "&name=turnOff";
|
||||
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, fibarodevice.id, fibarodevice.name, fibarodevice.fibaroname, "switch", "fibaroDevice", null, null);
|
||||
bridgeService.state.device.headers = "[{\"name\":\"Authorization\",\"value\":\"" + fibarodevice.fibaroAuth + "\"}]";
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2004,10 +2004,11 @@ app.controller('FibaroController', function ($scope, $location, bridgeService, n
|
||||
};
|
||||
|
||||
$scope.buildSceneUrls = function (fibaroscene) {
|
||||
onpayload = "http://" + fibaroscene.fibaroaddress + ":" + $scope.fibaro.port + "/api/sceneControl?id=" + fibaroscene.id + "&action=start";
|
||||
offpayload = "http://" + fibaroscene.fibaroaddress + ":" + $scope.fibaro.port + "/api/sceneControl?id=" + fibaroscene.id + "&action=stop";
|
||||
onpayload = "http://" + fibaroscene.fibaroaddress + ":" + fibaroscene.fibaroport + "/api/sceneControl?id=" + fibaroscene.id + "&action=start";
|
||||
offpayload = "http://" + fibaroscene.fibaroaddress + ":" + fibaroscene.fibaroport + "/api/sceneControl?id=" + fibaroscene.id + "&action=stop";
|
||||
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, fibaroscene.id, fibaroscene.name, fibaroscene.fibaroname, "scene", "fibaroScene", null, null);
|
||||
bridgeService.state.device.headers = "[{\"name\":\"Authorization\",\"value\":\"" + fibaroscene.fibaroAuth + "\"}]";
|
||||
$scope.device = bridgeService.state.device;
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
$location.path('/editdevice');
|
||||
|
||||
@@ -63,9 +63,9 @@
|
||||
ng-checked="selectAll"
|
||||
ng-click="toggleSelectAll()"> Name</span></th>
|
||||
<th sortable-header col="id" comparator-fn="comparatorUniqueId">Id</th>
|
||||
<th sortable-header col="category">Category</th>
|
||||
<th sortable-header col="room">Room</th>
|
||||
<th sortable-header col="fibaroname">Fibaro</th>
|
||||
<th sortable-header col="value">Value</th>
|
||||
<th>Build Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -78,9 +78,9 @@
|
||||
ng-click="toggleSelection(fibarodevice.id)">
|
||||
{{fibarodevice.name}}</td>
|
||||
<td>{{fibarodevice.id}}</td>
|
||||
<td>{{fibarodevice.category}}</td>
|
||||
<td>{{fibarodevice.room}}</td>
|
||||
<td>{{fibarodevice.roomName}}</td>
|
||||
<td>{{fibarodevice.fibaroname}}</td>
|
||||
<td>{{fibarodevice.properties.value}}</td>
|
||||
<td>
|
||||
<button class="btn btn-success" type="submit"
|
||||
ng-click="buildDeviceUrls(fibarodevice, device_dim_control, false)">Build Item</button>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<td>{{$index+1}}</td>
|
||||
<td>{{fibaroscene.name}}</td>
|
||||
<td>{{fibaroscene.id}}</td>
|
||||
<td>{{fibaroscene.room}}</td>
|
||||
<td>{{fibaroscene.roomName}}</td>
|
||||
<td>{{fibaroscene.fibaroname}}</td>
|
||||
<td>
|
||||
<button class="btn btn-success" type="submit"
|
||||
|
||||
@@ -152,6 +152,7 @@
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>IP</th>
|
||||
<th>Port</th>
|
||||
<th>Username</th>
|
||||
<th>Password </th>
|
||||
<th>Manage</th>
|
||||
@@ -160,11 +161,12 @@
|
||||
<tr ng-repeat="fibaro in bridge.settings.fibaroaddress.devices">
|
||||
<td>{{fibaro.name}}</td>
|
||||
<td>{{fibaro.ip}}</td>
|
||||
<td>{{fibaro.port}}</td>
|
||||
<td>{{fibaro.username}}</td>
|
||||
<td ng-if="fibaro.password">*******</td>
|
||||
<td ng-if="!fibaro.password"> </td>
|
||||
<td><button class="btn btn-danger" type="submit"
|
||||
ng-click="removeFibarotoSettings(fibaro.name, fibaro.ip)">Del</button></td>
|
||||
ng-click="removeFibarotoSettings(fibaro.name, fibaro.ip, fibaro.port)">Del</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input id="bridge-settings-next-fibaro-name"
|
||||
@@ -173,6 +175,9 @@
|
||||
<td><input id="bridge-settings-next-fibaro-ip"
|
||||
class="form-control" type="text" ng-model="newfibaroip"
|
||||
placeholder="192.168.1.2"></td>
|
||||
<td><input id="bridge-settings-next-fibaro-port"
|
||||
class="form-control" type="text" ng-model="newfibaroport"
|
||||
placeholder="80"></td>
|
||||
<td><input id="bridge-settings-next-fibaro-username"
|
||||
class="form-control" type="text" ng-model="newfibarousername"
|
||||
placeholder="Fibaro username"></td>
|
||||
@@ -180,7 +185,7 @@
|
||||
class="form-control" type="password" ng-model="newfibaropassword"
|
||||
placeholder="Fibaro password"></td>
|
||||
<td><button class="btn btn-success" type="submit"
|
||||
ng-click="addFibarotoSettings(newfibaroname, newfibaroip, newfibarousername, newfibaropassword)">Add</button></td>
|
||||
ng-click="addFibarotoSettings(newfibaroname, newfibaroip, newfibaroport, newfibarousername, newfibaropassword)">Add</button></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user