I’m wanting to make a command line template sensor for smartctl which displays HDD data and can output in json format. smartctl --nocheck standby --json -x /dev/sda
Here is the json output:
https://pastebin.com/Bsbyx2Mx
you can paste the above into here to see the format:
http://jsonviewer.stack.hu/
Here is what I have done so far
sensor:
- platform: command_line
command: "smartctl --nocheck standby --json -x /dev/sda"
value_template: "{{ value_json }}"
- platform: template
sensors:
dev_sda_exit_status:
value_template: "{{ value_json.smartctl.exit_status }}"
dev_sda_smart_status_passed:
value_template: "{{ value_json.smart_status.passed }}"
dev_sda_temperature_current:
value_template: "{{ value_json.temperature.current }}"
There is also another one I want to grab that is harder
ata_smart_atrributes -> table -> id = 5 ; raw_value = X
I can’t use
# ID 5
{{ value_json.ata_smart_attributes.table[4].raw.value }}
# ID 197
{{ value_json.ata_smart_attributes.table[14].raw.value }}
because I want the raw_value based on the ID=5 or ID=197 and not based on the entry number in the table (4 or 14)