【抓取阿特兹(my mazda App)汽车状态】通过node-red-contrib-bizwechat(企业微信推送)

新手首贴,大神忽略

如何使用node-red-contrib-bizwechat
请先看教程:基于企业微信的一对多消息送达服务-完美替代pushbear

需先注册my mazda 账号

第一步:通过fiddler(使用方法自行百度)抓取app请求接口参数:

第二步:编写node-red脚本(部分参数根据抓包结果修改):

[{"id":"f77e07dc.73b7c8","type":"tab","label":"抓取汽车状态信息","disabled":false,"info":""},{"id":"cc7df7e7.f930d8","type":"http request","z":"f77e07dc.73b7c8","name":"获取token","method":"POST","ret":"obj","paytoqs":false,"url":"https://mazda.palmgo.cn:8443/mazda-prod/mobile-api/oauth2/token","tls":"","proxy":"","authType":"","x":800,"y":200,"wires":[["523ed5de.c079cc","abe556cd.9eb478"]]},{"id":"714a20ec.3c919","type":"inject","z":"f77e07dc.73b7c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"7000","crontab":"","once":true,"onceDelay":0.1,"x":440,"y":200,"wires":[["9f7ea978.751d18"]]},{"id":"523ed5de.c079cc","type":"debug","z":"f77e07dc.73b7c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1030,"y":60,"wires":[]},{"id":"9f7ea978.751d18","type":"function","z":"f77e07dc.73b7c8","name":"设置请求头","func":"// 请求参数,取抓包https://mazda.palmgo.cn:8443/mazda-prod/mobile-api/oauth2/token 接口请求参数\nmsg.payload = \"\";\nmsg.headers = {};\nmsg.headers['Content-Type'] = 'application/json;charset=UTF-8';\nmsg.headers['Connection'] = 'keep-alive';\nmsg.headers['User-Agent'] = 'My%20Mazda/138 CFNetwork/1179.0.1 Darwin/20.0.0';\nmsg.headers['Accept-Language'] = 'zh-cn';\nmsg.headers['Accept-Encoding'] = 'gzip, deflate, br';\nreturn msg;","outputs":1,"noerr":0,"x":610,"y":200,"wires":[["cc7df7e7.f930d8"]]},{"id":"abe556cd.9eb478","type":"function","z":"f77e07dc.73b7c8","name":"保存token","func":"global.set('mzd_access_token', msg.payload.access_token)\nmsg.deldy = 7000;\nreturn msg;","outputs":1,"noerr":0,"x":1020,"y":200,"wires":[[]]},{"id":"7c367a91.df0804","type":"function","z":"f77e07dc.73b7c8","name":"设置请求头","func":"// 请求参数,取抓包https://mazda.palmgo.cn:8443/mazda-prod/mobile-api/accountMazda/login接口请求参数\nmsg.payload = \"\";\nmsg.headers = {};\nmsg.headers['Content-Type'] = 'application/json;charset=UTF-8';\nmsg.headers['Connection'] = 'keep-alive';\nmsg.headers['User-Agent'] = 'Mazda/1.0.3 (iPhone; iOS 14.0; Scale/2.00)';\nmsg.headers['Accept-Language'] = 'zh-cn';\nmsg.headers['Accept-Encoding'] = 'gzip, deflate, br';\nmsg.headers['Authorization'] = 'Bearer '+global.get(\"mzd_access_token\");\n\nreturn msg;","outputs":1,"noerr":0,"x":610,"y":380,"wires":[["2bacf1f9.d3bfae"]]},{"id":"2bacf1f9.d3bfae","type":"http request","z":"f77e07dc.73b7c8","name":"用户登录","method":"POST","ret":"obj","paytoqs":false,"url":"https://mazda.palmgo.cn:8443/mazda-prod/mobile-api/accountMazda/login","tls":"","proxy":"","authType":"","x":800,"y":380,"wires":[["545afc08.2c5e54","e4d5c336.630c8"]]},{"id":"545afc08.2c5e54","type":"function","z":"f77e07dc.73b7c8","name":"保存token","func":"global.set('mzd_token', msg.payload.data.token)\nreturn msg;","outputs":1,"noerr":0,"x":1020,"y":380,"wires":[["b48318f1.a5b838"]]},{"id":"e4d5c336.630c8","type":"debug","z":"f77e07dc.73b7c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1030,"y":300,"wires":[]},{"id":"b2e6178.36de0e8","type":"comment","z":"f77e07dc.73b7c8","name":"动态刷新access_token信息","info":"","x":490,"y":160,"wires":[]},{"id":"6c928107.6616f","type":"comment","z":"f77e07dc.73b7c8","name":"登录用户操作","info":"","x":410,"y":360,"wires":[]},{"id":"767e3c24.0f60e4","type":"comment","z":"f77e07dc.73b7c8","name":"获取汽车位置信息","info":"","x":470,"y":520,"wires":[]},{"id":"ba505f41.bf8db","type":"inject","z":"f77e07dc.73b7c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":430,"y":560,"wires":[["b48318f1.a5b838"]]},{"id":"b48318f1.a5b838","type":"function","z":"f77e07dc.73b7c8","name":"设置请求头","func":"// 请求参数,取抓包https://mazda.palmgo.cn:8443/mazda-prod/mobile-api/vehicleData/findMyCarStatus接口请求参数\nmsg.payload = \"\";\nmsg.headers = {};\nmsg.headers['Content-Type'] = 'application/json;charset=UTF-8';\nmsg.headers['Connection'] = 'keep-alive';\nmsg.headers['User-Agent'] = 'Mazda/1.0.3 (iPhone; iOS 14.0; Scale/2.00)';\nmsg.headers['Accept-Language'] = 'zh-cn';\nmsg.headers['Accept-Encoding'] = 'gzip, deflate, br';\nmsg.headers['Authorization'] = 'Bearer '+global.get(\"mzd_access_token\");\nmsg.headers['token'] = global.get(\"mzd_token\");\n// 手机号\nmsg.headers['identifier'] = 'xxxx';\n\nreturn msg;","outputs":1,"noerr":0,"x":610,"y":560,"wires":[["3d10ac68.4ac874"]]},{"id":"3d10ac68.4ac874","type":"http request","z":"f77e07dc.73b7c8","name":"获取车辆状态信息","method":"POST","ret":"obj","paytoqs":false,"url":"https://mazda.palmgo.cn:8443/mazda-prod/mobile-api/vehicleData/findMyCarStatus","tls":"","proxy":"","authType":"","x":830,"y":560,"wires":[["f76d40fe.05f41","479b7c09.28f994"]]},{"id":"f76d40fe.05f41","type":"debug","z":"f77e07dc.73b7c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1750,"y":460,"wires":[]},{"id":"3ae85be1.f0bc94","type":"comment","z":"f77e07dc.73b7c8","name":"其他状态描述","info":"doorStatus(车门状态):\n1.右车门-00000010","x":450,"y":620,"wires":[]},{"id":"eb50a04d.c06a9","type":"function","z":"f77e07dc.73b7c8","name":"保存值","func":"let info = msg.carstatus.data;\nlet location = msg.payload.location;\n// 驻车状态:1-是\nlet parkingBrake = info.realtimeInfo.parkingBrake;\n// 雨刷控制:00000011自动\nlet pluviometer = info.realtimeInfo.pluviometer;\n// 发动机状态:3-熄火\nlet engineStatus = info.realtimeInfo.engineStatus;\n// 前照灯状态:3-近光灯开启\nlet headlightStatus = info.realtimeInfo.headlightStatus; \n// 制动状态:0-未制动\nlet brakeStatus = info.realtimeInfo.brakeStatus;\n// 门状态:00000010(右门)\nlet doorStatus = info.realtimeInfo.doorStatus;\n// | 纵向 - ${info.realtimeInfo.acceleratedVelocityLengthways} | 横向 - ${info.realtimeInfo.acceleratedVelocityCrosswise} \n// | 加速器范围 | ${info.realtimeInfo.acceleratorExtent} \n// | 柴油损耗   | ${info.realtimeInfo.dieselLose}\nmsg.payload = `\n* 汽车位置\n| 熄火时间   | ${info.locationInfo.reportTimeString} \n| 停车位置   | ${location} \n* 汽车状态\n| 行驶公里数 | ${info.realtimeInfo.mile} km \n| 是否驻车   | ${parkingBrake} \n| 车轮转速   | ${info.realtimeInfo.wheelSpeed} \n| 雨刷控制   | ${pluviometer} \n| 发动机状态 | ${engineStatus} \n| 转速       | ${info.realtimeInfo.rotateSpeed} \n| 档位       | ${info.realtimeInfo.gears} \n| 座位压力   | ${info.realtimeInfo.pressureCopilot} \n| 制动状态   | ${brakeStatus} \n| 门状态     | ${doorStatus} \n| 汽油残渣   | ${info.realtimeInfo.gasolineResidue} \n| 电压       | ${info.realtimeInfo.voltage} \n| 气囊状态   | ${info.realtimeInfo.airSacStatus} \n| 制动压力   | ${info.realtimeInfo.brakePressure} \n| 纵向加速   | ${info.realtimeInfo.acceleratedVelocityLengthways} \n| 横向加速   | ${info.realtimeInfo.acceleratedVelocityCrosswise} \n| 主驾安全带 | ${info.realtimeInfo.safetyBeltDriver} \n| 副驾安全带 | ${info.realtimeInfo.safetyBeltCopilot} \n| 加速器范围 | ${info.realtimeInfo.acceleratorExtent} \n| 柴油损耗   | ${info.realtimeInfo.dieselLose}\n `\nreturn msg;","outputs":1,"noerr":0,"x":1330,"y":560,"wires":[["c1451a22.39cdb8","f76d40fe.05f41"]]},{"id":"c1451a22.39cdb8","type":"bizwechat-pushbear","z":"f77e07dc.73b7c8","name":"汽车情况","bizwechat":"c25f0536.a6b868","touser":"xxxx","toparty":"","title":"汽车情况","description":"","x":1540,"y":560,"wires":[[]]},{"id":"82e60d52.645df","type":"gaode","z":"f77e07dc.73b7c8","server":"8c7ef69.7385c08","name":"获取汽车位置","longitude":"","latitude":"","x":1020,"y":740,"wires":[["eb50a04d.c06a9","f76d40fe.05f41"]]},{"id":"479b7c09.28f994","type":"function","z":"f77e07dc.73b7c8","name":"处理位置信息","func":"let longitude = msg.payload.data.locationInfo.longitude;\nlet latitude = msg.payload.data.locationInfo.latitude;\n\nlongitude = insertStr(longitude,3,'.');\nlatitude = insertStr(latitude,2,'.');\n\nmsg.payload.longitude = longitude;\nmsg.payload.latitude = latitude;\n\nmsg.carstatus = msg.payload;\n\nreturn msg;\n\nfunction insertStr(soure, start, newStr){   \n   return soure.slice(0, start) + newStr + soure.slice(start);\n}","outputs":1,"noerr":0,"x":1020,"y":660,"wires":[["82e60d52.645df"]]},{"id":"66a76948.4e4df8","type":"link in","z":"f77e07dc.73b7c8","name":"微信查询汽车状态","links":["9683b50e.6ec5c8"],"x":135,"y":380,"wires":[["5cc9a2f6.8d1b4c"]]},{"id":"409a2ac4.0bc3e4","type":"switch","z":"f77e07dc.73b7c8","name":"汽车状态查询","property":"message.Content","propertyType":"msg","rules":[{"t":"eq","v":"汽车状态","vt":"str"},{"t":"eq","v":"a","vt":"str"},{"t":"eq","v":"我的汽车","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":400,"y":420,"wires":[["7c367a91.df0804"],["7c367a91.df0804"],[]]},{"id":"5cc9a2f6.8d1b4c","type":"function","z":"f77e07dc.73b7c8","name":"解析参数","func":"msg.message.Content=msg.message.Content||msg.message.AsrContent[0]\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":320,"wires":[["409a2ac4.0bc3e4","e4d5c336.630c8"]]},{"id":"c25f0536.a6b868","type":"bizwechat-configurator","z":"","name":"企业微信配置","port":"8090","corpid":"ww339bc923241f244b","agentid":"1000005","corpsecret":"gdR_c1qcp4YvqEaDXfLwCfjgajXc_19Gs7ArBV6mAto","url":"http://push.mrluo.net:99","token":"4lElCr","aeskey":"fa6XlNsOgVpcgMg5jUmJs9uQSA8shawh5Shu7V1FeTe","client_id":"GOSvdsBiE43Ejh7TEPMKleks","client_secret":"iNXfS0Cmz8runxzMiFiI2Ouh6Dvm2qGC"},{"id":"8c7ef69.7385c08","type":"gaode-server","z":"","name":"高德key","gaodeKey":""}]

效果:

补充一下有些参数意思:

arrayList.add(“车灯状态”); if (paramRealtimeInfo.headlightStatus.equals(“0”)) { arrayList.add(“关闭”); this.mIvCarLight.setVisibility(8); } else { this.mIvCarLight.setVisibility(0); this.mIvCarLight.setImageResource(2131230833); if (paramRealtimeInfo.headlightStatus.equals(“1”)) { arrayList.add(“日行灯开启”); } else if (paramRealtimeInfo.headlightStatus.equals(“2”)) { arrayList.add(“示宽灯开启”); } else if (paramRealtimeInfo.headlightStatus.equals(“3”)) { arrayList.add(“近光灯开启”); } else if (paramRealtimeInfo.headlightStatus.equals(“4”)) { arrayList.add(“远光灯开启”); } } if (paramRealtimeInfo.headlightStatus != null) { arrayList.add(“电池电压”); double d = Double.parseDouble(paramRealtimeInfo.voltage) / 4.0D; String str = m2(d); if (d <= 11.0D) { if (d == 0.0D) { str = “0.00V 过低”; } else { str = str + “V 过低”; } } else { str = str + " V"; } arrayList.add(str); } arrayList.add(“车门开关状态”); String str1 = “0”; String str2 = “0”; if (paramRealtimeInfo.doorStatus != null) { String str4 = paramRealtimeInfo.doorStatus.substring(7, 8); String str5 = paramRealtimeInfo.doorStatus.substring(6, 7); String str6 = paramRealtimeInfo.doorStatus.substring(5, 6); String str7 = paramRealtimeInfo.doorStatus.substring(4, 5); str2 = paramRealtimeInfo.doorStatus.substring(3, 4); str1 = paramRealtimeInfo.doorStatus.substring(2, 3); String str3 = paramRealtimeInfo.doorStatus.substring(4, 8); str3 = “carimge_” + str3; this.mIvCarDoor.setImageResource(getResource(str3)); if (str4.equals(“1”) || str5.equals(“1”) || str6.equals(“1”) || str7.equals(“1”)) { arrayList.add(“车门未关闭”); } else { arrayList.add(“关闭”); } } arrayList.add(“引擎盖开关状态”); if (str1.equals(“1”)) { this.mIvCarHead.setImageResource(2131230832); this.mIvCarHead.setVisibility(0); arrayList.add(“开启”); } else { this.mIvCarHead.setVisibility(8); arrayList.add(“关闭”); } arrayList.add(“后备箱门开关状态”); if (str2.equals(“1”)) { this.mIvCarFoot.setImageResource(2131230834); this.mIvCarFoot.setVisibility(0); arrayList.add(“开启”); } else { this.mIvCarFoot.setVisibility(8); arrayList.add(“关闭”); } } else { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(“yyy-MM-dd HH:mm:ss”); this.tv_time.setText(“更新于” + simpleDateFormat.format(new Date())); arrayList.add(“车灯状态”); arrayList.add(“关闭”); arrayList.add(“电池电压”); arrayList.add(“4.5V 过低”); arrayList.add(“车门开关状态”); arrayList.add(“关闭”); arrayList.add(“引擎盖开关状态”); arrayList.add(“关闭”); arrayList.add(“后备箱门开关状态”); arrayList.add(“关闭”); }

那么问题来了,阿特兹哪里 :thinking:

只要 19.5k立马抱回家

这是新版阿特兹自带的吗?
用的18版阿特兹的人与车联,不知道跟这个一样不.

不知道18款有app没呢

有,叫人与车练. 测试新版阿特兹APP不通用.

自己抓包每次会生成一个类似token的长串,没搞明白怎么获取和使用 :sweat_smile:

token就是认证字符串,后续发起请求应该都要带上的,可以把包抓出来测试下

土豪啊人车互联(2000多啊),,,我看了下 my mazda 里面是有汽车控制接口,,但是要装远程启动模块才能使用