Draggon / hassio-hdd-tools

27 stars 14 forks source link

How to use attributes? #59

Closed RestOp closed 2 years ago

RestOp commented 2 years ago

Hello,

thanks a lot for Addon! I am o RPI4 and SSD in USB 3.0 enclosure with latest HassOS. Installed 0.53

Two questions

  1. I get temperature value 0. Why? In windows smart software i can see the right value.
  2. How to set attributes image To get more information in sensor as just ON OFF states.

Here is LOG is needed s6-rc: info: service s6rc-oneshot-runner: starting s6-rc: info: service s6rc-oneshot-runner successfully started s6-rc: info: service fix-attrs: starting s6-rc: info: service fix-attrs successfully started s6-rc: info: service legacy-cont-init: starting s6-rc: info: service legacy-cont-init successfully started s6-rc: info: service legacy-services: starting s6-rc: info: service legacy-services successfully started [Tue Sep 13 11:46:37 CEST 2022][INFO] HDD Tools start [Tue Sep 13 11:46:37 CEST 2022][INFO] Configuration - sensor state type: smart_state [Tue Sep 13 11:46:37 CEST 2022][INFO] Configuration - performance check enabled: false [Tue Sep 13 11:46:38 CEST 2022][INFO] Configuration - disk path: /dev/sda4 [Tue Sep 13 11:46:38 CEST 2022][INFO] Configuration - check period: 1 [Tue Sep 13 11:46:38 CEST 2022][INFO] Configuration - database update: true [Tue Sep 13 11:46:38 CEST 2022][INFO] Configuration - database update period: 168 [Tue Sep 13 11:46:38 CEST 2022][INFO] Configuration - output file: temp.log [Tue Sep 13 11:46:38 CEST 2022][INFO] Configuration - attributes property: [Tue Sep 13 11:46:38 CEST 2022][INFO] Init run [Tue Sep 13 11:46:40 CEST 2022][INFO] Sensor value as smart_state: true, problem: off [Tue Sep 13 11:46:40 CEST 2022][DEBUG] Sensor data before attributes: {"state": "off", "attributes": {"friendly_name":"Hdd SMART","device_class":"problem"}} [Tue Sep 13 11:46:40 CEST 2022][DEBUG] Sensor data which would be pushed to home-assistant and exposed as "binary_sensor.hdd_smart_detail": {"state": "off", "attributes": {"friendly_name":"Hdd SMART","device_class":"problem"}} [Tue Sep 13 11:46:40 CEST 2022][DEBUG] debug is enabled, sensor data is not published to home-assistant! [Tue Sep 13 11:46:40 CEST 2022][INFO] Cron tab SMART update [Tue Sep 13 11:46:40 CEST 2022][INFO] Cron tab database update ENABLED [Tue Sep 13 11:46:40 CEST 2022][INFO] Updating drives database... [Tue Sep 13 11:46:43 CEST 2022][INFO] /usr/share/smartmontools/drivedb.h 7.3/5319 updated to 7.3/5405 [Tue Sep 13 11:46:43 CEST 2022][INFO] Apply cron tab [Tue Sep 13 11:46:43 CEST 2022][INFO] Device /dev/sda4 found - starting CRON [Tue Sep 13 11:47:05 CEST 2022][INFO] Sensor value as smart_state: true, problem: off [Tue Sep 13 11:47:05 CEST 2022][DEBUG] Sensor data before attributes: {"state": "off", "attributes": {"friendly_name":"Hdd SMART","device_class":"problem"}} [Tue Sep 13 11:47:05 CEST 2022][DEBUG] Sensor data which would be pushed to home-assistant and exposed as "binary_sensor.hdd_smart_detail": {"state": "off", "attributes": {"friendly_name":"Hdd SMART","device_class":"problem"}} [Tue Sep 13 11:47:05 CEST 2022][DEBUG] debug is enabled, sensor data is not published to home-assistant! [Tue Sep 13 11:48:01 CEST 2022][INFO] Sensor value as smart_state: true, problem: off [Tue Sep 13 11:48:01 CEST 2022][DEBUG] Sensor data before attributes: {"state": "off", "attributes": {"friendly_name":"Hdd SMART","device_class":"problem"}} [Tue Sep 13 11:48:01 CEST 2022][DEBUG] Sensor data which would be pushed to home-assistant and exposed as "binary_sensor.hdd_smart_detail": {"state": "off", "attributes": {"friendly_name":"Hdd SMART","device_class":"problem"}} [Tue Sep 13 11:48:01 CEST 2022][DEBUG] debug is enabled, sensor data is not published to home-assistant! [Tue Sep 13 11:49:01 CEST 2022][INFO] Sensor value as smart_state: true, problem: off [Tue Sep 13 11:49:01 CEST 2022][DEBUG] Sensor data before attributes: {"state": "off", "attributes": {"friendly_name":"Hdd SMART","device_class":"problem"}} [Tue Sep 13 11:49:01 CEST 2022][DEBUG] Sensor data which would be pushed to home-assistant and exposed as "binary_sensor.hdd_smart_detail": {"state": "off", "attributes": {"friendly_name":"Hdd SMART","device_class":"problem"}} [Tue Sep 13 11:49:01 CEST 2022][DEBUG] debug is enabled, sensor data is not published to home-assistant! [Tue Sep 13 11:50:01 CEST 2022][INFO] Sensor value as smart_state: true, problem: off [Tue Sep 13 11:50:01 CEST 2022][DEBUG] Sensor data before attributes: {"state": "off", "attributes": {"friendly_name":"Hdd SMART","device_class":"problem"}} [Tue Sep 13 11:50:01 CEST 2022][DEBUG] Sensor data which would be pushed to home-assistant and exposed as "binary_sensor.hdd_smart_detail": {"state": "off", "attributes": {"friendly_name":"Hdd SMART","device_class":"problem"}} [Tue Sep 13 11:50:01 CEST 2022][DEBUG] debug is enabled, sensor data is not published to home-assistant!

