Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有一个单位兼容警告 #205

Open
Juddd opened this issue Mar 8, 2025 · 9 comments · May be fixed by home-assistant/core#141518
Open

有一个单位兼容警告 #205

Juddd opened this issue Mar 8, 2025 · 9 comments · May be fixed by home-assistant/core#141518

Comments

@Juddd
Copy link

Juddd commented Mar 8, 2025

前言

  • 请自行搜索历史issues是否存在相同问题
  • 尽量按格式填写Issues模版中的必要信息,没有这些信息就算提交了也解决不了任何问题。

问题描述
有一个单位兼容警告(不是错误,只是警告)

环境信息:

  • Homeassistant版本: [e.g. 2025.2.4]

设备信息
是一个海尔燃气热水器,型号为海尔kln-eco7,这是你要的.storage/haier/device_5408535FCE63.json:
{
"version": 1,
"minor_version": 1,
"key": "haier/device_5408535FCE63.json",
"data": {
"device": {
"name": "燃气热水器",
"type": "1801701C",
"product_code": "GD0RAR004",
"product_name": "JSLQ27-16KLN-ECO7FLRGU1",
"wifi_type": "201c120000118674181700418007685400000000000000000000000000000040"
},
"attributes": [
{
"desc": "随温感(e动红外)判定温度",
"invisible": false,
"name": "ecoJudgeTemp",
"operationType": "I",
"readable": true,
"value": "11.0",
"valueRange": {
"dataStep": {
"dataType": "Double",
"maxValue": "35.0",
"minValue": "0.0",
"step": "0.1"
},
"type": "STEP"
},
"writable": true
},
{
"desc": "浴缸注水实际已注水量",
"invisible": false,
"name": "tankCurrentFlux",
"readable": true,
"value": "0",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "990",
"minValue": "0",
"step": "1"
},
"type": "STEP"
},
"writable": false
},
{
"defaultValue": "32",
"desc": "目标温度",
"invisible": false,
"name": "targetTemp",
"operationType": "IG",
"readable": true,
"value": "55",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "60",
"minValue": "32",
"step": "1"
},
"type": "STEP"
},
"writable": true
},
{
"desc": "本次用户用水燃烧时间",
"invisible": false,
"name": "userWaterBurnTime",
"readable": true,
"value": "0",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "60",
"minValue": "0",
"step": "1"
},
"type": "STEP"
},
"writable": false
},
{
"desc": "智慧零冷水功能有无",
"invisible": false,
"name": "zeroColdWaterFuncExist",
"readable": true,
"value": "true",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "有"
},
{
"data": "false",
"desc": "无"
}
],
"type": "LIST"
},
"writable": false
},
{
"desc": "累计用水量",
"invisible": false,
"name": "totalWaterL",
"readable": true,
"value": "3152",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "4294967295",
"minValue": "0",
"step": "1"
},
"type": "STEP"
},
"writable": false
},
{
"defaultValue": "0",
"desc": "浴缸状态",
"invisible": false,
"name": "tankCode",
"operationType": "G",
"readable": true,
"value": "0",
"valueRange": {
"dataList": [
{
"data": "0",
"desc": "0"
},
{
"data": "1",
"desc": "1"
},
{
"data": "2",
"desc": "2"
},
{
"data": "3",
"desc": "3"
},
{
"data": "4",
"desc": "4"
},
{
"data": "5",
"desc": "5"
},
{
"data": "6",
"desc": "6"
},
{
"data": "7",
"desc": "7"
},
{
"data": "8",
"desc": "8"
},
{
"data": "9",
"desc": "9"
},
{
"data": "10",
"desc": "10"
},
{
"data": "11",
"desc": "11"
},
{
"data": "12",
"desc": "12"
},
{
"data": "13",
"desc": "13"
},
{
"data": "14",
"desc": "14"
},
{
"data": "15",
"desc": "15"
}
],
"type": "LIST"
},
"writable": true
},
{
"desc": "浴缸注水状态",
"invisible": false,
"name": "tankWaterLevel",
"readable": true,
"value": "false",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "注水满"
},
{
"data": "false",
"desc": "注水未满"
}
],
"type": "LIST"
},
"writable": false
},
{
"defaultValue": "0",
"desc": "协议版本号",
"invisible": false,
"name": "prtlVersion",
"readable": true,
"value": "3",
"valueRange": {
"dataList": [
{
"data": "0",
"desc": "版本0"
},
{
"data": "1",
"desc": "版本1"
},
{
"data": "2",
"desc": "版本2"
},
{
"data": "3",
"desc": "版本3"
},
{
"data": "4",
"desc": "版本4"
},
{
"data": "5",
"desc": "版本5"
},
{
"data": "6",
"desc": "版本6"
},
{
"data": "7",
"desc": "版本7"
}
],
"type": "LIST"
},
"writable": false
},
{
"defaultValue": "0",
"desc": "消除浴缸注水满标志",
"invisible": false,
"name": "clearTankWaterFullRemind",
"operationType": "I",
"readable": false,
"valueRange": {
"dataList": [
{
"data": "0",
"desc": "停止提醒"
}
],
"type": "LIST"
},
"writable": true
},
{
"desc": "设置半管循环运行模式",
"invisible": false,
"name": "halfPipeOpModeSet",
"operationType": "I",
"readable": true,
"value": "0",
"valueRange": {
"dataList": [
{
"data": "0",
"desc": "自动模式"
},
{
"data": "1",
"desc": "手动模式"
}
],
"type": "LIST"
},
"writable": true
},
{
"desc": "手动半管循环时长设置值",
"invisible": false,
"name": "halfPipeTimeSet",
"operationType": "I",
"readable": true,
"value": "30",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "1800",
"minValue": "0",
"step": "1"
},
"type": "STEP"
},
"writable": true
},
{
"defaultValue": "0",
"desc": "设置零冷水运行状态",
"invisible": false,
"name": "zeroColdWaterStatus",
"operationType": "IG",
"readable": true,
"value": "0",
"valueRange": {
"dataList": [
{
"data": "0",
"desc": "关闭"
},
{
"data": "1",
"desc": "单次循环"
},
{
"data": "2",
"desc": "定时循环"
},
{
"data": "3",
"desc": "水动循环"
},
{
"data": "4",
"desc": "云智慧循环"
},
{
"data": "10",
"desc": "半管循环"
}
],
"type": "LIST"
},
"writable": true
},
{
"defaultValue": "1",
"desc": "日期日",
"invisible": false,
"name": "dateDD",
"operationType": "G",
"readable": true,
"value": "30",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "31",
"minValue": "1",
"step": "1"
},
"type": "STEP"
},
"writable": true
},
{
"desc": "额定功率",
"invisible": false,
"name": "ratedPower",
"readable": true,
"value": "16",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "255",
"minValue": "0",
"step": "1"
},
"type": "STEP"
},
"writable": false
},
{
"defaultValue": "35",
"desc": "洗浴温度(组命令)",
"invisible": false,
"name": "scourTargetTemp",
"operationType": "G",
"readable": false,
"value": "35",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "60",
"minValue": "35",
"step": "1"
},
"type": "STEP"
},
"writable": true
},
{
"desc": "风机自清洁运转状态",
"invisible": false,
"name": "fanSelfCleaningStatus",
"operationType": "I",
"readable": true,
"value": "false",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "自清洁运转中"
},
{
"data": "false",
"desc": "未在自清洁状态"
}
],
"type": "LIST"
},
"writable": true
},
{
"defaultValue": "0",
"desc": "消除用户用水燃烧半小时提醒",
"invisible": false,
"name": "clearHalfHourRemind",
"operationType": "I",
"readable": false,
"valueRange": {
"dataList": [
{
"data": "0",
"desc": "停止提醒"
}
],
"type": "LIST"
},
"writable": true
},
{
"defaultValue": "19:10:01",
"desc": "定时循环结束日期",
"invisible": false,
"name": "timingCycleEndDate",
"operationType": "G",
"readable": true,
"value": "19:10:01",
"valueRange": {
"dataDate": {
"beginDate": "01:01:01",
"endDate": "99:12:31",
"format": "yy:MM:dd"
},
"type": "DATE"
},
"writable": true
},
{
"desc": "浴缸注水功能",
"invisible": false,
"name": "tankWateringStatus",
"operationType": "I",
"readable": true,
"value": "false",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "开"
},
{
"data": "false",
"desc": "关"
}
],
"type": "LIST"
},
"writable": true
},
{
"desc": "曲线手动设置完成标识",
"invisible": false,
"name": "curveManualSetSuccess",
"readable": true,
"value": "false",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "曲线已手动下载过"
},
{
"data": "false",
"desc": "曲线未手动设置过,可以由服务器下发"
}
],
"type": "LIST"
},
"writable": false
},
{
"desc": "水流状态",
"invisible": false,
"name": "flowStatus",
"readable": true,
"value": "false",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "有"
},
{
"data": "false",
"desc": "无"
}
],
"type": "LIST"
},
"writable": false
},
{
"defaultValue": "0",
"desc": "当前时间分钟",
"invisible": false,
"name": "timeMM",
"operationType": "G",
"readable": true,
"value": "22",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "59",
"minValue": "0",
"step": "1"
},
"type": "STEP"
},
"writable": true
},
{
"defaultValue": "1",
"desc": "星期几",
"invisible": false,
"name": "week",
"operationType": "G",
"readable": true,
"value": "4",
"valueRange": {
"dataList": [
{
"data": "1",
"desc": "星期一"
},
{
"data": "2",
"desc": "星期二"
},
{
"data": "3",
"desc": "星期三"
},
{
"data": "4",
"desc": "星期四"
},
{
"data": "5",
"desc": "星期五"
},
{
"data": "6",
"desc": "星期六"
},
{
"data": "7",
"desc": "星期日"
}
],
"type": "LIST"
},
"writable": true
},
{
"defaultValue": "19:10:01",
"desc": "定时循环开始日期",
"invisible": false,
"name": "timingCycleStartDate",
"operationType": "G",
"readable": true,
"value": "19:10:01",
"valueRange": {
"dataDate": {
"beginDate": "01:01:01",
"endDate": "99:12:31",
"format": "yy:MM:dd"
},
"type": "DATE"
},
"writable": true
},
{
"defaultValue": "0",
"desc": "定时循环目标温度",
"invisible": false,
"name": "timingCMTargetTemperature",
"operationType": "G",
"readable": true,
"value": "42",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "70",
"minValue": "0",
"step": "1"
},
"type": "STEP"
},
"writable": true
},
{
"desc": "海拔自适应功能状态",
"invisible": false,
"name": "altitudeAdaptationStatus",
"readable": true,
"value": "true",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "开"
},
{
"data": "false",
"desc": "关"
}
],
"type": "LIST"
},
"writable": false
},
{
"desc": "燃烧时间半小时提醒",
"invisible": false,
"name": "burnTimeHalfHourRemindStatus",
"readable": true,
"value": "false",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "正在提醒"
},
{
"data": "false",
"desc": "未提醒"
}
],
"type": "LIST"
},
"writable": false
},
{
"defaultValue": "16",
"desc": "设定额定功率",
"invisible": false,
"name": "targetRatedPower",
"operationType": "G",
"readable": true,
"value": "16",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "16",
"minValue": "16",
"step": "1"
},
"type": "STEP"
},
"writable": true
},
{
"desc": "风机状态",
"invisible": false,
"name": "fanStatus",
"readable": true,
"value": "false",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "运行"
},
{
"data": "false",
"desc": "停止"
}
],
"type": "LIST"
},
"writable": false
},
{
"defaultValue": "1",
"desc": "洗浴状态",
"invisible": false,
"name": "scourState",
"operationType": "IG",
"readable": true,
"value": "1",
"valueRange": {
"dataList": [
{
"data": "1",
"desc": "普通模式"
},
{
"data": "2",
"desc": "注水模式"
},
{
"data": "5",
"desc": "e感温模式"
},
{
"data": "7",
"desc": "厨房模式"
},
{
"data": "129",
"desc": "智慧家-冲凉洗"
},
{
"data": "130",
"desc": "智慧家-高温泡"
},
{
"data": "131",
"desc": "智慧家-老人浴"
},
{
"data": "132",
"desc": "智慧家-婴儿洗"
},
{
"data": "139",
"desc": "智慧家-温暖浴"
}
],
"type": "LIST"
},
"writable": true
},
{
"desc": "出水温度",
"invisible": false,
"name": "outWaterTemp",
"readable": true,
"value": "18.0",
"valueRange": {
"dataStep": {
"dataType": "Double",
"maxValue": "100.0",
"minValue": "0.0",
"step": "0.5"
},
"type": "STEP"
},
"writable": false
},
{
"defaultValue": "true",
"desc": "开关机状态",
"invisible": false,
"name": "onOffStatus",
"operationType": "IG",
"readable": true,
"value": "true",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "开机"
},
{
"data": "false",
"desc": "关机"
}
],
"type": "LIST"
},
"writable": true
},
{
"desc": "查询所有属性",
"invisible": true,
"name": "getAllProperty",
"operationType": "I",
"readable": true,
"valueRange": {
"dataList": [
{
"data": "getAllProperty"
}
],
"type": "LIST"
},
"writable": true
},
{
"defaultValue": "0",
"desc": "当前时间小时",
"invisible": false,
"name": "timeHH",
"operationType": "G",
"readable": true,
"value": "2",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "23",
"minValue": "0",
"step": "1"
},
"type": "STEP"
},
"writable": true
},
{
"desc": "停止报警",
"invisible": true,
"name": "stopCurrentAlarm",
"operationType": "I",
"readable": true,
"valueRange": {
"dataList": [
{
"data": "stopCurrentAlarm"
}
],
"type": "LIST"
},
"writable": true
},
{
"defaultValue": "0",
"desc": "实际曲线ID",
"invisible": false,
"name": "curveID",
"readable": true,
"value": "0",
"valueRange": {
"dataList": [
{
"data": "0",
"desc": "曲线0"
},
{
"data": "1",
"desc": "曲线1"
},
{
"data": "2",
"desc": "曲线2"
},
{
"data": "3",
"desc": "曲线3"
},
{
"data": "4",
"desc": "曲线4"
},
{
"data": "5",
"desc": "曲线5"
},
{
"data": "6",
"desc": "曲线6"
},
{
"data": "7",
"desc": "曲线7"
},
{
"data": "8",
"desc": "曲线8"
},
{
"data": "9",
"desc": "曲线9"
},
{
"data": "11",
"desc": "曲线-1"
},
{
"data": "12",
"desc": "曲线-2"
},
{
"data": "13",
"desc": "曲线-3"
},
{
"data": "14",
"desc": "曲线-4"
},
{
"data": "15",
"desc": "曲线-5"
},
{
"data": "16",
"desc": "曲线-6"
},
{
"data": "17",
"desc": "曲线-7"
},
{
"data": "18",
"desc": "曲线-8"
},
{
"data": "19",
"desc": "曲线-9"
}
],
"type": "LIST"
},
"writable": false
},
{
"desc": "累计用气量",
"invisible": false,
"name": "totalUseGasL",
"readable": true,
"value": "16693",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "4294967295",
"minValue": "0",
"step": "1"
},
"type": "STEP"
},
"writable": false
},
{
"desc": "进水温度",
"invisible": false,
"name": "inWaterTemp",
"readable": true,
"value": "18.0",
"valueRange": {
"dataStep": {
"dataType": "Double",
"maxValue": "100.0",
"minValue": "0.0",
"step": "0.5"
},
"type": "STEP"
},
"writable": false
},
{
"defaultValue": "32",
"desc": "浴缸目标温度",
"invisible": false,
"name": "tankTargetTemp",
"operationType": "IG",
"readable": true,
"value": "42",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "60",
"minValue": "32",
"step": "1"
},
"type": "STEP"
},
"writable": true
},
{
"defaultValue": "00:00",
"desc": "定时循环开始时间",
"invisible": false,
"name": "timingCycleStartTime",
"operationType": "G",
"readable": true,
"value": "00:00",
"valueRange": {
"dataTime": {
"format": "HH:mm",
"maxHour": 23,
"maxMinute": 59,
"maxSecond": 0,
"minHour": 0,
"minMinute": 0,
"minSecond": 0
},
"type": "TIME"
},
"writable": true
},
{
"desc": "50度超温提醒",
"invisible": false,
"name": "highTempRemindStatus",
"readable": true,
"value": "true",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "设定温度>50℃"
},
{
"data": "false",
"desc": "设定温度≤50℃"
}
],
"type": "LIST"
},
"writable": false
},
{
"defaultValue": "00:00",
"desc": "定时循环结束时间",
"invisible": false,
"name": "timingCycleEndTime",
"operationType": "G",
"readable": true,
"value": "00:00",
"valueRange": {
"dataTime": {
"format": "HH:mm",
"maxHour": 23,
"maxMinute": 59,
"maxSecond": 0,
"minHour": 0,
"minMinute": 0,
"minSecond": 0
},
"type": "TIME"
},
"writable": true
},
{
"defaultValue": "0",
"desc": "循环功能选择",
"invisible": false,
"name": "cycFuncSelect",
"readable": true,
"value": "0",
"valueRange": {
"dataList": [
{
"data": "0",
"desc": "使用定时循环"
},
{
"data": "1",
"desc": "使用预约循环"
}
],
"type": "LIST"
},
"writable": false
},
{
"desc": "设备的全管循环时长",
"invisible": false,
"name": "equAllPipeTimeSet",
"readable": true,
"value": "379",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "1800",
"minValue": "0",
"step": "1"
},
"type": "STEP"
},
"writable": false
},
{
"desc": "火焰有无",
"invisible": false,
"name": "flameStatus",
"readable": true,
"value": "false",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "有"
},
{
"data": "false",
"desc": "无"
}
],
"type": "LIST"
},
"writable": false
},
{
"desc": "曲线下载成功标识(掉电记忆)",
"invisible": false,
"name": "curveDownloadSuccess",
"readable": true,
"value": "false",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "本机已下载成功"
},
{
"data": "false",
"desc": "本机未下载或下载失败"
}
],
"type": "LIST"
},
"writable": false
},
{
"desc": "安全自检状态",
"invisible": false,
"name": "safeSelfTestStatus",
"operationType": "I",
"readable": true,
"value": "false",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "处于自检状态"
},
{
"data": "false",
"desc": "未在自检状态"
}
],
"type": "LIST"
},
"writable": true
},
{
"defaultValue": "0",
"desc": "智能增压模式",
"invisible": false,
"name": "pressurizeMode",
"operationType": "IG",
"readable": true,
"value": "2",
"valueRange": {
"dataList": [
{
"data": "0",
"desc": "关闭"
},
{
"data": "2",
"desc": "智能增压"
}
],
"type": "LIST"
},
"writable": true
},
{
"desc": "查询所有报警",
"invisible": true,
"name": "getAllAlarm",
"operationType": "I",
"readable": true,
"valueRange": {
"dataList": [
{
"data": "getAllAlarm"
}
],
"type": "LIST"
},
"writable": true
},
{
"defaultValue": "50",
"desc": "浴缸注水量",
"invisible": false,
"name": "tankTargetFlux",
"operationType": "IG",
"readable": true,
"value": "50",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "310",
"minValue": "50",
"step": "10"
},
"type": "STEP"
},
"writable": true
},
{
"defaultValue": "0",
"desc": "设定曲线ID",
"invisible": false,
"name": "targetCurveID",
"operationType": "G",
"readable": true,
"value": "0",
"valueRange": {
"dataList": [
{
"data": "0",
"desc": "曲线0"
},
{
"data": "1",
"desc": "曲线1"
},
{
"data": "2",
"desc": "曲线2"
},
{
"data": "3",
"desc": "曲线3"
},
{
"data": "4",
"desc": "曲线4"
},
{
"data": "12",
"desc": "曲线-2"
},
{
"data": "13",
"desc": "曲线-3"
},
{
"data": "14",
"desc": "曲线-4"
}
],
"type": "LIST"
},
"writable": true
},
{
"desc": "自动半管循环时长设置值",
"invisible": false,
"name": "halfPipeLearningTime",
"operationType": "I",
"readable": true,
"value": "220",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "1800",
"minValue": "0",
"step": "1"
},
"type": "STEP"
},
"writable": true
},
{
"desc": "智慧节能实时燃烧功率百分比",
"invisible": false,
"name": "realTimePowerPct",
"readable": true,
"value": "0",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "99",
"minValue": "0",
"step": "1"
},
"type": "STEP"
},
"writable": false
},
{
"defaultValue": "2000",
"desc": "日期年",
"invisible": false,
"name": "dateYY",
"operationType": "G",
"readable": true,
"value": "2025",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "2099",
"minValue": "2000",
"step": "1"
},
"type": "STEP"
},
"writable": true
},
{
"defaultValue": "1",
"desc": "日期月",
"invisible": false,
"name": "dateMM",
"operationType": "G",
"readable": true,
"value": "1",
"valueRange": {
"dataStep": {
"dataType": "Integer",
"maxValue": "12",
"minValue": "1",
"step": "1"
},
"type": "STEP"
},
"writable": true
},
{
"desc": "单次循环首次完成提醒",
"invisible": false,
"name": "singleCycleFinish",
"readable": true,
"value": "false",
"valueRange": {
"dataList": [
{
"data": "true",
"desc": "完成"
},
{
"data": "false",
"desc": "未完成"
}
],
"type": "LIST"
},
"writable": false
}
]
}
}

