diff --git a/automations.yaml b/automations.yaml index 3905ccf..06bdbf1 100644 --- a/automations.yaml +++ b/automations.yaml @@ -343,30 +343,6 @@ - schlafzimmer - wohnzimmer mode: single -- id: snmp_monitor_traffic_in - alias: Monitor Traffic In - trigger: - platform: state - entity_id: sensor.snmp_wan_in - action: - - service: input_number.set_value - data_template: - entity_id: input_number.internet_traffic_delta_in - value: '{{ ((trigger.to_state.state | int - trigger.from_state.state | int) - * 8 ) / ( as_timestamp(trigger.to_state.last_updated) - as_timestamp(trigger.from_state.last_updated) - ) }}' -- id: snmp_monitor_traffic_out - alias: Monitor Traffic Out - trigger: - platform: state - entity_id: sensor.snmp_wan_out - action: - - service: input_number.set_value - data_template: - entity_id: input_number.internet_traffic_delta_out - value: '{{ ((trigger.to_state.state | int - trigger.from_state.state | int) - * 8 ) / ( as_timestamp(trigger.to_state.last_updated) - as_timestamp(trigger.from_state.last_updated) - ) }}' - id: '1632477389492' alias: Licht beim Heimkommen einschalten description: Nur während Dunkelphase diff --git a/configuration.yaml b/configuration.yaml index a10cd21..52cb63b 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -31,11 +31,9 @@ wake_on_lan: homeassistant: customize: !include customize.yaml -# Include helpers -input_number: !include input_number.yaml - # Additional sensors sensor: !include sensors.yaml +utility_meter: !include utility_meters.yaml # MQTT sensors mqtt: !include mqtt.yaml @@ -93,7 +91,7 @@ bluetooth: # Bluetooth Low Energy tracker device_tracker: - platform: bluetooth_le_tracker - # track_new_devices: true + track_new_devices: true # Configure MPD addon as media player media_player: diff --git a/input_number.yaml b/input_number.yaml deleted file mode 100644 index fe57db3..0000000 --- a/input_number.yaml +++ /dev/null @@ -1,11 +0,0 @@ - internet_traffic_delta_in: - name: "Traffic IN Delta" - initial: 0 - min: 0 - max: 1000000000000 - - internet_traffic_delta_out: - name: "Traffic OUT Delta" - initial: 0 - min: 0 - max: 1000000000000 diff --git a/recorder.yaml b/recorder.yaml index 8cc2fd2..0d124a9 100644 --- a/recorder.yaml +++ b/recorder.yaml @@ -30,10 +30,6 @@ - sensor.fritzbox_device_uptime - sensor.snmp_wan_in - sensor.snmp_wan_out - - input_number.internet_traffic_delta_in - - input_number.internet_traffic_delta_out - - automation.monitor_traffic_in - - automation.monitor_traffic_out - sensor.time # event_types: # - call_service # Don't record service calls diff --git a/sensors.yaml b/sensors.yaml index 502eba4..ff1d597 100644 --- a/sensors.yaml +++ b/sensors.yaml @@ -21,31 +21,39 @@ query: 'SELECT table_schema "database", Round(Sum(data_length + index_length) / 1048576, 2) "value" FROM information_schema.tables WHERE table_schema="homeassistant" GROUP BY table_schema;' column: 'value' unit_of_measurement: MB + # SNMP (Juniper) router traffic sensor - platform: snmp name: snmp_wan_in host: !secret router_ip community: !secret router_community baseoid: .1.3.6.1.2.1.2.2.1.10.511 - - platform: snmp name: snmp_wan_out host: !secret router_ip community: !secret router_community baseoid: .1.3.6.1.2.1.2.2.1.16.511 + - platform: derivative + source: sensor.snmp_wan_in + unit_time: s + unit: B + name: wan_in_derivative + - platform: derivative + source: sensor.snmp_wan_out + unit_time: s + unit: B + name: wan_out_derivative + - platform: template sensors: internet_speed_in: friendly_name: 'Internet Speed IN' - value_template: '{{ ((states.input_number.internet_traffic_delta_in.state | float ) / 1000000 ) | round(2) }}' + value_template: "{{ (( states('sensor.wan_in_derivative') | float * 8 / 1000000 ) | round(2)) }}" unit_of_measurement: 'Mbps' - - - platform: template - sensors: internet_speed_out: friendly_name: 'Internet Speed OUT' - value_template: '{{ ((states.input_number.internet_traffic_delta_out.state | float ) / 1000000 ) | round(2) }}' + value_template: "{{ (( states('sensor.wan_out_derivative') | float * 8 / 1000000 ) | round(2)) }}" unit_of_measurement: 'Mbps' - platform: statistics @@ -53,7 +61,6 @@ state_characteristic: mean entity_id: sensor.internet_speed_in sampling_size: 10 - - platform: statistics name: 'WAN Traffic Out' state_characteristic: mean @@ -71,3 +78,4 @@ sun_setting_template: friendly_name: "Sun Setting Template" value_template: "{{ as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom ('%H:%M') }}" +