Draggon / hassio-hdd-tools

27 stars 12 forks source link

jq: error: syntax error, unexpected '{' - sensor not have SMART attributes only Temperature #31

Closed andrewjswan closed 3 years ago

andrewjswan commented 3 years ago

Sensor not have SMART attributes only Temperature, error in log:

[Thu Jun 10 16:38:59 EEST 2021][INFO] HDD Tools start
[Thu Jun 10 16:38:59 EEST 2021][INFO] Configuration - performance check enabled: false
[Thu Jun 10 16:38:59 EEST 2021][INFO] Configuration - disk path: /dev/sda
[Thu Jun 10 16:38:59 EEST 2021][INFO] Configuration - check period: 1
[Thu Jun 10 16:38:59 EEST 2021][INFO] Configuration - database update: true
[Thu Jun 10 16:38:59 EEST 2021][INFO] Configuration - database update period: 168
[Thu Jun 10 16:38:59 EEST 2021][INFO] Configuration - output file: temp.log
[Thu Jun 10 16:38:59 EEST 2021][INFO] Configuration - attributes property: smart
[Thu Jun 10 16:38:59 EEST 2021][INFO] Init run
jq: error: syntax error, unexpected '{', expecting $end (Unix shell quoting issues?) at <top-level>, line 2:
{}
jq: 1 compile error
[Thu Jun 10 16:39:00 EEST 2021][INFO] Sensor value: 34°
[Thu Jun 10 16:39:00 EEST 2021][DEBUG] Sensor data which would be pushed to home-assistant and exposed as "sensor.ssd_temp": 
[Thu Jun 10 16:39:00 EEST 2021][DEBUG] debug is enabled, sensor data is not published to home-assistant!
[Thu Jun 10 16:39:00 EEST 2021][INFO] Cron tab SMART update
[Thu Jun 10 16:39:00 EEST 2021][INFO] Cron tab database update ENABLED
[Thu Jun 10 16:39:00 EEST 2021][INFO] Updating drives database...
[Thu Jun 10 16:39:03 EEST 2021][INFO] /usr/share/smartmontools/drivedb.h updated from branches/RELEASE_7_2_DRIVEDB
[Thu Jun 10 16:39:03 EEST 2021][INFO] Apply cron tab
[Thu Jun 10 16:39:03 EEST 2021][INFO] Device /dev/sda found - starting CRON
jq: error: syntax error, unexpected '{', expecting $end (Unix shell quoting issues?) at <top-level>, line 2:
{}
jq: 1 compile error
[Thu Jun 10 16:40:01 EEST 2021][INFO] Sensor value: 34°
McGiverGim commented 3 years ago

Enable the debug option and paste here your configuration and the output file of the debug.

andrewjswan commented 3 years ago

temp.log

andrewjswan commented 3 years ago

@McGiverGim Configuration:

sensor_name: sensor.ssd_temp
friendly_name: SSD Temp
hdd_path: /dev/disk/by-id/ata-KINGSTON_RBUSNS8180S3128GJ_50026B76821D0D9B
attributes_format: object
attributes_property: smart
check_period: 1
database_update: true
database_update_period: 168
performance_check: false
debug: true
output_file: temp.log

Log attached above ...

McGiverGim commented 3 years ago

If I'm not wrong, change the: attributes_format: list and attributes_property: ata_smart_attributes.table

andrewjswan commented 3 years ago

@McGiverGim Yes, this work:

[Thu Jun 10 18:05:01 EEST 2021][INFO] Sensor value: 34°
[Thu Jun 10 18:05:01 EEST 2021][DEBUG] Sensor data which would be pushed to home-assistant and exposed as "sensor.ssd_temp": {
  "state": "34",
  "attributes": {
    "unit_of_measurement": "°C",
    "friendly_name": "SSD Temp",
    "power_on_hours": 5438,
    "power_cycle_count": 1743,
    "unknown_attribute_167": 0,
    "unknown_attribute_168": 0,
    "unknown_attribute_172": 0,
    "unknown_attribute_173": 9961651,
    "program_fail_cnt_total": 0,
    "reported_uncorrect": 0,
    "power-off_retract_count": 538,
    "temperature_celsius": 34,
    "reallocated_event_count": 0,
    "unknown_attribute_218": 0,
    "unknown_ssd_attribute": 92,
    "media_wearout_indicator": 12089,
    "total_lbas_written": 10209,
    "total_lbas_read": 12746,
    "unknown_attribute_244": 152,
    "unknown_attribute_245": 179,
    "unknown_attribute_246": 1695968
  }
}
[Thu Jun 10 18:05:01 EEST 2021][DEBUG] debug is enabled, sensor data is not published to home-assistant!

But i dont see critical_warning vlaue, but i need it for check overall SSD health, is Ok or Bad ...

andrewjswan commented 3 years ago

Is it possible to get this status:

  "smart_status": {
    "passed": true
  },
andrewjswan commented 3 years ago

@McGiverGim If i change settings to:

attributes_format: object
attributes_property: smart_status

Then i have this value:

[Thu Jun 10 18:16:07 EEST 2021][DEBUG] Sensor data which would be pushed to home-assistant and exposed as "sensor.ssd_temp": {
  "state": "34",
  "attributes": {
    "unit_of_measurement": "°C",
    "friendly_name": "SSD Temp",
    "passed": true
  }
}

But then I lose the other attributes, is it possible how to combine them? Get the status in one attribute and the SMART attributes in the second?

McGiverGim commented 3 years ago

At this moment no. One or another. Maybe open a feature request for it.

andrewjswan commented 3 years ago

@McGiverGim Ok! I create it ... https://github.com/Draggon/hassio-hdd-tools/issues/32