package com.bwssystems.HABridge.api.hue;

import com.bwssystems.HABridge.dao.DeviceDescriptor;
import com.bwssystems.HABridge.dao.GroupDescriptor;

/**
 * Created by arm on 4/14/15.
 */
public class DeviceResponse {
    private DeviceState state;
    private String type;
    private String name;
    private String modelid;
    private String manufacturername;
    private String luminaireuniqueid;
    private String uniqueid;
    private String swversion;
    private String swconfigid;
    private String productid;

    public DeviceState getState() {
        return state;
    }

    public void setState(DeviceState state) {
        this.state = state;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getModelid() {
        return modelid;
    }

    public void setModelid(String modelid) {
        this.modelid = modelid;
    }

    public String getManufacturername() {
        return manufacturername;
    }

    public void setManufacturername(String manufacturername) {
        this.manufacturername = manufacturername;
    }

    public String getUniqueid() {
        return uniqueid;
    }

    public void setUniqueid(String uniqueid) {
        this.uniqueid = uniqueid;
    }

    public String getSwversion() {
        return swversion;
    }

    public void setSwversion(String swversion) {
        this.swversion = swversion;
    }

    public String getSwconfigid() {
        return swconfigid;
    }

    public void setSwconfigid(String swconfigid) {
        this.swconfigid = swconfigid;
    }
    
    public String getProductid() {
        return productid;
    }

	public void setProductid(String productid) {
        this.productid = productid;
    }


    public String getLuminaireuniqueid() {
		return luminaireuniqueid;
	}

	public void setLuminaireuniqueid(String luminaireuniqueid) {
		this.luminaireuniqueid = luminaireuniqueid;
	}

	public static DeviceResponse createResponse(DeviceDescriptor device){
        DeviceResponse response = new DeviceResponse();
        response.setState(device.getDeviceState());

        response.setName(device.getName());
        response.setUniqueid(device.getUniqueid());
        response.setManufacturername("Philips");
            
        if (device.isColorDevice()) {
            response.setType("Extended color light");
            response.setModelid("LCT010");
            response.setSwversion("1.15.2_r19181");
            response.setSwconfigid("F921C859");
            response.setProductid("Philips-LCT010-1-A19ECLv4");    
        } else {
            response.setType("Dimmable light");
            response.setModelid("LWB007");
            response.setSwversion("66012040");
        }
        
        response.setLuminaireuniqueid(null);

        return response;
    }

    public static DeviceResponse createResponseForVirtualLight(GroupDescriptor group){
        DeviceResponse response = new DeviceResponse();
        response.setState(group.getAction());

        response.setName(group.getName());
        response.setUniqueid("00:17:88:5E:D3:FF-" + String.format("%02X", Integer.parseInt(group.getId())));
        response.setManufacturername("Philips");
        response.setType("Extended color light");
        response.setModelid("LCT010");
        response.setSwversion("1.15.2_r19181");
        response.setSwconfigid("F921C859");
        response.setProductid("Philips-LCT010-1-A19ECLv4");    
        
        response.setLuminaireuniqueid(null);

        return response;
    }


}

@@ -512,16 +512,48 @@
 oductid;
+%0A    private String productname;
 %0A%0A    pu
@@ -1943,16 +1943,185 @@
 %0A    %7D%0A%0A
+    public String getProductName() %7B%0A        return productname;%0A    %7D%0A%0A%09public void setProductName(String productname) %7B%0A        this.productname = productname;%0A    %7D%0A%0A
 %0A    pub
@@ -2760,33 +2760,33 @@
 etModelid(%22LCT01
-0
+5
 %22);%0A            
@@ -2806,35 +2806,36 @@
 wversion(%221.
-15.2_r19181
+46.13_r26312
 %22);%0A        
@@ -2858,32 +2858,32 @@
 Swconfigid(%22
-F921C859
+52E3234B
 %22);%0A        
@@ -2914,33 +2914,33 @@
 d(%22Philips-LCT01
-0
+5
 -1-A19ECLv4%22);  
@@ -2929,32 +2929,83 @@
 15-1-A19ECLv
-4%22);    
+5%22);%0A            response.setProductName(%22Hue color lamp%22);
 %0A        %7D e
@@ -3516,21 +3516,27 @@
 00:1
-7:88:5E:D3:FF
+1:22:33:44:55:66:77
 -%22 +
@@ -3726,17 +3726,17 @@
 d(%22LCT01
-0
+5
 %22);%0A    
@@ -3768,19 +3768,20 @@
 (%221.
-15.2_r19181
+46.13_r26312
 %22);%0A
@@ -3816,16 +3816,16 @@
 id(%22
-F921C859
+52E3234B
 %22);%0A
@@ -3868,17 +3868,17 @@
 ps-LCT01
-0
+5
 -1-A19EC
@@ -3883,16 +3883,63 @@
 ECLv
-4
+5
 %22);
+%0A  
     
+  response.setProductName(%22Hue color lamp%22);
 %0A   

Update DeviceResponse.java