『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 65934|回复: 84

[流程系列] NR小白第一帖:万物(汽车)在线GPS接入HA获取状态和位置。

  [复制链接]

75

主题

1976

帖子

8185

积分

元老级技术达人

积分
8185
金钱
6159
HASS币
430

活跃会员教程狂人

发表于 2019-5-17 22:33:29 | 显示全部楼层 |阅读模式
本帖最后由 咸味土豆 于 2022-2-10 21:54 编辑

2022-02-10 貌似很多人反应万物不能用了,因为我已经至少1年半没有再用这个了(模块早都被娃弄丢了),所以抱歉啦,我也没有发言权,毕竟好几年了,谢谢关注本帖。

相关更新说明

2190519,根据萝卜大佬的流程增加了逆地理(同时参考了令狐大佬的逆地理转换方法),yaml增加了重启HA自动触发执行流程的自动化(来自彩云天气的nodered流程),整理了一下,附件我重新打包上传了。

TIM截图20190519075928.png

逆地理效果图:

TIM截图20190519082356.png

墨澜显示地图效果:

TIM截图20190519082306.png

sensor信息我都提取出来了,其实也没什么用,有些数据没什么意义,可以自己转换成顺眼的,时间戳这个等F大和花神他们的节点更新。

新的附件:

gps_flow.rar (2.37 KB, 下载次数: 259)

nodered_gps.rar (1.2 KB, 下载次数: 241)


20190518,20:05 大佬发了个新的流给我,应该很全了,逆地理貌似也做了,我明天看看再更新一下,我先放附件里面了。

20190518,20:00 补充完毕。

以下是原帖内容

提示

因为我的模块本身不是汽车在线平台,都是万物在线的,不过萝卜大佬说都一样,所以不同的平台安装对应的节点就行了,见教程部分。

致谢

感谢flashsoft发的nr流;

感谢花神的nodered节点;

感谢dodoJie、萝卜、鬼鬼等大佬以及所有坛友的热心帮助。

功能

利用花神做好的nodered节点,通过这个流程将万物在线GPS模块信息接入HA,实现设备信息查看和地图的device_tracker追踪。

流程截图

flow

