Ideas and automations¶
What you can do with the entities, with examples to copy. Each example is a
package: put the file into a
packages folder next to configuration.yaml and add
homeassistant:
packages: !include_dir_named packages
once, then restart. Or create the same automation in the editor (Settings, Automations, three
dots, Edit in YAML) from the part below automation:. Replace the entity IDs with yours (copy
them from the entity's settings; in another language than English they differ, see
Entities), and notify.mobile_app_phone with your phone's notify action.
For uplinks, trunks, slower ports, restarts and new devices there is a ready blueprint; the examples here are for single devices you care about.
A wired device lost its link¶
# A wired device lost its link for 5 minutes: its port's link sensor (here the NAS on trunk 1).
automation:
- alias: NAS link lost
triggers:
- trigger: state
entity_id: binary_sensor.switch_1_port_trk_1_link
to: "off"
for: {minutes: 5}
actions:
- action: notify.mobile_app_phone
data:
title: NAS offline
message: "Its port has had no link since {{ trigger.from_state.last_changed | as_local }}."
A port runs slower than it should¶
A cable with a broken pair or a dirty plug often still works, at 100 Mbit/s instead of 1 Gbit/s.
# A device that should run at 1 Gbit/s has been slower for 10 minutes: a cable or a port that
# negotiated 100 Mbit/s (here the desktop on switch 3, port 7).
automation:
- alias: Desktop port slow
triggers:
- trigger: numeric_state
entity_id: sensor.switch_3_port_7_speed
below: 1000
above: 0
for: {minutes: 10}
actions:
- action: notify.mobile_app_phone
data:
title: Desktop port slow
message: "It runs at {{ trigger.to_state.state }} Mbit/s."
A PoE device lost its power¶
# A PoE device no longer gets power (here whatever is plugged into switch 1, port 1).
automation:
- alias: PoE device without power
triggers:
- trigger: state
entity_id: sensor.switch_1_port_1_poe
from: delivering_power
for: {minutes: 2}
actions:
- action: notify.mobile_app_phone
data:
title: PoE device without power
message: "Port 1 PoE is now {{ trigger.to_state.state }}."
Something else is plugged into a port¶
# Something else is plugged into a port (here the printer port, switch 3, port 8).
automation:
- alias: Printer port changed
triggers:
- trigger: state
entity_id: sensor.switch_3_port_8_device
not_from: [unknown, unavailable]
not_to: [unavailable]
conditions:
- condition: template
value_template: "{{ trigger.from_state.state != trigger.to_state.state }}"
actions:
- action: notify.mobile_app_phone
data:
title: Printer port changed
message: "Was {{ trigger.from_state.state }}, now {{ trigger.to_state.state or 'nothing' }}."
A switch does not answer¶
# A switch does not answer for 10 minutes: its entities become unavailable (here switch 2,
# watched through its uplink port).
automation:
- alias: Switch unreachable
triggers:
- trigger: state
entity_id: binary_sensor.switch_2_port_7_link
to: unavailable
for: {minutes: 10}
actions:
- action: notify.mobile_app_phone
data:
title: Switch 2 unreachable
message: "It has not answered SNMP since {{ trigger.from_state.last_changed | as_local }}."
A port is busy for a long time¶
# A port is busy for 15 minutes, for example a backup running in the day (here the server's
# trunk; enable its "received" sensor first, it is off by default).
automation:
- alias: Server port busy
triggers:
- trigger: numeric_state
entity_id: sensor.switch_1_port_trk_2_received
above: 500
for: {minutes: 15}
actions:
- action: notify.mobile_app_phone
data:
title: Server port busy
message: "{{ trigger.to_state.state | round(0) }} Mbit/s for 15 minutes."
Every example is loaded by the demo instance (scripts/demo/run.py) on each start, so a change
that breaks one shows there.