Files
Home-AssistantConfig/config/packages/speedtest.yaml

75 lines
2.8 KiB
YAML

######################################################################
# @CCOSTAN - Follow Me on X
# For more info visit https://www.vcloudinfo.com/click-here
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# -------------------------------------------------------------------
# Speedtest Alerts - Log internet speed drops/restores to Activity feed
# Related Issue: 1550
# Uses `script.send_to_logbook` + `sensor.activity_feed`.
# -------------------------------------------------------------------
######################################################################
automation:
- alias: "Internet Speed is Slow (Logbook)"
id: notify-carlo-slow-internet-speed
description: "Logs an Activity entry if download or upload speed falls below 300 Mbps."
trigger:
- platform: numeric_state
entity_id: sensor.speedtest_download
below: 300
- platform: numeric_state
entity_id: sensor.speedtest_upload
below: 300
condition:
- condition: state
entity_id: group.bed
state: 'off'
- condition: template # Checks to make sure the system hasn't been restarted in the past 10 minutes
value_template: >-
{% set uptime = states('sensor.ha_uptime') | as_datetime %}
{% set now = now() %}
{{ (now - uptime).total_seconds() / 60 >= 10 }}
action:
- service: script.send_to_logbook
data:
topic: "NETWORK"
message: >-
Download: {{ states('sensor.speedtest_download') }} Mbps,
Upload: {{ states('sensor.speedtest_upload') }} Mbps.
One or both speeds are below 300 Mbps.
mode: single
- alias: "Internet Speed Restored (Logbook)"
id: notify-carlo-internet-speed-restored
description: "Logs an Activity entry when download and upload speeds are back above 300/300 Mbps."
trigger:
- platform: numeric_state
entity_id: sensor.speedtest_download
above: 300
- platform: numeric_state
entity_id: sensor.speedtest_upload
above: 300
condition:
- condition: numeric_state
entity_id: sensor.speedtest_download
above: 300
- condition: numeric_state
entity_id: sensor.speedtest_upload
above: 300
- condition: template # Checks to make sure the system hasn't been restarted in the past 10 minutes
value_template: >-
{% set uptime = states('sensor.ha_uptime') | as_datetime %}
{% set now = now() %}
{{ (now - uptime).total_seconds() / 60 >= 10 }}
action:
- service: script.send_to_logbook
data:
topic: "NETWORK"
message: >-
Download: {{ states('sensor.speedtest_download') }} Mbps,
Upload: {{ states('sensor.speedtest_upload') }} Mbps.
Internet speeds are back to normal.
mode: single