forked from dashdrum/esphome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruuvi_deep_sleep.yaml
103 lines (90 loc) · 2.59 KB
/
ruuvi_deep_sleep.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
substitutions:
device_name: ruuvi_deep_sleep
upper_device_name: Ruuvi Deep Sleep
esphome:
name: $device_name
platform: ESP32
board: wemos_d1_mini32
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: $upper_device_name
password: !secret hotspot_password
captive_portal:
# Enable logging
logger:
level: DEBUG
# I'm not using the ESPHome API, but you certainly can
# api:
ota:
mqtt:
broker: !secret mqtt_broker
username: !secret mqtt_username
password: !secret mqtt_password
# Needed when using deep sleep mode
birth_message:
topic: " "
payload: disabled
will_message:
topic: " "
payload: disabled
globals:
- id: ruuvi_count
type: int
restore_value: no
initial_value: '0'
esp32_ble_tracker:
sensor:
- platform: ruuvitag
# MAC Address of Ruuvi Tag should include colon separators
mac_address: !secret trailer_fridge_ruuvi_mac
temperature:
name: $upper_device_name Temperature
expire_after: 60min
device_class: "temperature"
# Device will stay awake until Ruuvi values are received the 2nd time (or deep sleep timer is reached)
# Why the 2nd time? The on_value event triggers BEFORE the values are published in MQTT
on_value:
then:
- lambda: |-
ESP_LOGD("sleepy", " Temp Published!:");
id(ruuvi_count) += 1;
if(id(ruuvi_count) > 1 ){
id(deep_sleep_1).begin_sleep();
}
humidity:
name: $upper_device_name Humidity
expire_after: 60min
pressure:
name: $upper_device_name Pressure
expire_after: 60min
acceleration:
name: $upper_device_name Acceleration
expire_after: 60min
acceleration_x:
name: $upper_device_name Acceleration X
expire_after: 60min
acceleration_y:
name: $upper_device_name Acceleration Y
expire_after: 60min
acceleration_z:
name: $upper_device_name Acceleration Z
expire_after: 60min
battery_voltage:
name: $upper_device_name Battery Voltage
expire_after: 60min
tx_power:
name: $upper_device_name TX Power
expire_after: 60min
movement_counter:
name: $upper_device_name Movement Counter
expire_after: 60min
measurement_sequence_number:
name: $upper_device_name Measurement Sequence Number
expire_after: 60min
deep_sleep:
run_duration: 120s ## this is a long duration, trying to pickup the Ruuvi BLE beacon
sleep_duration: 15min
id: deep_sleep_1