[{"id":"354b77ea224b34fa","type":"http request","z":"a0d142e5f5ffdc44","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://www.qiyoujiage.com/guizhou/qianxinan.shtml","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":340,"y":340,"wires":[["0b50352509aaa71b"]]},{"id":"f8c53c2c58c2de41","type":"inject","z":"a0d142e5f5ffdc44","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"43200","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":320,"wires":[["354b77ea224b34fa"]]},{"id":"9cb2b5a6707ef8a6","type":"mqtt in","z":"a0d142e5f5ffdc44","name":"主动刷新","topic":"youjia/contrl/shuaxin","qos":"0","datatype":"utf8","broker":"7cb95522e79640f4","nl":false,"rap":true,"rh":0,"inputs":0,"x":140,"y":360,"wires":[["354b77ea224b34fa"]]},{"id":"0b50352509aaa71b","type":"html","z":"a0d142e5f5ffdc44","name":"提取","property":"payload","outproperty":"payload","tag":"#youjiaCont> div","ret":"text","as":"single","chr":"","x":490,"y":340,"wires":[["d4c09bce0a44c7fb"]]},{"id":"d4c09bce0a44c7fb","type":"function","z":"a0d142e5f5ffdc44","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');\n//var endIndex = StateTips[2].indexOf('。');\nvar TipsTips = StateTips[2].substring(0, 500);\n\nvar newmsg = {};\nnewmsg.price = filteredArray;\nnewmsg.state = StateTips[1];\nnewmsg.tips = TipsTips;\nflow.set('newmsg', newmsg); //将access_token储存\n\nreturn newmsg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":340,"wires":[["ff63fe69898cd1ba"]]},{"id":"ff63fe69898cd1ba","type":"function","z":"a0d142e5f5ffdc44","name":"整合mqtt流","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//获取日\nvar str2 = flow.get('newmsg').state.substring(n2 + 1, n3);\n\n//整合油价调整日期\nvar tiaozhendate =str1+'月'+str2+'日';\n\nmsg.payload = {\n "汽油92": flow.get("newmsg").price[1],\n "汽油95": flow.get("newmsg").price[3],\n "汽油98": flow.get("newmsg").price[5],\n "柴油0": flow.get("newmsg").price[7],\n "下一轮调价日期": tiaozhendate,\n "调整情况": flow.get("newmsg").tips\n}\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":340,"wires":[["ae6a162efd208da1"]]},{"id":"ae6a162efd208da1","type":"mqtt out","z":"a0d142e5f5ffdc44","name":"最新油价","topic":"youjia/zuixinyoujia","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"7cb95522e79640f4","x":1100,"y":340,"wires":[]},{"id":"626a76e2505b39c8","type":"function","z":"a0d142e5f5ffdc44","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":390,"y":420,"wires":[["ed92894a6d3e5520"]]},{"id":"84876af9798c96c7","type":"inject","z":"a0d142e5f5ffdc44","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 01 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":420,"wires":[["626a76e2505b39c8"]]},{"id":"ed92894a6d3e5520","type":"switch","z":"a0d142e5f5ffdc44","name":"判断两个日期是否相同","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":660,"y":420,"wires":[["70b08a1de0c3bf37"]]},{"id":"70b08a1de0c3bf37","type":"function","z":"a0d142e5f5ffdc44","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: '30019',\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":950,"y":420,"wires":[["c521c69735aa60c6"]]},{"id":"c521c69735aa60c6","type":"http request","z":"a0d142e5f5ffdc44","name":"微信推送","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://api.anpush.com/push/{your_token}","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"other","valueValue":"application/x-www-form-urlencoded"}],"x":1180,"y":420,"wires":[[]]},{"id":"7cb95522e79640f4","type":"mqtt-broker","name":"ha上的mqtt","broker":"192.168.31.8","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]