From 2502d74e956a3455cad5541e960831c1f29029e6 Mon Sep 17 00:00:00 2001 From: CCOSTAN Date: Fri, 10 Feb 2017 16:00:15 +0000 Subject: [PATCH] ADD in system Monitor stuff to watch hard drives. --- automation/watchdog.yaml | 23 ++++++++ sensor/systemmonitor.yaml | 118 +++++++++++++++++++------------------- 2 files changed, 83 insertions(+), 58 deletions(-) diff --git a/automation/watchdog.yaml b/automation/watchdog.yaml index 2175d539..eef8cd9c 100755 --- a/automation/watchdog.yaml +++ b/automation/watchdog.yaml @@ -75,3 +75,26 @@ - service: script.Voice_notify data_template: value1: "There has been a new device detected on the network. Be sure to appropriately catagorize it within Circle." + +############################################################################## + +- alias: "Disk Use Alarm" + trigger: + - platform: numeric_state + entity_id: sensor.disk_use_percent + above: 30.4 + action: + - service: script.Voice_notify + data_template: + value1: 'Your harddrive has run out of Space! /dev/root:{{ states.sensor.disk_use_.state }}%!' + - service: script.ifttt_notify + data_template: + value1: 'Hard Drive Monitor:' + value2: "Your harddrive has run out of Space! /dev/root:{{ states.sensor.disk_use_.state }}%!" + value3: ' ' + + - service: persistent_notification.create + data: + title: "Hard Drive Monitor:" + message: "Your harddrive has run out of Space! /dev/root:{{ states.sensor.disk_use_.state }}%!" + notification_id: "Critical Alert" \ No newline at end of file diff --git a/sensor/systemmonitor.yaml b/sensor/systemmonitor.yaml index 192699bf..8e20d970 100755 --- a/sensor/systemmonitor.yaml +++ b/sensor/systemmonitor.yaml @@ -1,59 +1,61 @@ -- platform: systemmonitor - resources: - # - type: last_boot - - type: since_last_boot - -- platform: template - sensors: - since_last_boot_templated: - value_template: >- - {%- set slb = states.sensor.since_last_boot.state.split(' ') -%} - {%- set count = slb | length -%} - {%- set hms = slb[count - 1] -%} - {%- set hms_trimmed = hms.split('.')[0] -%} - {%- set hms_split = hms_trimmed.split(':') -%} - {%- set hours = hms_split[0] | int -%} - {%- set minutes = hms_split[1] | int -%} - {%- set seconds = hms_split[2] | int -%} - - {%- if count == 3 -%} - {{ slb[0] ~ ' ' ~ slb[1] ~ ' ' }} - {%- endif -%} - {%- if hours > 0 -%} - {%- if hours == 1 -%} - 1 hour - {%- else -%} - {{ hours }} hours - {%- endif -%} - {%- endif -%} - {%- if minutes > 0 -%} - {%- if hours > 0 -%} - {{ ', ' }} - {%- endif -%} - {%- if minutes == 1 -%} - 1 minute - {%- else -%} - {{ minutes }} minutes - {%- endif -%} - {%- endif -%} - {%- if seconds > 0 -%} - {%- if hours > 0 or minutes > 0 -%} - {{ ', ' }} - {%- endif -%} - {%- if seconds == 1 -%} - 1 second - {%- else -%} - {{ seconds }} seconds - {%- endif -%} - {%- endif -%} - -- platform: rest - resource: http://ip.jsontest.com - name: External IP - value_template: '{{ value_json.ip }}' - -- platform: template - sensors: - ipchange: - entity_id: sensor.external_ip +- platform: systemmonitor + resources: + # - type: last_boot + - type: since_last_boot + - type: disk_use_percent + arg: / + +- platform: template + sensors: + since_last_boot_templated: + value_template: >- + {%- set slb = states.sensor.since_last_boot.state.split(' ') -%} + {%- set count = slb | length -%} + {%- set hms = slb[count - 1] -%} + {%- set hms_trimmed = hms.split('.')[0] -%} + {%- set hms_split = hms_trimmed.split(':') -%} + {%- set hours = hms_split[0] | int -%} + {%- set minutes = hms_split[1] | int -%} + {%- set seconds = hms_split[2] | int -%} + + {%- if count == 3 -%} + {{ slb[0] ~ ' ' ~ slb[1] ~ ' ' }} + {%- endif -%} + {%- if hours > 0 -%} + {%- if hours == 1 -%} + 1 hour + {%- else -%} + {{ hours }} hours + {%- endif -%} + {%- endif -%} + {%- if minutes > 0 -%} + {%- if hours > 0 -%} + {{ ', ' }} + {%- endif -%} + {%- if minutes == 1 -%} + 1 minute + {%- else -%} + {{ minutes }} minutes + {%- endif -%} + {%- endif -%} + {%- if seconds > 0 -%} + {%- if hours > 0 or minutes > 0 -%} + {{ ', ' }} + {%- endif -%} + {%- if seconds == 1 -%} + 1 second + {%- else -%} + {{ seconds }} seconds + {%- endif -%} + {%- endif -%} + +- platform: rest + resource: http://ip.jsontest.com + name: External IP + value_template: '{{ value_json.ip }}' + +- platform: template + sensors: + ipchange: + entity_id: sensor.external_ip value_template: "{%- if is_state('sensor.external_ip', '!secret external_ip') -%} False {%- else -%} True {%- endif %}" \ No newline at end of file