1
0

Add router via SNMP

This commit is contained in:
Przemek Grondek 2022-08-14 01:37:41 +02:00
parent d6c21dd26f
commit 2353ffc71a
2 changed files with 102 additions and 10 deletions

View File

@ -1,15 +1,23 @@
- id: notify-slow-internet
alias: '[Notify] Slow internet'
- id: notify-slow-eth0
alias: '[Notify] Slow eth0 link'
mode: single
trigger:
- platform: numeric_state
entity_id: sensor.speedtest_download
for:
hours: 0
minutes: 30
seconds: 0
below: '110'
- platform: state
entity_id: sensor.router_eth0_link_speed
to: '100'
action:
- service: notify.mobile_app_iphone_pg
data:
message: Internet speed fell down to 100 Mbit
message: Internet link fell down to 100 Mbit
- id: notify-slow-eth4
alias: '[Notify] Slow eth4 link - WiFi'
mode: single
trigger:
- platform: state
entity_id: sensor.router_eth4_link_speed
to: '100'
action:
- service: notify.mobile_app_iphone_pg
data:
message: Wifi link speed fell down to 100 Mbit

View File

@ -446,6 +446,90 @@ sensor:
arg: "eth0"
- type: packets_out
arg: "eth0"
# SNMP
- platform: snmp
name: "Router eth0 link speed"
host: 192.168.60.1
community: home
baseoid: 1.3.6.1.2.1.2.2.1.5.4
accept_errors: true
unit_of_measurement: "Mbits"
value_template: "{{((value | int) / 1000000) | int}}"
- platform: snmp
name: "Router eth1 link speed"
host: 192.168.60.1
community: home
baseoid: 1.3.6.1.2.1.2.2.1.5.5
accept_errors: true
unit_of_measurement: "Mbits"
value_template: "{{((value | int) / 1000000) | int}}"
- platform: snmp
name: "Router eth2 link speed"
host: 192.168.60.1
community: home
baseoid: 1.3.6.1.2.1.2.2.1.5.6
accept_errors: true
unit_of_measurement: "Mbits"
value_template: "{{((value | int) / 1000000) | int}}"
- platform: snmp
name: "Router eth3 link speed"
host: 192.168.60.1
community: home
baseoid: 1.3.6.1.2.1.2.2.1.5.7
accept_errors: true
unit_of_measurement: "Mbits"
value_template: "{{((value | int) / 1000000) | int}}"
- platform: snmp
name: "Router eth4 link speed"
host: 192.168.60.1
community: home
baseoid: 1.3.6.1.2.1.2.2.1.5.8
accept_errors: true
unit_of_measurement: "Mbits"
value_template: "{{((value | int) / 1000000) | int}}"
- platform: snmp
version: 2c
name: "Router uptime"
host: 192.168.60.1
community: home
baseoid: 1.3.6.1.2.1.25.1.1.0
accept_errors: true
value_template: >-
{% set timetick = value | int %}
{% set minutes = ((timetick % 360000) / 6000) | int%}
{% set hours = ((timetick % 8640000) / 360000) | int %}
{% set days = (timetick / 8640000) | int %}
{%- if timetick < 6000 -%}
Less than a minute
{%- else -%}
{%- if days > 0 -%}
{%- if days == 1 -%}
1 day
{%- else -%}
{{ days }} days
{%- endif -%}
{%- endif -%}
{%- if hours > 0 -%}
{%- if days > 0 -%}
{{ ', ' }}
{%- endif -%}
{%- if hours == 1 -%}
1 hr
{%- else -%}
{{ hours }} hrs
{%- endif -%}
{%- endif -%}
{%- if minutes > 0 -%}
{%- if days > 0 or hours > 0 -%}
{{ ', ' }}
{%- endif -%}
{%- if minutes == 1 -%}
1 min
{%- else -%}
{{ minutes }} min
{%- endif -%}
{%- endif -%}
{%- endif -%}
# Power
- platform: integration
name: "3D printer energy Total"