and temp.log `{ "json_format_version": [ 1, 0 ], "smartctl": { "version": [ 7, 3 ], "svn_revision": "5338", "platform_info": "aarch64-linux-5.15.32-v8", "build_info": "(local build)", "argv": [ "smartctl", "-a", "--json", "/dev/sda" ], "drive_database_version": { "string": "7.3/5405" }, "exit_status": 64 }, "local_time": { "time_t": 1663063501, "asctime": "Tue Sep 13 12:05:01 2022 CEST" }, "device": { "name": "/dev/sda", "info_name": "/dev/sda [SAT]", "type": "sat", "protocol": "ATA" }, "model_family": "Silicon Motion based OEM SSDs", "model_name": "Verbatim Vi550 S3", "serial_number": "4935015148305831", "firmware_version": "U1124A0", "user_capacity": { "blocks": 250069680, "bytes": 128035676160 }, "logical_block_size": 512, "physical_block_size": 512, "rotation_rate": 0, "form_factor": { "ata_value": 3, "name": "2.5 inches" }, "trim": { "supported": true, "deterministic": false, "zeroed": false }, "in_smartctl_database": true, "ata_version": { "string": "ACS-2 T13/2015-D revision 3", "major_value": 1008, "minor_value": 272 }, "sata_version": { "string": "SATA 3.2", "value": 255 }, "interface_speed": { "max": { "sata_value": 14, "string": "6.0 Gb/s", "units_per_second": 60, "bits_per_unit": 100000000 }, "current": { "sata_value": 3, "string": "6.0 Gb/s", "units_per_second": 60, "bits_per_unit": 100000000 } }, "smart_support": { "available": true, "enabled": true }, "smart_status": { "passed": true }, "ata_smart_data": { "offline_data_collection": { "status": { "value": 0, "string": "was never started" }, "completion_seconds": 120 }, "self_test": { "status": { "value": 0, "string": "completed without error", "passed": true }, "polling_minutes": { "short": 2, "extended": 10 } }, "capabilities": { "values": [ 17, 2 ], "exec_offline_immediate_supported": true, "offline_is_aborted_upon_new_cmd": false, "offline_surface_scan_supported": false, "self_tests_supported": true, "conveyance_self_test_supported": false, "selective_self_test_supported": false, "attribute_autosave_enabled": false, "error_logging_supported": true, "gp_logging_supported": true } }, "ata_smart_attributes": { "revision": 1, "table": [ { "id": 1, "name": "Raw_Read_Error_Rate", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 5, "name": "Reallocated_Sector_Ct", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 9, "name": "Power_On_Hours", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 4555, "string": "4555" } }, { "id": 12, "name": "Power_Cycle_Count", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 43, "string": "43" } }, { "id": 160, "name": "Uncorrectable_Error_Cnt", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 161, "name": "Valid_Spare_Block_Cnt", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 51, "string": "PO--CK ", "prefailure": true, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 100, "string": "100" } }, { "id": 163, "name": "Initial_Bad_Block_Count", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 8, "string": "8" } }, { "id": 164, "name": "Total_Erase_Count", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 159952, "string": "159952" } }, { "id": 165, "name": "Max_Erase_Count", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 402, "string": "402" } }, { "id": 166, "name": "Min_Erase_Count", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 102, "string": "102" } }, { "id": 167, "name": "Average_Erase_Count", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 245, "string": "245" } }, { "id": 168, "name": "Max_Erase_Count_of_Spec", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 5050, "string": "5050" } }, { "id": 169, "name": "Remaining_Lifetime_Perc", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 96, "string": "96" } }, { "id": 175, "name": "Program_Fail_Count_Chip", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 176, "name": "Erase_Fail_Count_Chip", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 177, "name": "Wear_Leveling_Count", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 178, "name": "Runtime_Invalid_Blk_Cnt", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 181, "name": "Program_Fail_Cnt_Total", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 182, "name": "Erase_Fail_Count_Total", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 192, "name": "Power-Off_Retract_Count", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 31, "string": "31" } }, { "id": 194, "name": "Temperature_Celsius", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 34, "string": "-O---K ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": false, "auto_keep": true }, "raw": { "value": 40, "string": "40" } }, { "id": 195, "name": "Hardware_ECC_Recovered", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 196, "name": "Reallocated_Event_Count", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 197, "name": "Current_Pending_Sector", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 198, "name": "Offline_Uncorrectable", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 0, "string": "0" } }, { "id": 199, "name": "UDMA_CRC_Error_Count", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 3, "string": "3" } }, { "id": 232, "name": "Available_Reservd_Space", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 100, "string": "100" } }, { "id": 241, "name": "Host_Writes_32MiB", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 48, "string": "----CK ", "prefailure": false, "updated_online": false, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 299655, "string": "299655" } }, { "id": 242, "name": "Host_Reads_32MiB", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 48, "string": "----CK ", "prefailure": false, "updated_online": false, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 247384, "string": "247384" } }, { "id": 245, "name": "TLC_Writes_32MiB", "value": 100, "worst": 100, "thresh": 50, "when_failed": "", "flags": { "value": 50, "string": "-O--CK ", "prefailure": false, "updated_online": true, "performance": false, "error_rate": false, "event_count": true, "auto_keep": true }, "raw": { "value": 475313, "string": "475313" } } ] }, "power_on_time": { "hours": 4555 }, "power_cycle_count": 43, "temperature": { "current": 40 }, "ata_smart_error_log": { "summary": { "revision": 1, "count": 3, "logged_count": 3, "table": [ { "error_number": -1, "lifetime_hours": 0, "completion_registers": { "error": 0, "status": 0, "count": 0, "lba": 0, "device": 0 }, "previous_commands": [ { "registers": { "command": 176, "features": 208, "count": 1, "lba": 12734208, "device": 0, "device_control": 0 }, "powerup_milliseconds": 0, "command_name": "SMART READ DATA" }, { "registers": { "command": 176, "features": 209, "count": 1, "lba": 12734209, "device": 0, "device_control": 0 }, "powerup_milliseconds": 0, "command_name": "SMART READ ATTRIBUTE THRESHOLDS [OBS-4]" }, { "registers": { "command": 176, "features": 218, "count": 0, "lba": 12734208, "device": 0, "device_control": 0 }, "powerup_milliseconds": 0, "command_name": "SMART RETURN STATUS" }, { "registers": { "command": 231, "features": 40, "count": 0, "lba": 5101096, "device": 0, "device_control": 0 }, "powerup_milliseconds": 0, "command_name": "FLUSH CACHE" }, { "registers": { "command": 236, "features": 0, "count": 1, "lba": 0, "device": 0, "device_control": 0 }, "powerup_milliseconds": 0, "command_name": "IDENTIFY DEVICE" } ] } ] } }, "ata_smart_self_test_log": { "standard": { "revision": 1, "table": [ { "type": { "value": 2, "string": "Extended offline" }, "status": { "value": 249, "string": "Self-test routine in progress", "remaining_percent": 90, "passed": true }, "lifetime_hours": 4511 }, { "type": { "value": 2, "string": "Extended offline" }, "status": { "value": 25, "string": "Aborted by host", "remaining_percent": 90 }, "lifetime_hours": 4511 } ], "count": 2, "error_count_total": 0, "error_count_outdated": 0 } } }

`