错误日志

Entity sensor.5408535fce63_totalusegasl (<class 'custom_components.haier.sensor.HaierSensor'>) is using native unit of measurement 'L' which is not a valid unit for the device class ('gas') it is using; expected one of ['CCF', 'm³', 'ft³']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/banto6/haier/issues

@banto6
Copy link
Owner

banto6 commented Mar 11, 2025

目前设备正确的用气量是多少m³?

@Arnie97
Copy link

Arnie97 commented Mar 24, 2025

我理解海尔接口返回的单位就是升 L,但是 Home Assistant 倾向于用立方米 m³,需要单位换算

@banto6
Copy link
Owner

banto6 commented Mar 26, 2025

我理解海尔接口返回的单位就是升 L,但是 Home Assistant 倾向于用立方米 m³,需要单位换算

如果是这样的话就比较麻烦了,得看看其他用气设备的单位是不是也是L,如果都是L的话就可以统一改了

@Arnie97
Copy link

Arnie97 commented Mar 26, 2025

海尔前端这代码也很幽默了。看似后端水、气接口里都返回了 unit == "L",实际上前端并没判断这返回值是什么,直接除以 1000 展示成了立方米 m³。后端命名是 firewaterheater,前端命名是拼音 ranre,然后前端还留了一大坨内容随心所欲的 console.log 甚至 mock 的各种测试用例在线上生产代码里。幸好我只是路人甲,不用和他一起维护这坨,不然强迫症得疯
JavaScript 代码
页面截图
用气量接口
用水量接口