[{"id":"d688cd16.ab96f","type":"tab","label":"万物在线节点","disabled":false,"info":""},{"id":"3dd1d8eb.13b2e8","type":"gmiot-login","z":"d688cd16.ab96f","server":"723ec47c.76332c","name":"万物在线登陆","x":353,"y":149,"wires":[["c56779f0.bd8db8"],[]]},{"id":"cafb3195.3549b","type":"gmiot-monitor","z":"d688cd16.ab96f","server":"723ec47c.76332c","name":"设备监控","x":317,"y":407,"wires":[["e0ef8ec2.79887","9d06bce8.c3929","1243aa1a.76ef76","3ba20060.a7433","15e74504.26ab2b","c35c88e4.cd61f8","4c5a3a4c.c959f4"],[]]},{"id":"cf6762fd.ef343","type":"mqtt out","z":"d688cd16.ab96f","name":"GPS1数据","topic":"node-red/gmiot/gps1","qos":"0","retain":"false","broker":"90976202.aa203","x":728,"y":329,"wires":[]},{"id":"bc4274ec.351f28","type":"inject","z":"d688cd16.ab96f","name":"手动触发","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":158,"y":118,"wires":[["3dd1d8eb.13b2e8"]]},{"id":"e0ef8ec2.79887","type":"debug","z":"d688cd16.ab96f","name":"设备日志","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":520,"y":260,"wires":[]},{"id":"9d06bce8.c3929","type":"function","z":"d688cd16.ab96f","name":"GPS1数据取值","func":"var newMsg = \n\n{payload:msg.payload.dataArray.data[0]};\n\nreturn newMsg ;","outputs":1,"noerr":0,"x":540,"y":329,"wires":[["cf6762fd.ef343"]]},{"id":"603473ae.e1b6dc","type":"inject","z":"d688cd16.ab96f","name":"定时2小时","topic":"","payload":"","payloadType":"date","repeat":"7200","crontab":"","once":false,"onceDelay":0.1,"x":148,"y":178,"wires":[["3dd1d8eb.13b2e8"]]},{"id":"1243aa1a.76ef76","type":"function","z":"d688cd16.ab96f","name":"GPS2数据取值","func":"\nvar newMsg = \n\n{payload:msg.payload.dataArray.data[1]};\n\nreturn newMsg ;","outputs":1,"noerr":0,"x":540,"y":400,"wires":[["757bd89a.65bb58"]]},{"id":"757bd89a.65bb58","type":"mqtt out","z":"d688cd16.ab96f","name":"GPS2数据","topic":"node-red/gmiot/gps2","qos":"0","retain":"false","broker":"90976202.aa203","x":727,"y":400,"wires":[]},{"id":"3ba20060.a7433","type":"function","z":"d688cd16.ab96f","name":"GPS3数据取值","func":"var newMsg = {payload:msg.payload.dataArray.data[2]};\nreturn newMsg ;","outputs":1,"noerr":0,"x":540,"y":460,"wires":[["2038b6af.10bc9a"]]},{"id":"c56779f0.bd8db8","type":"debug","z":"d688cd16.ab96f","name":"token日志","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":540,"y":143,"wires":[]},{"id":"2038b6af.10bc9a","type":"mqtt out","z":"d688cd16.ab96f","name":"GPS3数据","topic":"node-red/gmiot/gps3","qos":"0","retain":"false","broker":"90976202.aa203","x":730,"y":460,"wires":[]},{"id":"15e74504.26ab2b","type":"function","z":"d688cd16.ab96f","name":"GPS1坐标取值","func":"msg.payload = {\n\"source_type\":msg.payload.dataArray.data[0].location,\n\"longitude\":msg.payload.dataArray.data[0].lng,\n\"latitude\":msg.payload.dataArray.data[0].lat,\n\"gps_accuracy\":msg.payload.dataArray.data[0].course,\n\"speed\":msg.payload.dataArray.data[0].speed,\n\"timestamp\":msg.payload.dataArray.data[0].heart_time,\n\"battery_level\":msg.payload.dataArray.data[0].power,};\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":520,"wires":[["b2a275f9.e4e618"]]},{"id":"b2a275f9.e4e618","type":"json","z":"d688cd16.ab96f","name":"数据处理1","property":"payload","action":"","pretty":false,"x":730,"y":520,"wires":[["6e68bd92.ed5504"]]},{"id":"6e68bd92.ed5504","type":"mqtt out","z":"d688cd16.ab96f","name":"GPS1定位","topic":"locaton/gps1","qos":"0","retain":"false","broker":"90976202.aa203","x":910,"y":520,"wires":[]},{"id":"3aaafae6.88cb96","type":"mqtt in","z":"d688cd16.ab96f","name":"HA启动触发","topic":"node-red/homeassistant-setup","qos":"2","datatype":"auto","broker":"90976202.aa203","x":116,"y":467,"wires":[["cafb3195.3549b"]]},{"id":"1b33d8ab.01a007","type":"inject","z":"d688cd16.ab96f","name":"手动触发","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":126,"y":347,"wires":[["cafb3195.3549b"]]},{"id":"590b4f31.38d64","type":"inject","z":"d688cd16.ab96f","name":"定时2分钟","topic":"","payload":"","payloadType":"date","repeat":"120","crontab":"","once":false,"onceDelay":0.1,"x":115,"y":407,"wires":[["cafb3195.3549b"]]},{"id":"3568e6d3.7e66da","type":"json","z":"d688cd16.ab96f","name":"数据处理2","property":"payload","action":"","pretty":false,"x":730,"y":580,"wires":[["847c69d9.213f18"]]},{"id":"847c69d9.213f18","type":"mqtt out","z":"d688cd16.ab96f","name":"GPS2定位","topic":"locaton/gps2","qos":"0","retain":"false","broker":"90976202.aa203","x":910,"y":580,"wires":[]},{"id":"c35c88e4.cd61f8","type":"function","z":"d688cd16.ab96f","name":"GPS2坐标取值","func":"msg.payload = {\n\"source_type\":msg.payload.dataArray.data[1].location,\n\"longitude\":msg.payload.dataArray.data[1].lng,\n\"latitude\":msg.payload.dataArray.data[1].lat,\n\"gps_accuracy\":msg.payload.dataArray.data[1].course,\n\"speed\":msg.payload.dataArray.data[1].speed,\n\"timestamp\":msg.payload.dataArray.data[1].heart_time,\n\"battery_level\":msg.payload.dataArray.data[1].power,};\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":580,"wires":[["3568e6d3.7e66da"]]},{"id":"54abb627.c23db8","type":"json","z":"d688cd16.ab96f","name":"数据处理3","property":"payload","action":"","pretty":false,"x":730,"y":640,"wires":[["3efb6352.d9318c"]]},{"id":"3efb6352.d9318c","type":"mqtt out","z":"d688cd16.ab96f","name":"GPS3定位","topic":"locaton/gps3","qos":"0","retain":"false","broker":"90976202.aa203","x":910,"y":640,"wires":[]},{"id":"4c5a3a4c.c959f4","type":"function","z":"d688cd16.ab96f","name":"GPS2坐标取值","func":"msg.payload = {\n\"source_type\":msg.payload.dataArray.data[2].location,\n\"longitude\":msg.payload.dataArray.data[2].lng,\n\"latitude\":msg.payload.dataArray.data[2].lat,\n\"gps_accuracy\":msg.payload.dataArray.data[2].course,\n\"speed\":msg.payload.dataArray.data[2].speed,\n\"timestamp\":msg.payload.dataArray.data[2].heart_time,\n\"battery_level\":msg.payload.dataArray.data[2].power,};\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":640,"wires":[["54abb627.c23db8"]]},{"id":"723ec47c.76332c","type":"gmiot-configurator","z":"","name":"万物账号","phone":"xxx","password":"xxx"},{"id":"90976202.aa203","type":"mqtt-broker","z":"","name":"hassio-mqtt","broker":"10.16.100.35","port":"1883","clientid":"nodered-client","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

前提

安装了nodered,并配置好了HA的节点;

安装了mqtt,在NR中配置好了mqtt节点。

用法

1、安装花神的Nodered节点;

万物在线用这个:

node-red-contrib-gps-lite-gmiot

汽车在线用这个:

node-red-contrib-gps

2、导入flow;

3、将附件的yaml放进packages文件夹下,device_tracker和sensor相关的配置、汉化、图标等我都做好了。

TIM截图20190518200634.png

4、重启HA

5、配置lovelace,因为没用group,附件放个单独的sensor明细。

6、配置地图相关

TIM截图20190518194324.png

我用的论坛里大佬做的高德的lovelace插件,其他的没测试。

地图插件地址:https://bbs.hassbian.com/thread-5782-1-1.html

这个也有偏移,不过都在偏,除了看起来别扭,先将就吧。

后话

模块的sensor里面,时间戳暂时没做转换(还不会),花神可能会更新节点直接写好,HA里面转换也是可以的,得自己动手了,我暂时不想搞了。

这个流我就做了一些和HA相关的基础工作,流程用到的处理方式都是萝卜大佬和dodoJie大佬帮忙写的,最近大佬们都比较忙,我拼凑了一下,先帮忙发出来给需要的坛友,流程本身有很多优化的空间,萝卜大佬可能会出一个新流,我也是边学边玩,就这样吧。

enjoy !

如果有疑问的话,可以留言,我看到而且知道的话会回复,但是强烈建议在搜索论坛帖子学习。

附件:

flows.rar (1.61 KB, 下载次数: 90)

groups.rar (249 Bytes, 下载次数: 105)

nodered_gps.rar (1.44 KB, 下载次数: 94)

萝卜新的flow附件:

萝卜大佬万物流.rar (541 Bytes, 下载次数: 154)








TIM截图20190518181643.png

评分

参与人数 4金钱 +55 HASS币 +20 收起 理由
shadowba + 5 我来瀚思就为看你!
a439771597 + 10 我来瀚思就为看你!
+ 20 + 20 厉害了word楼主!
neroxps + 20

查看全部评分

所有过往,皆为序章。
回复

使用道具 举报

62

主题

603

帖子

6390

积分

论坛元老

Rank: 8Rank: 8

积分
6390
金钱
5712
HASS币
240

教程狂人论坛风云人物

发表于 2019-5-18 19:00:34 | 显示全部楼层
最近忙,没空写具体教程,所以跟土豆兄弟简单讲了一下。汽车在线跟万物在线花神都有写了节点的,用法是一致的,根据自己设备选择不同的节点替换就是。
汽车在线.png
尝试过萝卜,我想你一定会忘记青瓜
回复

使用道具 举报

40

主题

2176

帖子

8294

积分

元老级技术达人

积分
8294
金钱
6103
HASS币
110
发表于 2019-5-21 14:12:42 | 显示全部楼层
本帖最后由 ghostist 于 2019-5-21 14:16 编辑

QQ图片20190521140751.png    
QQ图片20190521140800.png

解决时间显示为UNIX时间戳的问题,如图PS:在我用HA解决这个问题的同时,土豆哥用NR解决了和我一样的问题  不约而同啊

参考:https://www.home-assistant.io/docs/configuration/templating/#time

sensor:
##1
  - platform: mqtt
    name: "gps01_nidili" 
    state_topic: "node-red/gmiot/nidili1"
    value_template: "{{ value }}"
  - platform: mqtt
    name: "gps01_name" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.name }}"
  - platform: mqtt
    name: "gps01_dev_type" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.dev_type }}"
  - platform: mqtt
    name: "gps01_imei" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.imei }}"
  - platform: mqtt
    name: "gps01_power" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.power }}"
  - platform: mqtt
    name: "gps01_device_info" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.device_info }}"
  - platform: mqtt
    name: "gps01_device_info_new" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.device_info_new }}"
  - platform: mqtt
    name: "gps01_seconds"
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.seconds }}"
  - platform: mqtt
    name: "gps01_gps_time" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.gps_time | timestamp_local}}"
  - platform: mqtt
    name: "gps01_sys_time" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.sys_time | timestamp_local}}"
  - platform: mqtt
    name: "gps01_heart_time"
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.heart_time | timestamp_local}}"
  - platform: mqtt
    name: "gps01_server_time" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.server_time | timestamp_local}}"
  - platform: mqtt
    name: "gps01_lng"
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.lng }}"
  - platform: mqtt
    name: "gps01_lat" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.lat }}"
  - platform: mqtt
    name: "gps01_course" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.course }}"
  - platform: mqtt
    name: "gps01_speed"
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.speed }}"
    unit_of_measurement: 'km/h'
  - platform: mqtt
    name: "gps01_location" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.location }}"
  - platform: mqtt
    name: "gps01_group_id"
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.group_id }}"
  - platform: mqtt
    name: "gps01_status" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.status }}"
  - platform: mqtt
    name: "gps01_acc" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.acc }}"
  - platform: mqtt
    name: "gps01_acc_seconds" 
    state_topic: "node-red/gmiot/gps1"
    value_template: "{{ value_json.acc_seconds }}"
    unit_of_measurement: '秒'


