Files
ha-bridge/src/main/java/com/bwssystems/HABridge/api/hue/DeviceState.java
Florian Förderreuther ce79fb4b82 Light type detection and filter for device list
"Extended color light" isn't used anymore for all devices without thinking about it. It will now automatically differentiate between Color and Dimmable light by the following logic: 
1. If it's  Philips Hue passthru look at the state: if it contains the attribute "colormode" it's a Extended color light, otherwise it's a Dimmable light.
2. If it's no passthru it's a dimmable light if the colorUrl has no content. 

I didn't use On/Off light because i disovered that a) the hue app treats these exactly the same as dimmable light, you can still "change the brightness" and b) the amazon echo doesn't find these lights without the skill

I also enhanced the filter options in the web ui.
You have a textbox "Show devices visible to". You can fill in an ip-address and there will only be devices displayed that a) have the ip address in the requesterFilter or b) don't filter by requester.
If you tick the checkbox "Must contain filter" option b isn't used. This means also if you check the box with no ip address in the textbox only devices without request filter will be shown.
Also there is a filter by device type.
All these 3 filter options will be remembered as long as the browser tab is closed.
2017-08-02 07:34:06 +02:00

146 lines
3.1 KiB
Java

package com.bwssystems.HABridge.api.hue;
import java.util.ArrayList;
import java.util.List;
/**
* Created by arm on 4/14/15.
*/
public class DeviceState {
private boolean on;
private int bri;
private Integer hue;
private Integer sat;
private String effect;
private List<Double> xy;
private Integer ct;
private String alert;
private String colormode;
private boolean reachable;
// private int transitiontime;
public boolean isOn() {
return on;
}
public void setOn(boolean on) {
this.on = on;
}
public int getBri() {
return bri;
}
public void setBri(int bri) {
this.bri = bri;
}
public int getHue() {
return hue != null ? hue.intValue() : 0;
}
public void setHue(int hue) {
this.hue = hue;
this.colormode = "hs";
}
public int getSat() {
return sat != null ? sat.intValue() : 0;
}
public void setSat(int sat) {
this.sat = sat;
this.colormode = "hs";
}
public String getEffect() {
return effect;
}
public void setEffect(String effect) {
this.effect = effect;
}
public int getCt() {
return ct != null ? ct.intValue() : 0;
}
public void setCt(int ct) {
this.ct = ct;
this.colormode = "ct";
}
public String getAlert() {
return alert;
}
public void setAlert(String alert) {
this.alert = alert;
}
public String getColormode() {
return colormode;
}
public void setColormode(String colormode) {
this.colormode = colormode;
}
public boolean isReachable() {
return reachable;
}
public void setReachable(boolean reachable) {
this.reachable = reachable;
}
public List<Double> getXy() {
return xy;
}
public void setXy(List<Double> xy) {
this.xy = xy;
this.colormode = "xy";
}
// public int getTransitiontime() {
// return transitiontime;
// }
// public void setTransitiontime(int transitiontime) {
// this.transitiontime = transitiontime;
// }
public static DeviceState createDeviceState(boolean color) {
DeviceState newDeviceState = new DeviceState();
newDeviceState.fillIn(color);
if (color) {
newDeviceState.setColormode("xy");
newDeviceState.setHue(0);
newDeviceState.setSat(0);
newDeviceState.setCt(153);
ArrayList<Double> doubleArray = new ArrayList<Double>();
doubleArray.add(0.3146);
doubleArray.add(0.3303);
newDeviceState.setXy(doubleArray);
}
return newDeviceState;
}
public void fillIn(boolean color) {
if(this.getAlert() == null)
this.setAlert("none");
if (color) {
if(this.getEffect() == null)
this.setEffect("none");
}
this.setReachable(true);
}
@Override
public String toString() {
return "DeviceState{" +
"on=" + on +
", bri=" + bri +
'}';
}
}