@Arnie97
Copy link

Arnie97 commented Mar 26, 2025

看了现在 _guess_state_class_device_class_and_unit 的代码,我觉得实现方式挺优雅的,不用修,不如推 Home Assistant 上游把 L 这个单位放进白名单里。既然现在同时允许「CCF 百立方英尺」和「ft³ 立方英尺」这俩单位,没道理不同时兼容公制单位升和立方米

@Arnie97 Arnie97 linked a pull request Mar 26, 2025 that will close this issue
19 tasks
@banto6
Copy link
Owner

banto6 commented Mar 27, 2025

看了现在 _guess_state_class_device_class_and_unit 的代码,我觉得实现方式挺优雅的,不用修,不如推 Home Assistant 上游把 L 这个单位放进白名单里。既然现在同时允许「CCF 百立方英尺」和「ft³ 立方英尺」这俩单位,没道理不同时兼容公制单位升和立方米

使用_guess_state_class_device_class_and_unit也是无奈之举,在你的截图里能看到返回了单位是L,但是在海尔的设备配置文件里根本就没有定义单位,所有的单位都得靠自己去猜测,真不知道他们自己是怎么用的

@Juddd
Copy link
Author

Juddd commented Mar 28, 2025

目前设备正确的用气量是多少m³?

我用开发者工具中的模板查到:

