Hi! I’m using Telegraf to create MQTT messages from Ubuntu to HASS Mosquito MQTT broker. I do this to get, amongst other things, hard drive temperatures.
The path is telegraf/my_home_server/hddtemp
. It works nicely, but the JSON is for a single disk, where the device name (in this example “sdd”) is inside the JSON:
{"fields":{"temperature":0},"name":"hddtemp","tags":{"device":"sdd","host":"my_hist_name","model":"TOSHIBA MG07ACA14TE","source":"127.0.0.1","status":"SLP","unit":"*"},"timestamp":1651054380}
I get one such JSON message for each disk. I use the configuration below, but it will obviously get the temperature of each disk, and assign them one by one to the same entity, instead of getting one entity per disk. Which is not helpful.
- platform: mqtt
name: "HD temperature for /dev/sdc"
unique_id: "hddtemp_sdc"
state_topic: "telegraf/my_home_server/hddtemp"
unit_of_measurement: "°C"
value_template: "{{ value_json.fields.temperature }}"
So the question then becomes, how can I create one entity per JSON message. Or perhaps: how can I apply the temperature value ONLY if the the disk name in the JSON matches the entity?
2 posts - 2 participants