[
{
"id": "910e49601765fe85",
"type": "function",
"z": "d5fc7a0af200ba50",
"name": "获取电动车基本信息",
"func": "// 构建请求的配置对象\nmsg = {\n // URL(含路径)\n url: "https://lism.lixcx.com:32026/smartBike/consumer/deviceIndex/v2/deviceList",\n // 请求方法:GET\n method: "GET",\n // URL 参数(会自动拼接到 URL 后)\n params: {\n deviceCode: "W3R1WTHD0C8"\n },\n // 请求头信息\n headers: {\n "Content-Type": "application/json;charset=UTF-8",\n "source": "app-smartbike",\n "Authorization": flow.get("电动车保存参数.token.token"),\n "Host": "lism.lixcx.com:32026",\n "Connection": "Keep-Alive",\n "Accept-Encoding": "gzip",\n "User-Agent": "okhttp/3.12.0"\n }\n};\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 980,
"y": 580,
"wires": [
[
"50f7fcee91f2f3d5"
]
]
},
{
"id": "33236a8d0e2466d8",
"type": "http request",
"z": "d5fc7a0af200ba50",
"name": "",
"method": "use",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": true,
"proxy": "",
"insecureHTTPParser": true,
"authType": "",
"senderr": true,
"headers": [],
"x": 1180,
"y": 480,
"wires": [
[
"e892ed2cf48fdcb8"
]
]
},
{
"id": "2bf723aa70ed1af8",
"type": "function",
"z": "d5fc7a0af200ba50",
"name": "账号登陆",
"func": "//加密后的账号密码字符串\nlet pwd ="在此填入加密后的账号密码字符串" \nconst headers = {\n "source": "app-smartbike",\n "Content-Type": "application/json;charset=UTF-8",\n "Host": "lism.lixcx.com:32026",\n "Connection": "Keep-Alive",\n "Accept-Encoding": "gzip",\n "User-Agent": "okhttp/3.12.0"\n};\n\n// 构造请求体(JSON 格式)\nconst payload = {\n "bioIdentification": "0",\n "key": pwd\n};\n\n// 设置消息对象(供 http request 节点使用)\nmsg.url = "https://lism.lixcx.com:32026/UserCenter/auth/account/login/password";\nmsg.method = "POST";\nmsg.headers = headers;\nmsg.payload = payload;\n\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1000,
"y": 480,
"wires": [
[
"33236a8d0e2466d8"
]
]
},
{
"id": "e892ed2cf48fdcb8",
"type": "change",
"z": "d5fc7a0af200ba50",
"name": "",
"rules": [
{
"t": "set",
"p": "电动车保存参数.token",
"pt": "flow",
"to": "payload.obj",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1420,
"y": 480,
"wires": [
[]
]
},
{
"id": "50f7fcee91f2f3d5",
"type": "http request",
"z": "d5fc7a0af200ba50",
"name": "",
"method": "use",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://lism.lixcx.com:32026/smartBike/consumer/deviceIndex/v2/deviceList",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 1180,
"y": 580,
"wires": [
[
"edb55047c750087f"
]
]
},
{
"id": "edb55047c750087f",
"type": "change",
"z": "d5fc7a0af200ba50",
"name": "",
"rules": [
{
"t": "set",
"p": "电动车保存参数.bike",
"pt": "flow",
"to": "payload.obj",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1410,
"y": 580,
"wires": [
[]
]
},
{
"id": "415fcf7f3c0e0489",
"type": "function",
"z": "d5fc7a0af200ba50",
"name": "获取电动车基本信息",
"func": "// 构建请求的配置对象\nmsg = {\n // URL(含路径)\n url: `https://lism.lixcx.com:32026/smartBike/consumer/deviceIndex/deviceInfo?bindingId=${flow.get("电动车保存参数.bike.bike[0].id")}&deviceType=${flow.get("电动车保存参数.bike.bike[0].deviceType")}&templateId=${flow.get("电动车保存参数.bike.bike[0].templateId")}&type=${flow.get("电动车保存参数.bike.bike[0].type")}&version=v2`,\n // 请求方法:GET\n method: "GET",\n // URL 参数(会自动拼接到 URL 后)\n params: {\n deviceCode: "W3R1WTHD0C8"\n },\n // 请求头信息\n headers: {\n "Content-Type": "application/json;charset=UTF-8",\n "source": "app-smartbike",\n "Authorization": flow.get("电动车保存参数.token.token"),\n "Host": "lism.lixcx.com:32026",\n "Connection": "Keep-Alive",\n "Accept-Encoding": "gzip",\n "User-Agent": "okhttp/3.12.0"\n }\n};\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 980,
"y": 660,
"wires": [
[
"cd8097f3a5bfa970"
]
]
},
{
"id": "cd8097f3a5bfa970",
"type": "http request",
"z": "d5fc7a0af200ba50",
"name": "",
"method": "use",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 1180,
"y": 660,
"wires": [
[
"3e03b06ae3439d9c"
]
]
},
{
"id": "3e03b06ae3439d9c",
"type": "change",
"z": "d5fc7a0af200ba50",
"name": "",
"rules": [
{
"t": "set",
"p": "电动车保存参数.2",
"pt": "flow",
"to": "payload.obj.bike",
"tot": "msg",
"dc": true
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1400,
"y": 660,
"wires": [
[]
]
},
{
"id": "949b104e6ff9be59",
"type": "function",
"z": "d5fc7a0af200ba50",
"name": "获取历史骑行信息",
"func": "const todayStart = new Date(new Date().setHours(0, 0, 0, 0)).getTime();\nconst todayEnd = new Date(new Date().setHours(24, 0, 0, 0) - 1).getTime();\n// 获取前一天的日期对象\nconst yesterday = new Date();\nyesterday.setDate(yesterday.getDate() - 1);\nconst yesterdayStart = new Date(yesterday);\nyesterdayStart.setHours(0, 0, 0, 0);\nconst yesterdayStartTimestamp = yesterdayStart.getTime();\n// 构建请求的配置对象\nmsg = {\n // URL(含路径)\n url: `https://lism.lixcx.com:32026/smartBike/consumer/travel/getHistoricalTrack?bikeId=577937&startDate=${todayStart}&endDate=${todayEnd}&pageNo=0&pageSize=1`,\n \n // 请求方法:GET\n method: "GET",\n // URL 参数(会自动拼接到 URL 后)\n // 请求头信息\n headers: {\n "Content-Type": "application/json;charset=UTF-8",\n "source": "app-smartbike",\n "Authorization": flow.get("电动车保存参数.token.token"),\n "Host": "lism.lixcx.com:32026",\n "Connection": "Keep-Alive",\n "Accept-Encoding": "gzip",\n "User-Agent": "okhttp/3.12.0"\n }\n};\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 970,
"y": 740,
"wires": [
[
"570ca6888b29ed18"
]
]
},
{
"id": "570ca6888b29ed18",
"type": "http request",
"z": "d5fc7a0af200ba50",
"name": "",
"method": "use",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 1160,
"y": 740,
"wires": [
[
"889389db9b0c4b12"
]
]
},
{
"id": "889389db9b0c4b12",
"type": "change",
"z": "d5fc7a0af200ba50",
"name": "",
"rules": [
{
"t": "set",
"p": "电动车保存参数3",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1400,
"y": 740,
"wires": [
[]
]
},
{
"id": "881871cf4252b4c9",
"type": "function",
"z": "d5fc7a0af200ba50",
"name": "获取GPS定位信息",
"func": "// 构建请求的配置对象\nmsg = {\n // URL(含路径)\n url: `https://lism.lixcx.com:32026/smartBike/consumer/deviceIndex/getLocationInfo?templateCode=${flow.get("电动车保存参数.bike.bike[0].templateCode")}&boxCode=${flow.get("电动车保存参数.bike.bike[0].boxCode")}`,\n // 请求方法:GET\n method: "GET",\n // URL 参数(会自动拼接到 URL 后)\n \n // 请求头信息\n headers: {\n "Content-Type": "application/json;charset=UTF-8",\n "source": "app-smartbike",\n "Authorization": flow.get("电动车保存参数.token.token"),\n "Host": "lism.lixcx.com:32026",\n "Connection": "Keep-Alive",\n "Accept-Encoding": "gzip",\n "User-Agent": "okhttp/3.12.0"\n }\n};\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 970,
"y": 840,
"wires": [
[
"33c81c1286ed1b2b"
]
]
},
{
"id": "33c81c1286ed1b2b",
"type": "http request",
"z": "d5fc7a0af200ba50",
"name": "",
"method": "use",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 1180,
"y": 840,
"wires": [
[
"42fda26999f467dd"
]
]
},
{
"id": "42fda26999f467dd",
"type": "change",
"z": "d5fc7a0af200ba50",
"name": "",
"rules": [
{
"t": "set",
"p": "电动车保存参数4",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1400,
"y": 840,
"wires": [
[
"9561c7ac40cfed7c"
]
]
},
{
"id": "f028c385e8f0d8be",
"type": "function",
"z": "d5fc7a0af200ba50",
"name": "获取报警信息",
"func": "// 构建请求的配置对象\nmsg = {\n // URL(含路径)\n url: `https://lism.lixcx.com:32026/smartBike/consumer/faultAlarm/myFaultAlarmList?bikeBaseId=${flow.get("电动车保存参数.bike.bike[0].deviceId")}&pageNo=0&pageSize=10`,\n // 请求方法:GET\n method: "GET",\n // URL 参数(会自动拼接到 URL 后)\n \n // 请求头信息\n headers: {\n "Content-Type": "application/json;charset=UTF-8",\n "source": "app-smartbike",\n "Authorization": flow.get("电动车保存参数.token.token"),\n "Host": "lism.lixcx.com:32026",\n "Connection": "Keep-Alive",\n "Accept-Encoding": "gzip",\n "User-Agent": "okhttp/3.12.0"\n }\n};\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 940,
"y": 920,
"wires": [
[
"6faf44d8cbe575a0"
]
]
},
{
"id": "a5a052c0195028fa",
"type": "inject",
"z": "d5fc7a0af200ba50",
"name": "2",
"props": [],
"repeat": "15",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"x": 490,
"y": 600,
"wires": [
[
"e86fcf8397750828"
]
]
},
{
"id": "6faf44d8cbe575a0",
"type": "http request",
"z": "d5fc7a0af200ba50",
"name": "",
"method": "use",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 1160,
"y": 920,
"wires": [
[
"134f5a0c0cdcbd4a"
]
]
},
{
"id": "134f5a0c0cdcbd4a",
"type": "change",
"z": "d5fc7a0af200ba50",
"name": "",
"rules": [
{
"t": "set",
"p": "电动车保存参数5",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1380,
"y": 920,
"wires": [
[
"2f4f02adea61f7ab",
"7dc4f317d7b9f566"
]
]
},
{
"id": "3851aaaf14fa5432",
"type": "ha-button",
"z": "d5fc7a0af200ba50",
"name": "",
"version": 0,
"debugenabled": false,
"outputs": 1,
"entityConfig": "6db902a159e407bd",
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "triggerId"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"x": 770,
"y": 480,
"wires": [
[
"2bf723aa70ed1af8",
"36c8aab541e68baa"
]
]
},
{
"id": "36c8aab541e68baa",
"type": "delay",
"z": "d5fc7a0af200ba50",
"name": "",
"pauseType": "delay",
"timeout": "2",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 800,
"y": 540,
"wires": [
[
"910e49601765fe85",
"e6109909f8faf3e7"
]
]
},
{
"id": "e6109909f8faf3e7",
"type": "delay",
"z": "d5fc7a0af200ba50",
"name": "",
"pauseType": "delay",
"timeout": "2",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 920,
"y": 620,
"wires": [
[
"415fcf7f3c0e0489",
"7c78b8d9e55ed699"
]
]
},
{
"id": "7c78b8d9e55ed699",
"type": "delay",
"z": "d5fc7a0af200ba50",
"name": "",
"pauseType": "delay",
"timeout": "2",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 920,
"y": 700,
"wires": [
[
"949b104e6ff9be59",
"bbb71e049d0b76e8"
]
]
},
{
"id": "bbb71e049d0b76e8",
"type": "delay",
"z": "d5fc7a0af200ba50",
"name": "",
"pauseType": "delay",
"timeout": "2",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 920,
"y": 780,
"wires": [
[
"881871cf4252b4c9",
"6fe65fd399fccae9"
]
]
},
{
"id": "6fe65fd399fccae9",
"type": "delay",
"z": "d5fc7a0af200ba50",
"name": "",
"pauseType": "delay",
"timeout": "2",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 920,
"y": 880,
"wires": [
[
"f028c385e8f0d8be"
]
]
},
{
"id": "9561c7ac40cfed7c",
"type": "function",
"z": "d5fc7a0af200ba50",
"name": "GPS设备数据处理",
"func": "//if(!flow.get("电动车保存参数4.obj.reportTime")){\nconst headers = {\n "Content-Type": "application/x-www-form-urlencoded"\n};\nlet aa = flow.get("电动车保存参数4");\nlet bb =aa.obj.location.split(/,/)\n// 构造请求体(JSON 格式)\nconst payload = {\n "latitude":bb[1]-0.00063,\n "longitude":bb[0]-0.00363 ,\n "device": flow.get("电动车保存参数.2.typeName") ,\n "accuracy": aa.obj.precision ,\n "battery": flow.get("电动车保存参数.2.batterySoc[0]"),\n "speed":flow.get("电动车保存参数.2.reportTime"),\n "altitude":flow.get("电动车保存参数.2.voltage")\n};\n\n// 设置消息对象(供 http request 节点使用)\nmsg.url = "在此填入GPSLoggerapi";\nmsg.method = "POST";\nmsg.headers = headers;\nmsg.payload = payload;\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1650,
"y": 840,
"wires": [
[
"b470cd6dfc67533d"
]
]
},
{
"id": "b470cd6dfc67533d",
"type": "http request",
"z": "d5fc7a0af200ba50",
"name": "",
"method": "use",
"ret": "txt",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 1840,
"y": 840,
"wires": [
[]
]
},
{
"id": "7dc4f317d7b9f566",
"type": "function",
"z": "d5fc7a0af200ba50",
"name": "function 89",
"func": "if (flow.get("电动车保存参数3.obj.data").length !== 0){\n // 1. 从上下文获取上一次的输入值(初始值设为false/0)\n let prevValue = flow.get("prevValue") || false; \n // 2. 获取当前输入值(根据实际输入调整,如msg.payload)\n let currentValue = flow.get("电动车保存参数.2.accState"); \n \n // 3. 对比判断:上升沿(前低后高)\n if (!prevValue && currentValue) {\n flow.set("骑行状态", "行驶中"); // 可自定义输出内容(如true、1等)\n // 触发时输出消息\n }\n \n // 4. 对比判断:下降沿(前高后低)\n if (prevValue && !currentValue) {\n var xjy = 1\n flow.set("骑行状态", "行驶结束");\n // return msg;\n }\n \n // 5. 更新上下文,存储当前值为下一次的“前值”\nflow.set("prevValue", currentValue);\n// 非沿变化时不输出消息(如需默认输出可取消注释下方)\n// return null;\n \nlet ss =flow.get("电动车保存参数.2.travelTime");\nlet gg = 0\nss = (ss / 1000 / 60).toFixed(3)\nflow.set("电动车保存参数.qxtime", ss ||0); //时间\n let kk = Number((flow.get("电动车保存参数3.obj.data[0].amapDistance") / 1000).toFixed(3)) //公里数\nss = ss/60\nflow.set("电动车保存参数.gls", kk ||0);\ngg= (flow.get("电动车保存参数.gls") /ss).toFixed(3) //评价时速\nflow.set("电动车保存参数.pjsd", gg);\nlet totalMileage =Number(flow.get("mileage.totalMileage")||0)\n\nlet mileage = Number(flow.get("电动车保存参数.gls"))\nif (xjy==1){\n flow.set("mileage.mileage", Number(kk)); \n totalMileage= totalMileage+mileage\n flow.set("mileage.bcxhgls", flow.get("mileage.bcxhgls")+mileage);\n flow.set("mileage.totalMileage", totalMileage.toFixed(3));\n}\nif (Number(flow.get("电动车保存参数.2.batterySoc[0]")) === 100 &&flow.get("mileage.bcxhgls")!==0){ \n flow.set("mileage.bcxhgls", 0);\n}\n}",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "// 部署节点后,此处添加的代码将运行一次。 \n flow.set("mileage.mileage", flow.get("电动车保存参数.gls"));",
"finalize": "",
"libs": [],
"x": 1690,
"y": 940,
"wires": [
[]
]
},
{
"id": "2f4f02adea61f7ab",
"type": "link out",
"z": "d5fc7a0af200ba50",
"name": "link out 7",
"mode": "link",
"links": [
"49b5810fce89cedf",
"017f55b4cf2f4a7a"
],
"x": 1585,
"y": 920,
"wires": []
},
{
"id": "3107c38d83ce69eb",
"type": "inject",
"z": "d5fc7a0af200ba50",
"name": "1",
"props": [],
"repeat": "60",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"x": 490,
"y": 540,
"wires": [
[
"fe6589719c0512ce"
]
]
},
{
"id": "fe6589719c0512ce",
"type": "switch",
"z": "d5fc7a0af200ba50",
"name": "",
"property": "电动车保存参数.2.accState",
"propertyType": "flow",
"rules": [
{
"t": "cont",
"v": "false",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 650,
"y": 540,
"wires": [
[
"36c8aab541e68baa"
]
]
},
{
"id": "e86fcf8397750828",
"type": "switch",
"z": "d5fc7a0af200ba50",
"name": "",
"property": "电动车保存参数.2.accState",
"propertyType": "flow",
"rules": [
{
"t": "cont",
"v": "true",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 670,
"y": 600,
"wires": [
[
"36c8aab541e68baa"
]
]
},
{
"id": "6db902a159e407bd",
"type": "ha-entity-config",
"server": "ba8d295cd9043319",
"deviceConfig": "d0d327350361c36c",
"name": "登录",
"version": "6",
"entityType": "button",
"haConfig": [
{
"property": "name",
"value": "登录"
},
{
"property": "icon",
"value": ""
},
{
"property": "entity_picture",
"value": ""
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": ""
}
],
"resend": false,
"debugEnabled": false
},
{
"id": "ba8d295cd9043319",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": false,
"rejectUnauthorizedCerts": false,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": true,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": ": ",
"statusYear": "numeric",
"statusMonth": "numeric",
"statusDay": "numeric",
"statusHourCycle": "h23",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": false
},
{
"id": "d0d327350361c36c",
"type": "ha-device-config",
"name": "电动车",
"hwVersion": "",
"manufacturer": "新日",
"model": "",
"swVersion": ""
}
]