Redid wan traffic collection and replaced the old clumsy way. Added usage_meters.
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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: | ||||
|   | ||||
| @@ -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 | ||||
| @@ -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 | ||||
|   | ||||
							
								
								
									
										22
									
								
								sensors.yaml
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								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') }}" | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user