评分

参与人数 1金钱 +20 收起 理由
咸味土豆 + 20 论坛有你更精彩!

查看全部评分

回复

使用道具 举报

8

主题

155

帖子

1204

积分

论坛技术达人

积分
1204
金钱
1039
HASS币
20
发表于 2022-3-18 09:37:48 | 显示全部楼层
咸味土豆 发表于 2022-3-17 22:24
要是有现成的流分享,可以发个附件,我置顶一下,因为我自己早已经不用也没有设备了,抱歉 ...

不需要改流。用你的流就可以了,但是要改的是节点源码里http请求的域名。具体是login.js address.js configure.js
回复

使用道具 举报

69

主题

691

帖子

4242

积分

论坛元老

Rank: 8Rank: 8

积分
4242
金钱
3546
HASS币
80
发表于 2019-5-17 23:01:25 | 显示全部楼层
土豆大哥,这个好啊。能不能生成gpx或kml格式的航迹文件,并可以导出到pc上啊。
回复

使用道具 举报

40

主题

2176

帖子

8294

积分

元老级技术达人

积分
8294
金钱
6103
HASS币
110
发表于 2019-5-17 23:02:56 | 显示全部楼层
device_tracker可以补  自己先挖个坑
回复

使用道具 举报

75

主题

1976