{% set entity_id = 'sensor.5408535fce63_totalusegasl' %}
原始数值: {{ states(entity_id) }}
单位: {{ state_attr(entity_id, 'unit_of_measurement') }}

返回值为36532L,但我海尔之家里显示是36.532m^3,也就是说,值是对的,只是单位不太对,如果你们不愿意修改,请问我是不是要去修改一下home assistant的config/configuration.yaml?

@banto6
Copy link
Owner

banto6 commented Mar 28, 2025

目前设备正确的用气量是多少m³?

我用开发者工具中的模板查到:

{% set entity_id = 'sensor.5408535fce63_totalusegasl' %}
原始数值: {{ states(entity_id) }}
单位: {{ state_attr(entity_id, 'unit_of_measurement') }}

返回值为36532L,但我海尔之家里显示是36.532m^3,也就是说,值是对的,只是单位不太对,如果你们不愿意修改,请问我是不是要去修改一下home assistant的config/configuration.yaml?

先等待上游PR情况

@Arnie97
Copy link

Arnie97 commented Mar 31, 2025

建议您后续方便的时候更新下 manifest.json,并给 master 分支打个 tag v1.1.3

上游 code reviewer 提醒我,我没有给能源面板补充新单位的支持。我为了构造测试环境,就在尝试把热水器加到能源面板上。看代码得知去年 #189 + #191 中已经正确支持了,但从 HA 打日志发现 SensorStateClass 仍是空,能源面板选不到。经过一番 debug,发现 HACS 安装是选取最新的 tag v1.1.2,近几个月 master 没打 tag 的代码视为没发布 😂 手动用 Git 拉了 master 代码后,成功加到能源面板了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants