zM1 icon indicating copy to clipboard operation
zM1 copied to clipboard

关于通信协议中的部分数据格式类型问题

Open Latezly opened this issue 11 months ago • 2 comments

device/zm1/MAC/sensor

{
	"mac":"d0bae4618552",	//唯一标识符
	"PM25":"1.0",				//当前PM2.5
	"formaldehyde":"0.2",		//甲醛
	"temperature":"20",			//温度
	"humidity":"64",			//湿度
}

除了mac以外,PM2.5、甲醛、温度、湿度的数据实际上是可以用int或者float类型来表达的,带入到json中只需要删掉value的双引号即可

mac                 string
PM25                int
formaldehyde        float
temperature         float
humidity            float

我在用telegraf通过mqtt抓取数据并使用json_v2解析并写入influxdb的过程中,json_v2会自动将M2.5、甲醛、温度、湿度以string的格式写入到measurement里面

> show field keys from phicomm
name: phicomm
fieldKey            fieldType
--------            ---------
mac                 string
PM25                string
formaldehyde        string
temperature         string
humidity            string

对于这些问题不知作者觉得是否可以改善一下?

Latezly avatar Feb 26 '24 09:02 Latezly