主要变更: **类型系统重构** - HomeInfo.ID/RoomInfo.ID/HomeID 从 string 改为 int64,json tag 使用 ,string - GetHome/GetRooms/GetRoomDevices 接口同步修改 - 新增 int64FromStr 工具函数,更新 parseHomeInfo 解析逻辑 **新增 Speaker 设备** - 新增 KindSpeaker 类型 - classify 映射覆盖 speaker/bluetooth-speaker/alarm-clock/media-player/playback/music **设备驱动重构** - AC 驱动彻底重写:从硬编码常量改为基于 SPEC ValueList 的动态 valMapper - 所有设备(Fan/Humidifier/Light/OccupancySensor/Switch/TempHumiditySensor/Thermostat/Vacuum/WaterHeater/Cover)新增 GetState() 和 FetchState(ctx) 接口 - base.go 新增 specResolver.format() 方法 **MIoT 模块增强** - MIoTClient 新增 homeIDs 字段,支持按家庭过滤设备 - RefreshDevices 支持 homeIDs 参数 - SpecStdLib 引入 logger.Logger,log.Printf 全部迁移为结构化日志 **其他** - Config 新增 RedirectURL 和 HomeIDs 字段 - AuthInfo.ExpiresIn 类型从 int 改为 int32 - UUID 生成简化为 hex.EncodeToString - 新增 github.com/sirupsen/logrus 依赖 - .gitignore 新增 examples/*/data/ 忽略规则 - 删除已提交的 config.json 敏感配置
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package devices
|
|
|
|
// ── 设备属性名常量 ──
|
|
// 用于 OnStateChanged 回调的 changed 字段,switch 前先用 deviceType 区分设备类型。
|
|
|
|
const (
|
|
// ── 通用 ──
|
|
PropOn = "on" // 所有设备
|
|
PropMode = "mode" // AC / Fan / Vacuum
|
|
PropSwing = "swing" // AC / Fan
|
|
PropFanLevel = "fan-level" // AC / Fan / Humidifier / Vacuum
|
|
PropTargetTemperature = "target-temperature" // AC / Thermostat / WaterHeater
|
|
PropTemperature = "temperature" // AC / Thermostat / WaterHeater
|
|
PropTargetHumidity = "target-humidity" // AC / Humidifier
|
|
PropRelativeHumidity = "relative-humidity" // AC
|
|
|
|
// ── 空调专属 ──
|
|
PropHeater = "heater"
|
|
PropEco = "eco"
|
|
|
|
// ── 灯光 ──
|
|
PropBrightness = "brightness"
|
|
PropColorTemperature = "color-temperature"
|
|
PropColor = "color"
|
|
|
|
// ── 扫地机 ──
|
|
PropBattery = "battery"
|
|
|
|
// ── 窗帘 ──
|
|
PropPosition = "position"
|
|
|
|
// ── 传感器 ──
|
|
PropTemperatureHumidity = "temperature_humidity"
|
|
PropOccupancy = "occupancy"
|
|
|
|
// ── 音箱 ──
|
|
PropVolume = "volume"
|
|
PropMute = "mute"
|
|
PropPlayState = "play-state"
|
|
)
|
|
|
|
const (
|
|
PropValueTrue = "true"
|
|
PropValueFalse = "false"
|
|
)
|