MKANET

Untitled

Feb 9th, 2021
1,502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 8.29 KB | None | 0 0
  1. sensor:
  2.   - platform: systemmonitor
  3.     resources:
  4.       - type: disk_use_percent
  5.         arg: /home
  6.       - type: memory_use
  7.       - type: memory_use_percent
  8.       - type: processor_use
  9.   - platform: rest
  10.     resource: http://192.168.1.2:61208/api/3/uptime
  11.     value_template: '{{ value_json | regex_replace(find="[\"]", replace="") | regex_replace(find="(?<=( (\d{1})|(\d{2})):\d{2}):\d{2}", replace=" hours") }}'
  12.    name: Horizon Uptime
  13.    verify_ssl: false
  14.    timeout: 30
  15.    scan_interval: 16
  16.  - platform: rest
  17.    resource: http://192.168.1.2:61208/api/3/cpu
  18.    name: Horizon CPU
  19.    value_template: '{{ value_json.total | round }}'
  20.    unit_of_measurement: "%"
  21.     verify_ssl: false
  22.     timeout: 30
  23.     scan_interval: 16
  24.   - platform: rest
  25.     resource: http://192.168.1.2:61208/api/3/mem
  26.     name: Horizon RAM
  27.     value_template: '{{ value_json.percent | round }}'
  28.     unit_of_measurement: "%"
  29.     verify_ssl: false
  30.     timeout: 30
  31.     scan_interval: 16
  32.   - platform: rest
  33.     resource: http://192.168.1.2:61208/api/3/memswap
  34.     name: Horizon Pagefile
  35.     value_template: '{{ value_json.percent | round }}'
  36.     unit_of_measurement: "%"
  37.     verify_ssl: false
  38.     timeout: 30
  39.     scan_interval: 16
  40.   - platform: rest
  41.     name: gpu
  42.     resource: http://192.168.1.2:61208/api/3/gpu
  43.     value_template: '{{ ( value_json ) }}'
  44.     json_attributes:
  45.      - name
  46.       - mem
  47.       - proc
  48.       - temperature
  49.     verify_ssl: false
  50.     timeout: 30
  51.     scan_interval: 16
  52.   - platform: rest
  53.     name: network
  54.     resource: http://192.168.1.2:61208/api/3/network
  55.     value_template: N/A
  56.     json_attributes:
  57.      - interface_name
  58.       - time_since_update
  59.       # - cumulative_rx
  60.       - rx
  61.       # - cumulative_tx
  62.       - tx
  63.       # - cumulative_cx
  64.       - cx
  65.       # - is_up
  66.       # - speed
  67.     verify_ssl: false
  68.     timeout: 30
  69.     scan_interval: 16
  70.   - platform: rest
  71.     resource: http://192.168.1.2:61208/api/3/fs
  72.     name: Horizon C Drive Used
  73.     value_template: '{{ value_json[0].percent | round }}'
  74.     unit_of_measurement: "%"
  75.     verify_ssl: false
  76.     timeout: 30
  77.     scan_interval: 16
  78.   - platform: rest
  79.     resource: http://192.168.1.2:61208/api/3/fs
  80.     name: Horizon E Drive Used
  81.     value_template: '{{ value_json[1].percent | round }}'
  82.     unit_of_measurement: "%"
  83.     verify_ssl: false
  84.     timeout: 30
  85.     scan_interval: 16
  86.   - platform: rest
  87.     name: diskio_0
  88.     resource: http://192.168.1.2:61208/api/3/diskio
  89.     value_template: '{{ ( value_json[0] ) }}'
  90.     json_attributes_path: "$.0"
  91.     json_attributes:
  92.      - time_since_update
  93.       - disk_name
  94.       # - read_count
  95.       # - write_count
  96.       - read_bytes
  97.       - write_bytes
  98.     verify_ssl: false
  99.     timeout: 30
  100.     scan_interval: 16
  101.   - platform: rest
  102.     name: diskio_1
  103.     resource: http://192.168.1.2:61208/api/3/diskio
  104.     value_template: '{{ ( value_json[1] ) }}'
  105.     json_attributes_path: "$.1"
  106.     json_attributes:
  107.      - time_since_update
  108.       - disk_name
  109.       # - read_count
  110.       # - write_count
  111.       - read_bytes
  112.       - write_bytes
  113.     verify_ssl: false
  114.     timeout: 30
  115.     scan_interval: 16
  116.  
  117. #Respective Templates for REST sensors:
  118.  
  119.   - platform: template
  120.     sensors:
  121.       horizon_c_drive_read_bytes:
  122.         value_template: >-
  123.                 {% set read_byte = state_attr('sensor.diskio_0', 'read_bytes') %}
  124.                 {% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
  125.                 {% if (read_byte != None ) and (time_since != None ) %}
  126.                   {{ ((read_byte | int) / (time_since | int) / 1000000) | round (2) }}
  127.                 {% endif %}
  128.         availability_template: >-
  129.                 {{ states("sensor.diskio_0") not in ["unknown", "unavailable"] }}
  130.         unit_of_measurement: 'MB/s'
  131.   - platform: template
  132.     sensors:
  133.       horizon_c_drive_write_bytes:
  134.         value_template: >-
  135.                 {% set write_byte = state_attr('sensor.diskio_0', 'write_bytes') %}
  136.                 {% set time_since = state_attr('sensor.diskio_0', 'time_since_update') %}
  137.                 {% if (write_byte != None ) and (time_since != None ) %}
  138.                   {{ ((write_byte | int) / (time_since | int) / 1000000) | round (2) }}
  139.                 {% endif %}
  140.         availability_template: >-
  141.                 {{ states("sensor.diskio_0") not in ["unknown", "unavailable"] }}
  142.         unit_of_measurement: 'MB/s'
  143.   - platform: template
  144.     sensors:
  145.       horizon_e_drive_read_bytes:
  146.         value_template: >-
  147.                 {% set read_byte = state_attr('sensor.diskio_1', 'read_bytes') %}
  148.                 {% set time_since = state_attr('sensor.diskio_1', 'time_since_update') %}
  149.                 {% if (read_byte != None ) and (time_since != None ) %}
  150.                   {{ ((read_byte | int) / (time_since | int) / 1000000) | round (2) }}
  151.                 {% endif %}
  152.         availability_template: >-
  153.                 {{ states("sensor.diskio_1") not in ["unknown", "unavailable"] }}
  154.         unit_of_measurement: 'MB/s'
  155.   - platform: template
  156.     sensors:
  157.       horizon_e_drive_write_bytes:
  158.         value_template: >-
  159.                 {% set write_byte = state_attr('sensor.diskio_1', 'write_bytes') %}
  160.                 {% set time_since = state_attr('sensor.diskio_1', 'time_since_update') %}
  161.                 {% if (write_byte != None ) and (time_since != None ) %}
  162.                   {{ ((write_byte | int) / (time_since | int) / 1000000) | round (2) }}
  163.                 {% endif %}
  164.         availability_template: >-
  165.                 {{ states("sensor.diskio_1") not in ["unknown", "unavailable"] }}
  166.         unit_of_measurement: 'MB/s'
  167.   - platform: template
  168.     sensors:
  169.       horizon_gpu_name:
  170.         value_template: '{{ state_attr("sensor.gpu", "name") }}'
  171.         # value_template: '{{ states.sensor.gpu.attributes["name"] }}'
  172.   - platform: template
  173.     sensors:
  174.       horizon_gpu_memory:
  175.         value_template: '{{ state_attr("sensor.gpu", "mem") | round }}'
  176.         # value_template: '{{ states.sensor.gpu.attributes["mem"] | round }}'
  177.         unit_of_measurement: "%"
  178.   - platform: template
  179.     sensors:
  180.       horizon_gpu_processor:
  181.         value_template: '{{ state_attr("sensor.gpu", "proc") }}'
  182.         # value_template: '{{ states.sensor.gpu.attributes["proc"] }}'
  183.         unit_of_measurement: "%"
  184.   - platform: template
  185.     sensors:
  186.       horizon_gpu_temperature:
  187.         value_template: '{{ state_attr("sensor.gpu", "temperature") }}'
  188.         # value_template: '{{ states.sensor.gpu.attributes["temperature"] }}'
  189.         unit_of_measurement: "°C"
  190.   - platform: template
  191.     sensors:
  192.       horizon_download_speed:
  193.         value_template: >-
  194.                 {% set receive = state_attr('sensor.network', 'rx') %}
  195.                 {% set time_since = state_attr('sensor.network', 'time_since_update') %}
  196.                 {% if (receive != None ) and (time_since != None ) %}
  197.                   {{ ((receive | int) / (time_since | int) * 8 / 1000000) | round (2) }}
  198.                 {% endif %}
  199.         availability_template: >-
  200.                 {{ states("sensor.network") not in ["unknown", "unavailable"] }}
  201.         unit_of_measurement: 'MB/s'
  202.   - platform: template
  203.     sensors:
  204.       horizon_upload_speed:
  205.         value_template: >-
  206.                 {% set transmit = state_attr('sensor.network', 'tx') %}
  207.                 {% set time_since = state_attr('sensor.network', 'time_since_update') %}
  208.                 {% if (transmit != None ) and (time_since != None ) %}
  209.                   {{ ((transmit | int) / (time_since | int) * 8 / 1000000) | round (2) }}
  210.                 {% endif %}
  211.         availability_template: >-
  212.                 {{ states("sensor.network") not in ["unknown", "unavailable"] }}
  213.         unit_of_measurement: 'MB/s'
  214.   - platform: template
  215.     sensors:
  216.       horizon_total_speed:
  217.         value_template: >-
  218.                 {% set total = state_attr('sensor.network', 'cx') %}
  219.                 {% set time_since = state_attr('sensor.network', 'time_since_update') %}
  220.                 {% if (total != None ) and (time_since != None ) %}
  221.                   {{ ((total | int) / (time_since | int) * 8 / 1000000) | round (2) }}
  222.                 {% endif %}
  223.         availability_template: >-
  224.                 {{ states("sensor.network") not in ["unknown", "unavailable"] }}
  225.         unit_of_measurement: 'MB/s'
Advertisement
Add Comment
Please, Sign In to add comment