|
本帖最后由 pauldw1230 于 2020-7-21 14:12 编辑
购买了一个空气检测仪,可以通过公网获得数据。现在想把数据传入自己的ha中,但是编程小白不知道从何入手。
目前已知的获得数据的方式有几种,其中
第一种:公网服务器地址XX.XX.XX.XX充当tcp server,端口9001。tcp客户端使用{"method":"readdata","did":"XXXXXX(序列号)",}可以获得一串数字,比如{"PM25":"16","PM1":"11","PM10":"15","CO2":"320","HCHO":"0.06","TEMR":"32","HIM":"62","AQI":"66","VOC":"-1",},其中-1代表没有相关传感器。
第二种:通过直接访问一个公网链接,就可以获得数据,格式类似于{"pm1":"19","hcho":"0.04","o2":"-1","time":"2020-07-20 15:59:20","tvoc":"0","pm2.5":"29","aqi":"41","temp":"23","co2":"489","pm10":"31","humi":"83"}。
问题是如何在homeassistant中获得上述传感器数据,每隔一定时间自动刷新一下(比如1分钟)。希望大神能够帮忙,谢谢。
|
|