using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Text;
namespace ZigBee.Device
{
///
/// 色温灯
///
public class ColorTemperatureLight : LightBase
{
public ColorTemperatureLight()
{
this.Type = DeviceType.ColorTemperatureLight;
}
///
///亮度,整形,取值范围:0-254表示0%-100%
///
[Newtonsoft.Json.JsonIgnore]
public int Level = 0;
///
///色温,取值范围:3400~6000
///
[Newtonsoft.Json.JsonIgnore]
public int ColorTemperature = 0;
///
/// 读取亮度
///
public void ReadLevel()
{
ReadAttri(Device.Cluster_ID.LevelControl, AttriButeId.LevelControl);
}
///
/// 读取色温
///
public void ReadColorTemperature()
{
ReadAttri(Device.Cluster_ID.ColorControl, AttriButeId.LevelControl);
}
///
///设置设备亮度(Level)
///value:亮度值取值范围:0-254
///
public void SetLevel(int value)
{
var jObject = new JObject {
{ "DeviceAddr", DeviceAddr},
{ "Epoint", DeviceEpoint},
{ "Cluster_ID", 8 },
{ "Command", 4},
{ "SendMode", 2 }
};
var data = new JObject {
{ "Level", value },
{ "TransitionTime", 0 }
};
jObject.Add("Data", data);
Gateway?.Send("DeviceControl", jObject.ToString());
}
///
///设置设备色温
///value:色温值取值范围:3400-6000
///
public void SetColorTemperature(int value)
{
var jObject = new JObject {
{ "DeviceAddr", DeviceAddr},
{ "Epoint", DeviceEpoint},
{ "Cluster_ID", 768 },
{ "Command", 10},
{ "SendMode", 2 }
};
var data = new JObject {
{ "ColorTemperature", value },
{ "TransitionTime", 0 }
};
jObject.Add("Data", data);
Gateway?.Send("DeviceControl", jObject.ToString());
}
}
}