为什么:并入宿主项目后须与宿主日志体系一致——宿主统一用 pkg/logger 初始化 logrus 全局实例并直接 logrus.Xxx 包级调用;包一层 Logger 接口会让 logrus 的 caller 定位(报告调用文件:行号)失准。 改动: - 删除 logger 包(Logger 接口 / Default / SetDefault,默认本就是 logrus.StandardLogger) - 11 个结构体移除 lgr logger.Logger 字段、SetLogger 方法及构造中的 lgr 初始化 - 192 处 lgr.Xxxf 调用改为 logrus.Xxxf,日志消息文本保持不变 - xiaomi.Client 移除 Logger() 访问器,air_conditioner 回读日志去掉判空调用直连 logrus - miot_i18n.go 两处标准库 log.Printf 改为 logrus.Errorf,统一日志出口 - go.mod:logrus 从 indirect 提升为直接依赖 - goimports/goformat 全树规范化:此前部分文件未 gofmt(单行 if、对齐),本次顺带 格式化,纯空白/换行变化,无逻辑改动 验证:go build / go vet / go test ./... 全部通过(bridge、miot、xiaomi、devices、specs)
66 lines
2.1 KiB
Go
66 lines
2.1 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"
|
|
)
|