**AC 驱动增强** - 支持 thermostat + air-conditioner + air-fresh 多服务三合一设备,属性跨服务合并解析 - 新增 specResolver.findValListInService/findInService/hasService/serviceShortName 方法 - 移除 KindThermostat,heater/electric-blanket/thermostat 重新归类为 KindAirConditioner **Cover 窗帘重构** - CoverProps 结构化:Position/Status/Fault 分离 - SetPosition 优先写 target-position,回退 current-position - OnPropsChanged/FetchProps 支持多属性同步刷新 **新增设备类型** - Plug 驱动:插座/插头,支持开合、在线状态、属性变更订阅 - Gateway 驱动:网关设备类型识别 - miot/miot_errors.go:新增 MIoT 云端错误码定义 **MIoT 客户端健壮性** - SetProp 空结果视为失败;设备被移除或离线时自动刷新设备列表 - GetDevices 的 has_more 改用 parseBool 严格解析 - MIPS SubscribeMany 批量订阅减少往返 - matchURN 改为按段精确匹配,避免 tofan 误匹配 fan **Bridge** - 移除 Thermostat case,Cover 改用结构化 CoverProps - 新增设备创建后自动订阅属性变更 **其他** - 日志整体 Info → Debug 降噪 - .gitignore 忽略 /.codebuddy/memory - 更新 devices_test 与 08_adv_filter_classify 示例
66 lines
2.2 KiB
Go
66 lines
2.2 KiB
Go
package devices
|
|
|
|
// ── 设备类型常量 ──
|
|
// 用于 bridge.OnPropsChanged 的 deviceType 字段 / factory 分类
|
|
|
|
const (
|
|
TypeAirConditioner = "air_conditioner" // 空调
|
|
TypeLight = "light" // 灯
|
|
TypeSwitch = "switch" // 开关
|
|
TypeFan = "fan" // 风扇
|
|
TypeCover = "cover" // 窗帘/遮阳帘
|
|
TypeHumidifier = "humidifier" // 加湿器
|
|
TypeVacuum = "vacuum" // 吸尘器/扫地机器人
|
|
TypeWaterHeater = "water_heater" // 热水器
|
|
TypeOccupancySensor = "sensor_occupy" // 人体传感器
|
|
TypeTempHumidSensor = "sensor" // 温湿度传感器(官方 URN type)
|
|
TypeSpeaker = "speaker" // 音箱
|
|
TypeGateway = "gateway" // 网关
|
|
TypePlug = "plug" // 插座
|
|
|
|
)
|
|
|
|
// ── 设备属性名常量 ──
|
|
// 用于 OnPropsChanged 回调的 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"
|
|
)
|