[
{
"id": "8098bb5720f117e3",
"type": "ha-sensor",
"z": "de66179675455cb6",
"name": "最新油价",
"entityConfig": "97bd4f8f.bee1f",
"version": 0,
"state": "state",
"stateType": "msg",
"attributes": [
{
"property": "'92#汽油'",
"value": "price[1]",
"valueType": "msg"
},
{
"property": "95#汽油",
"value": "price[3]",
"valueType": "msg"
},
{
"property": "98#汽油",
"value": "price[5]",
"valueType": "msg"
},
{
"property": "0#柴油",
"value": "price[7]",
"valueType": "msg"
},
{
"property": "Tips",
"value": "tips",
"valueType": "msg"
}
],
"inputOverride": "allow",
"outputProperties": [],
"x": 755,
"y": 360,
"wires": [
[]
],
"l": false
},
{
"id": "3b688f94218a4435",
"type": "http request",
"z": "de66179675455cb6",
"name": "",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://www.qiyoujiage.com/sichuan",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 320,
"y": 280,
"wires": [
[
"334c4d17e420103e"
]
]
},
{
"id": "5bbe2854613b3376",
"type": "inject",
"z": "de66179675455cb6",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "20 00 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 160,
"y": 280,
"wires": [
[
"3b688f94218a4435"
]
]
},
{
"id": "334c4d17e420103e",
"type": "html",
"z": "de66179675455cb6",
"name": "提取",
"property": "payload",
"outproperty": "payload",
"tag": "#youjiaCont> div",
"ret": "text",
"as": "single",
"x": 490,
"y": 280,
"wires": [
[
"833235cd88485027"
]
]
},
{
"id": "833235cd88485027",
"type": "function",
"z": "de66179675455cb6",
"name": "",
"func": "var OilPrice = msg.payload[0].split('\\n');\n// 去除数组中的空元素\nvar filteredArray = OilPrice.filter(function (element) {\n return element !== '';\n});\n\nvar StateTips = msg.payload[1].split('\\n');\nvar endIndex = StateTips[2].indexOf('。');\nvar TipsTips = StateTips[2].substring(0, endIndex + 1);\n\nvar newmsg = {};\nnewmsg.price = filteredArray;\nnewmsg.state = StateTips[1];\nnewmsg.tips = TipsTips;\nflow.set('newmsg', newmsg); //将access_token储存\nreturn newmsg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 630,
"y": 280,
"wires": [
[
"8098bb5720f117e3",
"8e4671326328e5f9",
"626a76e2505b39c8"
]
]
},
{
"id": "8e4671326328e5f9",
"type": "ha-sensor",
"z": "de66179675455cb6",
"name": "92#汽油油价",
"entityConfig": "3e6cb13c5ba04c83",
"version": 0,
"state": "price[1]",
"stateType": "msg",
"attributes": [
{
"property": "92#汽油",
"value": "price[1]",
"valueType": "msg"
},
{
"property": "95#汽油",
"value": "price[3]",
"valueType": "msg"
},
{
"property": "98#汽油",
"value": "price[5]",
"valueType": "msg"
},
{
"property": "0#柴油",
"value": "price[7]",
"valueType": "msg"
},
{
"property": "Tips",
"value": "tips",
"valueType": "msg"
},
{
"property": "tiaozhendate",
"value": "state",
"valueType": "msg"
}
],
"inputOverride": "allow",
"outputProperties": [],
"x": 755,
"y": 200,
"wires": [
[]
],
"l": false
},
{
"id": "c521c69735aa60c6",
"type": "http request",
"z": "de66179675455cb6",
"name": "微信推送",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://api.anpush.com/push/you_anpush_api", //you_anpush_api换成你自己的api,每天免费30次推送,够用了_
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "Content-Type",
"keyValue": "",
"valueType": "other",
"valueValue": "application/x-www-form-urlencoded"
}
],
"x": 1680,
"y": 280,
"wires": [
[]
]
},
{
"id": "70b08a1de0c3bf37",
"type": "function",
"z": "de66179675455cb6",
"name": "日期相同推送调价信息到微信AnPush",
"func": "// @ts-nocheck\nmsg.payload={\n title: "今日油价",\n content: flow.get("newmsg").price + ';'+flow.get("newmsg").state+ ';' + flow.get("newmsg").tips,\n channel: 'your_anpush_channel',\n}\nreturn msg;",//your_anpush_channel换成你在anpush的信息通道代码
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1430,
"y": 280,
"wires": [
[
"c521c69735aa60c6"
]
]
},
{
"id": "626a76e2505b39c8",
"type": "function",
"z": "de66179675455cb6",
"name": "对比当前日期和调价前一天日期",
"func": "var n1 = flow.get("newmsg").state.indexOf('价');//获取“价”所在位置\nvar n2 = flow.get('newmsg').state.indexOf('月');\nvar n3 = flow.get('newmsg').state.indexOf('日');\n\n//获取月\nvar str1 = flow.get('newmsg').state.substring(n1+1,n2);\n//将月份调整为两位数,1位数的十位补0\nif (str1.length === 1) {\n // 处理条件1的情况\n str1 = '0'+str1;\n} //else if (input === 'condition2') {\n // 处理条件2的情况\n// msg.payload = 'Condition 2 is true';\n//}\n else {\n // 处理其他情况\n str1;\n}\n\n//获取日\nvar str2 = flow.get('newmsg').state.substring(n2 + 1, n3)-1;\n//将月份调整为两位数,1位数的十位补0\nif (str2.length === 1) {\n // 处理条件1的情况\n str2 = '0' + str2;\n} //else if (input === 'condition2') {\n// 处理条件2的情况\n// msg.payload = 'Condition 2 is true';\n//}\nelse {\n // 处理其他情况\n str2;\n}\n\n//整合油价调整日期\nvar tiaozhendate =str1+'月'+str2+'日';\n\n// 获取当前日期和时间\nvar currentDate = new Date();\n//var currentDateString = currentDate.toISOString().slice(0,10);\n\n// 将当前日期发送到下一个节点\nvar currentDate = new Date();\n\n// 将日期格式转换为所需格式(例如:YYYY-MM-DD)\nvar formattedDate = ('0' + (currentDate.getMonth() + 1)).slice(-2) + '月' + ('0' + currentDate.getDate()).slice(-2)+'日';\n\n// 对比两个日期是否相同\nif (tiaozhendate === formattedDate){\n msg.payload = 'on';\n}else{\n msg.payload = 'off';\n}\n\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 890,
"y": 280,
"wires": [
[
"ed92894a6d3e5520"
]
]
},
{
"id": "ed92894a6d3e5520",
"type": "switch",
"z": "de66179675455cb6",
"name": "判断两个日期是否相同",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "on",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 1140,
"y": 280,
"wires": [
[
"70b08a1de0c3bf37"
]
]
},
{
"id": "97bd4f8f.bee1f",
"type": "ha-entity-config",
"server": "8ee52cc75649ea4c",
"deviceConfig": "52396cf973e98382",
"name": "最新油价",
"version": "6",
"entityType": "sensor",
"haConfig": [
{
"property": "name",
"value": "最新油价"
},
{
"property": "icon",
"value": "mdi:gas-station"
},
{
"property": "entity_picture",
"value": ""
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": ""
},
{
"property": "unit_of_measurement",
"value": ""
},
{
"property": "state_class",
"value": ""
}
],
"resend": true,
"debugEnabled": false
},
{
"id": "3e6cb13c5ba04c83",
"type": "ha-entity-config",
"server": "8ee52cc75649ea4c",
"deviceConfig": "b0765d0d7d439dae",
"name": "92#汽油油价",
"version": "6",
"entityType": "sensor",
"haConfig": [
{
"property": "name",
"value": "92#汽油油价"
},
{
"property": "icon",
"value": "mdi:gas-station"
},
{
"property": "entity_picture",
"value": ""
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": ""
},
{
"property": "unit_of_measurement",
"value": ""
},
{
"property": "state_class",
"value": ""
}
],
"resend": false,
"debugEnabled": false
},
{
"id": "8ee52cc75649ea4c",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": ": ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "default",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": false
},
{
"id": "52396cf973e98382",
"type": "ha-device-config",
"name": "最新油价",
"hwVersion": "",
"manufacturer": "Node-RED",
"model": "",
"swVersion": ""
},
{
"id": "b0765d0d7d439dae",
"type": "ha-device-config",
"name": "92#汽油油价",
"hwVersion": "",
"manufacturer": "Node-RED",
"model": "",
"swVersion": ""
}
]