-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathinfluxdb.yaml
70 lines (66 loc) · 1.93 KB
/
influxdb.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
# An example to send results to influxdb.
substitutions:
my_name: influxdb-example
my_location: somewhere
influxdb_host: influxdb.example.org
influxdb_port: "8086"
influxdb_user: !secret influxdb_user
influxdb_password: !secret influxdb_password
influxdb_database: my_database
target_ip_address: 8.8.4.4
globals:
- id: buf
type: char[512]
restore_value: no
initial_value: ""
esphome:
name: ${my_name}
platform: ESP8266
board: nodemcuv2
libraries:
- ESP8266WiFi
- https://github.com/akaJes/AsyncPing#95ac7e4
logger:
ota:
password: !secret ota_password
api:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: ${my_name}
password: !secret wifi_ap_password
external_components:
- source:
type: local
path: ../components
http_request:
useragent: esphome/${my_name}
timeout: 10s
sensor:
- platform: ping
ip_address: ${target_ip_address}
num_attempts: 17
timeout: 1sec
loss:
name: Packet loss
id: loss
on_value:
then:
- http_request.post:
url: "http://${influxdb_host}:${influxdb_port}/write?db=${influxdb_database}&u=${influxdb_user}&p=${influxdb_password}"
body: !lambda |-
snprintf(id(buf), sizeof(id(buf)), "ping,location=${my_location},host=${my_name},url=${target_ip_address} percent_packet_loss=%0.1f", id(loss).state);
return id(buf);
latency:
name: Latency
accuracy_decimals: 3
id: latency
on_value:
then:
- http_request.post:
url: "http://${influxdb_host}:${influxdb_port}/write?db=${influxdb_database}&u=${influxdb_user}&p=${influxdb_password}"
body: !lambda |-
snprintf(id(buf), sizeof(id(buf)), "ping,location=${my_location},host=${my_name},url=${target_ip_address} average_response_ms=%0.1f", id(latency).state * 1000);
return id(buf);