2019-04-17 22:46:06 +00:00
|
|
|
###############################################################################
|
|
|
|
# @author : Mahasri Kalavala
|
|
|
|
# @date : 07/16/2017
|
|
|
|
# @package : QNAP
|
|
|
|
# @description : QNAP NAS Package
|
|
|
|
###############################################################################
|
|
|
|
homeassistant:
|
|
|
|
customize:
|
|
|
|
sensor.kalavala_nas_cpu_usage:
|
|
|
|
friendly_name: CPU Usage
|
|
|
|
sensor.kalavala_nas_memory_usage:
|
|
|
|
friendly_name: Memory Usage
|
|
|
|
sensor.kalavala_nas_network_up_eth0:
|
|
|
|
friendly_name: Network Speed
|
|
|
|
sensor.kalavala_nas_network_up_eth1:
|
|
|
|
friendly_name: Network Speed
|
|
|
|
sensor.kalavala_nas_status:
|
|
|
|
friendly_name: NAS Status
|
|
|
|
sensor.kalavala_nas_volume_used_datavol1:
|
|
|
|
friendly_name: Percent Disk Used
|
|
|
|
sensor.kalavala_nas_system_temperature:
|
|
|
|
friendly_name: System Temperature
|
|
|
|
sensor.kalavala_nas_cpu_temperature:
|
|
|
|
friendly_name: CPU Temperature
|
|
|
|
sensor.nas_memory_usage_above_80:
|
|
|
|
friendly_name: Is Memory Above 80 Percent?
|
|
|
|
hidden: true
|
|
|
|
sensor.nas_cpu_usage_above_80:
|
|
|
|
friendly_name: Is CPU Above 80 Percent?
|
|
|
|
hidden: true
|
|
|
|
|
|
|
|
sensor.kalavala_nas_smart_status_drive_0_1:
|
|
|
|
friendly_name: Drive 1 Status
|
|
|
|
sensor.kalavala_nas_smart_status_drive_0_2:
|
|
|
|
friendly_name: Drive 2 Status
|
|
|
|
sensor.kalavala_nas_smart_status_drive_0_3:
|
|
|
|
friendly_name: Drive 3 Status
|
|
|
|
sensor.kalavala_nas_smart_status_drive_0_4:
|
|
|
|
friendly_name: Drive 4 Status
|
2022-12-03 16:28:12 +00:00
|
|
|
|
2019-04-17 22:46:06 +00:00
|
|
|
sensor.kalavala_nas_temperature_drive_0_1:
|
|
|
|
friendly_name: Drive 1 Temperature
|
|
|
|
sensor.kalavala_nas_temperature_drive_0_2:
|
|
|
|
friendly_name: Drive 2 Temperature
|
|
|
|
sensor.kalavala_nas_temperature_drive_0_3:
|
|
|
|
friendly_name: Drive 3 Temperature
|
|
|
|
sensor.kalavala_nas_temperature_drive_0_4:
|
|
|
|
friendly_name: Drive 4 Temperature
|
|
|
|
|
|
|
|
sensor:
|
|
|
|
- platform: qnap
|
|
|
|
host: !secret qnap_hostname
|
|
|
|
username: !secret qnap_username
|
|
|
|
password: !secret qnap_password
|
|
|
|
monitored_conditions:
|
|
|
|
- status
|
|
|
|
- cpu_usage
|
|
|
|
- memory_percent_used
|
|
|
|
- network_tx
|
|
|
|
- volume_percentage_used
|
|
|
|
- system_temp
|
|
|
|
- cpu_temp
|
|
|
|
- drive_smart_status
|
|
|
|
- drive_temp
|
|
|
|
|
2021-01-10 20:03:52 +00:00
|
|
|
- platform: qnap
|
|
|
|
host: !secret qnap_hostname2
|
|
|
|
username: !secret qnap_username
|
|
|
|
password: !secret qnap_password
|
|
|
|
monitored_conditions:
|
|
|
|
- status
|
|
|
|
- cpu_usage
|
|
|
|
- memory_percent_used
|
|
|
|
- network_tx
|
|
|
|
- volume_percentage_used
|
|
|
|
- system_temp
|
|
|
|
- cpu_temp
|
|
|
|
- drive_smart_status
|
|
|
|
- drive_temp
|
|
|
|
|
2022-12-03 16:28:12 +00:00
|
|
|
# The following sensors are required, as the automations with trigger platform `numeric_state`,
|
|
|
|
# above a certain value using `above: x` AND `for: 00:05:00` combination is not supported.
|
|
|
|
#
|
|
|
|
# Apparently `for:` is ONLY supportd for trigger platform 'state'
|
|
|
|
#
|
|
|
|
# By creating the folowing sensor, we can now have an automation with trigger platform as 'state'
|
|
|
|
# with a combination of `to:` and `for:`
|
|
|
|
#
|
|
|
|
# See the automations 'Notify NAS Memory Usage' and 'Notify NAS CPU Usage' that uses these sensor values
|
2019-04-17 22:46:06 +00:00
|
|
|
|
|
|
|
- platform: template
|
|
|
|
sensors:
|
|
|
|
nas_memory_usage_above_80:
|
2019-12-20 15:32:28 +00:00
|
|
|
value_template: "{{ states('sensor.kalavala_nas_memory_usage') | int > 80 }}"
|
2019-04-17 22:46:06 +00:00
|
|
|
|
|
|
|
- platform: template
|
|
|
|
sensors:
|
|
|
|
nas_cpu_usage_above_80:
|
2019-12-20 15:32:28 +00:00
|
|
|
value_template: "{{ states('sensor.kalavala_nas_cpu_usage') | int > 80 }}"
|
2019-04-17 22:46:06 +00:00
|
|
|
|
|
|
|
###############################################################################
|
2022-12-03 16:28:12 +00:00
|
|
|
# _ _ _
|
|
|
|
# /\ | | | | (_)
|
|
|
|
# / \ _ _| |_ ___ _ __ ___ __ _| |_ _ ___ _ __ ___
|
2019-04-17 22:46:06 +00:00
|
|
|
# / /\ \| | | | __/ _ \| '_ ` _ \ / _` | __| |/ _ \| '_ \/ __|
|
|
|
|
# / ____ \ |_| | || (_) | | | | | | (_| | |_| | (_) | | | \__ \
|
|
|
|
# /_/ \_\__,_|\__\___/|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/
|
2022-12-03 16:28:12 +00:00
|
|
|
#
|
2019-04-17 22:46:06 +00:00
|
|
|
###############################################################################
|
|
|
|
automation:
|
|
|
|
- alias: Notify NAS Status Change
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: state
|
2022-12-03 16:28:12 +00:00
|
|
|
entity_id:
|
|
|
|
- sensor.kalavala_nas_status
|
2019-04-17 22:46:06 +00:00
|
|
|
condition:
|
|
|
|
- condition: template
|
|
|
|
value_template: "{{ trigger.from_state.state != trigger.to_state.state }}"
|
|
|
|
action:
|
2022-12-03 16:28:12 +00:00
|
|
|
- service: script.notify_family
|
2022-12-05 00:02:34 +00:00
|
|
|
data:
|
2019-04-17 22:46:06 +00:00
|
|
|
message: "NAS Status changed to: {{ trigger.to_state.state| upper }}"
|
2022-12-03 16:28:12 +00:00
|
|
|
notify_options:
|
|
|
|
- telegram
|
|
|
|
- tv
|
2019-04-17 22:46:06 +00:00
|
|
|
|
|
|
|
- alias: Notify NAS Drive Status Change
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: state
|
2022-12-03 16:28:12 +00:00
|
|
|
entity_id:
|
|
|
|
- sensor.kalavala_nas_smart_status_drive_01
|
|
|
|
- sensor.kalavala_nas_smart_status_drive_02
|
|
|
|
- sensor.kalavala_nas_smart_status_drive_03
|
|
|
|
- sensor.kalavala_nas_smart_status_drive_04
|
2019-04-17 22:46:06 +00:00
|
|
|
condition:
|
|
|
|
- condition: template
|
2022-12-03 16:28:12 +00:00
|
|
|
value_template: "{{ trigger.from_state.state != trigger.to_state.state }}"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
2022-12-03 16:28:12 +00:00
|
|
|
- service: script.notify_family
|
2022-12-05 00:02:34 +00:00
|
|
|
data:
|
2022-12-03 16:28:12 +00:00
|
|
|
message: "NAS Drive state changed to: {{ trigger.to_state.state| upper }} from '{{ trigger.from_state.state| upper }}'"
|
|
|
|
notify_options:
|
|
|
|
- telegram
|
|
|
|
- tv
|
2019-04-17 22:46:06 +00:00
|
|
|
|
|
|
|
- alias: Notify NAS CPU Temperature
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: numeric_state
|
2022-12-03 16:28:12 +00:00
|
|
|
entity_id: sensor.kalavala_nas_cpu_temperature
|
2019-04-17 22:46:06 +00:00
|
|
|
above: 125
|
|
|
|
action:
|
2022-12-03 16:28:12 +00:00
|
|
|
- service: script.notify_family
|
2022-12-05 00:02:34 +00:00
|
|
|
data:
|
2022-12-03 16:28:12 +00:00
|
|
|
message: "NAS CPU temperature is going crazy hot, needs your attention!!! Current cpu temp is: {{ trigger.to_state.state }}"
|
|
|
|
notify_options:
|
|
|
|
- telegram
|
|
|
|
- tv
|
2019-04-17 22:46:06 +00:00
|
|
|
|
|
|
|
- alias: Notify NAS Disk Usage
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: numeric_state
|
2022-12-03 16:28:12 +00:00
|
|
|
entity_id: sensor.kalavala_nas_volume_used_datavol1
|
2019-04-17 22:46:06 +00:00
|
|
|
above: 80
|
|
|
|
action:
|
2022-12-03 16:28:12 +00:00
|
|
|
- service: script.notify_family
|
2022-12-05 00:02:34 +00:00
|
|
|
data:
|
2019-04-17 22:46:06 +00:00
|
|
|
message: "Attention! NAS disk usage is above 80 percent. Time to clean up?"
|
2022-12-03 16:28:12 +00:00
|
|
|
notify_options:
|
|
|
|
- telegram
|
|
|
|
- tv
|
2019-04-17 22:46:06 +00:00
|
|
|
|
|
|
|
- alias: Notify NAS Memory Usage
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: state
|
|
|
|
entity_id: sensor.nas_memory_usage_above_80
|
2022-12-03 16:28:12 +00:00
|
|
|
to: "True"
|
|
|
|
for: "00:05:00"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
2022-12-03 16:28:12 +00:00
|
|
|
- service: script.notify_family
|
2022-12-05 00:02:34 +00:00
|
|
|
data:
|
2019-04-17 22:46:06 +00:00
|
|
|
message: "FYI - NAS Memory is above 80 percent for more than 5 minutes."
|
2022-12-03 16:28:12 +00:00
|
|
|
notify_options:
|
|
|
|
- telegram
|
|
|
|
- tv
|
2019-04-17 22:46:06 +00:00
|
|
|
|
|
|
|
- alias: Notify NAS CPU Usage
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: state
|
2022-12-03 16:28:12 +00:00
|
|
|
entity_id: sensor.nas_cpu_usage_above_80
|
|
|
|
to: "True"
|
|
|
|
for: "00:05:00"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
2022-12-03 16:28:12 +00:00
|
|
|
- service: script.notify_family
|
2022-12-05 00:02:34 +00:00
|
|
|
data:
|
2019-04-17 22:46:06 +00:00
|
|
|
message: "FYI - NAS CPU is above 80 percent for more than 5 minutes."
|
2022-12-03 16:28:12 +00:00
|
|
|
notify_options:
|
|
|
|
- telegram
|
|
|
|
- tv
|