帖子

8185

积分

元老级技术达人

积分
8185
金钱
6159
HASS币
430

活跃会员教程狂人

 楼主| 发表于 2019-5-17 23:25:30 | 显示全部楼层
本帖最后由 咸味土豆 于 2019-5-18 20:19 编辑
ghostist 发表于 2019-5-17 23:02
device_tracker可以补  自己先挖个坑

可以用了,哈哈。
所有过往,皆为序章。
回复

使用道具 举报

75

主题

1976

帖子

8185

积分

元老级技术达人

积分
8185
金钱
6159
HASS币
430

活跃会员教程狂人

 楼主| 发表于 2019-5-17 23:26:56 | 显示全部楼层
zhenxiwen 发表于 2019-5-17 23:01
土豆大哥,这个好啊。能不能生成gpx或kml格式的航迹文件,并可以导出到pc上啊。 ...

这个获取到的信息都是大佬们的做的节点,本身好像也获取不到轨迹的吧,我这小白更不懂啦。哈哈。
所有过往,皆为序章。
回复

使用道具 举报

73

主题

1165

帖子

6645

积分

论坛元老

Rank: 8Rank: 8

积分
6645
金钱
5475
HASS币
30
发表于 2019-5-18 04:49:10 | 显示全部楼层
学习一下
回复

