-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.yaml
141 lines (127 loc) · 3.42 KB
/
example.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
esphome:
name: sd-card
esp32:
board: esp32dev
framework:
type: arduino
version: 2.0.17
external_components:
- source: components
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
logger:
level: VERBOSE #makes uart stream available in esphome logstream
baud_rate: 0 #disable logging over uart
on_message:
level: DEBUG
then:
- sd_mmc_card.append_file:
path: "/test.log"
data: !lambda |
std::string str(message);
str += "\n";
return std::vector<uint8_t>(str.begin(), str.end());
globals:
- id: capture_switch_state
type: boolean
restore_value: false
initial_value: "false"
- id: await_capture_state
type: boolean
restore_value: false
initial_value: "false"
time:
- platform: sntp
id: sntp_time
timezone: Europe/Paris
sd_mmc_card:
id: esp_camera_sd_card
mode_1bit: false
clk_pin: GPIO14
cmd_pin: GPIO15
data0_pin: GPIO2
data1_pin: GPIO4
data2_pin: GPIO12
data3_pin: GPIO13
esp32_camera:
external_clock:
pin: GPIO0
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
pixel_clock_pin: GPIO22
power_down_pin: GPIO32
# Image settings
name: My Camera
id: camera
max_framerate: 5fps
jpeg_quality: 10
resolution: 1920x1080
vertical_flip: False
on_image:
then:
- if:
condition:
lambda: "return id(await_capture_state);"
then:
- sd_mmc_card.write_file:
path: !lambda "return \"/test_\" + id(sntp_time).now().strftime(\"%FT%H-%M-%S\") + \".jpg\";"
data: !lambda "return std::vector<uint8_t>(&image.data[0], &image.data[image.length]);"
- logger.log: "image saved"
- lambda: "id(await_capture_state) = false;"
- sd_mmc_card.delete_file:
path: "/test.txt"
- sd_mmc_card.create_directory:
path: "/test"
- sd_mmc_card.remove_directory:
path: "/test"
- lambda: |
for (auto const & file : id(esp_camera_sd_card)->list_directory("/", 1))
ESP_LOGE(" ", "File: %s\n", file.c_str());
switch:
- platform: template
name: Capture Switch
id: capture_switch
optimistic: true
lambda: return id(capture_switch_state);
turn_on_action:
then:
- lambda: |
id(capture_switch_state) = false;
id(await_capture_state) = true;
sensor:
- platform: sd_mmc_card
type: used_space
unit_of_measurement: Mb
name: "SD card used space"
filters:
- lambda: return sd_mmc_card::convertBytes(x, sd_mmc_card::MemoryUnits::MegaByte);
- platform: sd_mmc_card
type: total_space
name: "SD card total space"
unit_of_measurement: Gb
filters:
- lambda: return sd_mmc_card::convertBytes(x, sd_mmc_card::MemoryUnits::GigaByte);
- platform: sd_mmc_card
type: file_size
name: "text.txt size"
unit_of_measurement: Kb
path: "/test.txt"
filters:
- lambda: return sd_mmc_card::convertBytes(x, sd_mmc_card::MemoryUnits::KiloByte);
text_sensor:
- platform: sd_mmc_card
sd_card_type:
name: "SD card type"
sd_file_server:
id: file_server
url_prefix: "file"
root_path: "/"
enable_deletion: true
enable_download: true
enable_upload: true