New file |
| | |
| | | using Newtonsoft.Json.Linq;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | |
|
| | | namespace ZigBee.Device
|
| | | {
|
| | | /// <summary>
|
| | | /// 色温灯
|
| | | /// </summary>
|
| | | public class ColorTemperatureLight : LightBase
|
| | | {
|
| | | public ColorTemperatureLight()
|
| | | {
|
| | | this.Type = DeviceType.ColorTemperatureLight;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | ///亮度,整形,取值范围:0-254表示0%-100% |
| | | /// </summary>
|
| | | [Newtonsoft.Json.JsonIgnore]
|
| | | public int Level = 0;
|
| | |
|
| | | /// <summary>
|
| | | ///色温,取值范围:3000~6000(这里记录的值的单位是 千)
|
| | | /// </summary>
|
| | | [Newtonsoft.Json.JsonIgnore]
|
| | | public int ColorTemperature = 0;
|
| | |
|
| | | /// <summary>
|
| | | ///蜂鸣器是否在响着(true:响着 false:不响)
|
| | | /// </summary>
|
| | | [Newtonsoft.Json.JsonIgnore]
|
| | | public bool IsBuzzerRing = false;
|
| | |
|
| | | /// <summary>
|
| | | /// 读取亮度
|
| | | /// </summary>
|
| | | public void ReadLevel()
|
| | | {
|
| | | ReadAttri(Device.Cluster_ID.LevelControl, AttriButeId.LevelControl);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 读取色温
|
| | | /// </summary>
|
| | | public void ReadColorTemperature()
|
| | | {
|
| | | ReadAttri(Device.Cluster_ID.ColorControl, AttriButeId.LevelControl);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 读取蜂鸣器状态(小夜灯专用)
|
| | | /// </summary>
|
| | | public void ReadBuzzerStatu()
|
| | | {
|
| | | ReadAttri((Cluster_ID)1282, 0);
|
| | | }
|
| | |
|
| | | ///<summary >
|
| | | ///设置设备亮度(Level)
|
| | | ///<para>value:亮度值取值范围:0-254</para>
|
| | | /// </summary>
|
| | | 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());
|
| | | }
|
| | |
|
| | | ///<summary >
|
| | | ///设置设备色温
|
| | | ///<para>value:色温值取值范围:3400-6000</para>
|
| | | /// </summary>
|
| | | 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());
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 发送打开获取关闭蜂鸣器的命令(目前先这样吧,小夜灯的蜂鸣器)
|
| | | /// </summary>
|
| | | /// <param name="isOpen"></param>
|
| | | public void SendBuzzerSwitchControl(bool isOpen)
|
| | | {
|
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 1282 }, { "Command", 0 } };
|
| | | var data = new JObject {
|
| | | { "WarningMode", isOpen==true?1:0 },//0:关闭报警 1:打开报警
|
| | | { "Strobe", 0 },//是否启动报警灯 0:不启动 1:启动
|
| | | { "SirenLevel", 0 },//报警音量 0:Low 1:Medium 2:high 3: very high
|
| | | { "WarningDuration", isOpen==true?10:0 }, //报警时长 0 -65535 单位:秒
|
| | | { "StrobeDutyCycle", 50 }, //报警等闪烁占空比 0-100
|
| | | { "StrobeLevel", 1 } //报警灯亮度 0:Low 1:Medium 2:high 3: very high
|
| | | };
|
| | | jObject.Add("Data", data);
|
| | |
|
| | | //主题可以乱写的
|
| | | Gateway.Send("SendSwitchCommand", jObject.ToString());
|
| | | }
|
| | | }
|
| | | }
|