Im new and try to achieve following, if someone can point me to correct directions , please:
Archit:
HW - X86 with Proxmox
HA - running as VM with HA Core v: 2022.9.1
I want to monitor HW running on Proxmox server ( HA , as it docker unable to “communicate” with hardware on HW box
I was driven by this tutorial:
YES, I know I can monitor HW running proxmox on 10.000 ways and provide graphs - BUT I would like to make it like this:
Telegraf Agent monitor Proxmox + HW → send by MQTT Topic data to HA MQTT broker → I create manual entities in HA based on MQTT data/topic → store data in InfluxDB ( Yes I know what Telegram can send raw data directly to InfluxDB - but I want it via MQTT - Cause I want to learn how to work with MQTT) - and last step represent graph in Grafana …
Again this is “LONG WAY” with many sub-components - but this a way how I learn it …
Now , lets take for example of of the Telegraf agent possibilities to monitor HW Disks temperature … and lets say I have 2 disks - /dev/sda and /dev/sdb
So, Telegraf configured and send data to MQTT to same topic like this:
#############################
Message 2 received on telegraf/192.168.10.6/hddtemp at 12:39 PM:
{
“fields”: {
“temperature”: 32
},
“name”: “hddtemp”,
“tags”: {
“device”: “sdb”,
“host”: “192.168.10.6”,
“model”: “Samsung SSD 870 QVO 2TB”,
“source”: “127.0.0.1”,
“status”: “”,
“unit”: “C”
},
“timestamp”: 1663148340
}
QoS: 0 - Retain: false
###########################
Message 1 received on telegraf/192.168.10.6/hddtemp at 12:39 PM:
{
“fields”: {
“temperature”: 32
},
“name”: “hddtemp”,
“tags”: {
“device”: “sda”,
“host”: “192.168.10.6”,
“model”: “Samsung SSD 870 QVO 2TB”,
“source”: “127.0.0.1”,
“status”: “”,
“unit”: “C”
},
“timestamp”: 1663148340
}
Now As you see - it 2 disks “sda” and “sdb” - each one has it own temperature and model.
( for this time both sda and sdb - 32 C*) ( I have 12 disks in server and temp for each different…)
Now I created in mqtt.yaml following:
sensor:
###SDA###
-
name: “HDDTemp-hda”
state_topic: telegraf/192.168.10.6/hddtemp
unit_of_measurement: “C”
value_template: “{{ value_json.fields.temperature if value_json.tags.device == ‘sda’ else sensor.value_template.from_state }}”
-
name: “HDDModel-hda”
state_topic: telegraf/192.168.10.6/hddtemp
value_template: “{{ value_json.tags.model if value_json.tags.device == ‘sda’ else sensor.value_template.from_state }}”
##############
###SDB###
-
name: “HDDTemp-hdb”
state_topic: telegraf/192.168.10.6/hddtemp
unit_of_measurement: “C”
value_template: “{{ value_json.fields.temperature if value_json.tags.device == ‘sdb’ else sensor.value_template.from_state }}”
-
name: “HDDModel-hdb”
state_topic: telegraf/192.168.10.6/hddtemp
value_template: “{{ value_json.tags.model if value_json.tags.device == ‘sdb’ else sensor.value_template.from_state }}”
##############
This is “WORK” ugli , hardcodded for each disk with errors in HA log:
############################################
2022-09-14 12:19:07.593 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.fields.temperature if value_json.tags.device == ‘sdb’ else sensor.value_template.from_state }}’
2022-09-14 12:19:07.597 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.tags.model if value_json.tags.device == ‘sdb’ else sensor.value_template.from_state }}’
2022-09-14 12:19:07.602 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.fields.temperature if value_json.tags.device == ‘sdc’ else sensor.value_template.from_state }}’
2022-09-14 12:19:07.609 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.tags.model if value_json.tags.device == ‘sdc’ else sensor.value_template.from_state }}’
2022-09-14 12:19:07.611 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.fields.temperature if value_json.tags.device == ‘sdd’ else sensor.value_template.from_state }}’
2022-09-14 12:19:07.612 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.tags.model if value_json.tags.device == ‘sdd’ else sensor.value_template.from_state }}’
2022-09-14 12:19:07.614 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.fields.temperature if value_json.tags.device == ‘sde’ else sensor.value_template.from_state }}’
2022-09-14 12:19:07.620 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.tags.model if value_json.tags.device == ‘sde’ else sensor.value_template.from_state }}’
2022-09-14 12:19:07.622 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.fields.temperature if value_json.tags.device == ‘sdf’ else sensor.value_template.from_state }}’
2022-09-14 12:19:07.625 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.tags.model if value_json.tags.device == ‘sdf’ else sensor.value_template.from_state }}’
2022-09-14 12:19:07.628 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.fields.temperature if value_json.tags.device == ‘sda’ else sensor.value_template.from_state }}’
2022-09-14 12:19:07.631 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.tags.model if value_json.tags.device == ‘sda’ else sensor.value_template.from_state }}’
2022-09-14 12:19:07.634 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.fields.temperature if value_json.tags.device == ‘sdc’ else sensor.value_template.from_state }}’
2022-09-14 12:19:07.636 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘sensor’ is undefined when rendering ‘{{ value_json.tags.model if value_json.tags.device == ‘sdc’ else sensor.value_template.from_state }}’
##############################################
My questions is:
- How can I from SAME MQTT topic which send me 12 messages , where each message “show/talking” different HardDrives - pickup the “1st” drive - make the “1st entity” like “hddtemp-sda” and add value : temp , second entity “hddmodel-sda” , where temp will be “different” and model constantly(until disk will be replaced) . and then from “2nd message” I’ll pickup second drive “sdb” and get relevant data for that drive . and add this data to relevant entity “hddtemp-sdb” and “hddmodel-sdb” …
Thanks a lot