使用道具 举报

8

主题

2073

帖子

6053

积分

论坛元老

流水无味

Rank: 8Rank: 8

积分
6053
金钱
3980
HASS币
145

灌水之王

发表于 2019-5-18 07:35:36 | 显示全部楼层
支持!  19的价格没涨好像不是终身平台了
回复

使用道具 举报

2

主题

433

帖子

2651

积分

金牌会员

Rank: 6Rank: 6

积分
2651
金钱
2218
HASS币
0
QQ
发表于 2019-5-18 09:06:23 | 显示全部楼层
大神 我GPS 模块 是汽车在线的  可以接入到HA 吗  求指教!
回复

使用道具 举报

75

主题

1976

帖子

8185

积分

元老级技术达人

积分
8185
金钱
6159
HASS币
430

活跃会员教程狂人

 楼主| 发表于 2019-5-18 09:09:31 | 显示全部楼层
[email protected] 发表于 2019-5-18 09:06
大神 我GPS 模块 是汽车在线的  可以接入到HA 吗  求指教!

一样的,安装的节点不一样,花神写的有。
所有过往,皆为序章。
回复

使用道具 举报

2

主题

433

帖子

2651

积分

金牌会员

Rank: 6Rank: 6

积分
2651
金钱
2218
HASS币
0
QQ
发表于 2019-5-18 09:34:55 | 显示全部楼层
咸味土豆 发表于 2019-5-18 09:09
一样的,安装的节点不一样,花神写的有。

给个汽车在线的连接可以吗 谢谢!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-29 04:37 , Processed in 0.238100 second(s), 43 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表