MKANET

Untitled

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