Thanks!

McGiverGim commented 2 years ago

You have selected to use the "smart" sensor, this sends the sensor as true/false and the temperature as attribute.

You have samples in the docs tab: https://github.com/Draggon/hassio-hdd-tools/blob/develop/hdd_tools/DOCS.md

but is ata_smart_attributes.table

RestOp commented 2 years ago

Thansk a lot! I made it work!!!

The only question is-

I set it up to ata_smart_attributes.table But in log i see also other parameters that i could also use image So is there a way to set both attributes like:

ata_smart_attributes.table

and

ata_smart_self_test_log.table

Thanks!

McGiverGim commented 2 years ago

No, the code does not support it.

RestOp commented 2 years ago

Thanks for answer! Am i right that if is use "smart" sensor the whole smart informations will be updated every check interval period? image

PS I have also made some template sensors, you can post them as examples in docs:


sensor:
  - platform: template
    sensors:
      hdd_smart_power_cycle_count:
        unit_of_measurement: "times"
        device_class: "duration"
        value_template: "{{  state_attr('binary_sensor.hdd_smart', 'power_cycle_count') }}"

  - platform: template
    sensors:
      hdd_smart_udma_crc_error_count:
        value_template: "{{  state_attr('binary_sensor.hdd_smart', 'udma_crc_error_count') }}"

  - platform: template
    sensors:
      hdd_smart_lifetime_percent:
        unit_of_measurement: "%"
        value_template: >-
          {% if state_attr('binary_sensor.hdd_smart', 'remaining_lifetime_perc') == None %}
            {{ state_attr('binary_sensor.hdd_smart', 'unknown_attribute_169') }}
          {% else %}
            {{ state_attr('binary_sensor.hdd_smart', 'remaining_lifetime_perc') }}
          {% endif %}

  - platform: template
    sensors:
      hdd_smart_power_on_hours:
        unit_of_measurement: "h."
        device_class: "duration"
        value_template: "{{  state_attr('binary_sensor.hdd_smart', 'power_on_hours') }}"

  - platform: template
    sensors:
      hdd_smart_temperature:
        unit_of_measurement: "°C"
        device_class: "temperature"
        value_template: "{{  state_attr('binary_sensor.hdd_smart', 'temperature_celsius') }}"
McGiverGim commented 2 years ago

Yes, the attributes will be updated each time. I close this issue now that it is fixed. If you want you can made a PR to add samples of sensors to the doc.