summaryrefslogtreecommitdiffstats
path: root/esphome/config
diff options
context:
space:
mode:
Diffstat (limited to 'esphome/config')
-rw-r--r--esphome/config/toiletlight.yaml128
1 files changed, 128 insertions, 0 deletions
diff --git a/esphome/config/toiletlight.yaml b/esphome/config/toiletlight.yaml
new file mode 100644
index 0000000..41cf154
--- /dev/null
+++ b/esphome/config/toiletlight.yaml
@@ -0,0 +1,128 @@
1substitutions:
2 device_name: toiletlight
3 friendly_name: "Toilet Light"
4
5esphome:
6 name: ${device_name}
7 friendly_name: ${friendly_name}
8 area: Toilet
9
10esp32:
11 variant: esp32c3
12 cpu_frequency: 80MHz
13 framework:
14 type: esp-idf
15 sdkconfig_options:
16 CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON: y
17 CONFIG_BOOTLOADER_LOG_LEVEL_NONE: y
18 CONFIG_LOG_DEFAULT_LEVEL_NONE: y
19
20preferences:
21 flash_write_interval: 30s
22
23# Enable logging
24logger:
25 # disable logging for much faster startup
26 level: NONE
27 # make RXD / TXD available
28 baud_rate: 0
29
30# Enable Home Assistant API
31api:
32 encryption:
33 key: !secret api_encryption_key
34
35# OTA
36ota:
37 - platform: esphome
38 password: !secret ota_password
39
40# WiFi Credentials
41wifi:
42 domain: .lan
43 ssid: !secret wifi_ssid
44 password: !secret wifi_password
45 # enabling power saves causes jitter!
46 power_save_mode: NONE
47
48 # Enable fallback hotspot (captive portal) in case wifi connection fails
49 ap:
50 ssid: "${device_name} Fallback Hotspot"
51 password: !secret wifi_ap_password
52
53captive_portal:
54
55light:
56 - id: toilet
57 platform: color_temperature
58 name: "Toilet"
59 color_temperature: pwm_warm_cold
60 # we are using pwm_dim_mapped to transform between min+max-power
61 # otherwise one can use:
62 #brightness: pwm_dim
63 #gamma_correct: 1.0
64 brightness: pwm_dim_mapped
65 cold_white_color_temperature: 6500 K
66 warm_white_color_temperature: 3000 K
67 default_transition_length: 300ms
68 initial_state:
69 state: true
70 brightness: 100%
71 color_temperature: 4500 K
72 restore_mode: RESTORE_DEFAULT_ON
73
74output:
75 - id: pwm_dim
76 platform: ledc
77 pin: GPIO1
78 frequency: 3900 Hz
79 channel: 0
80 min_power: 0.04
81 zero_means_zero: true
82
83 - id: pwm_warm
84 platform: ledc
85 pin: GPIO3
86 # original mcu uses 3900Hz
87 frequency: 24000 Hz
88 channel: 2
89
90 - id: pwm_cold
91 platform: ledc
92 pin: GPIO4
93 # original mcu uses 3900Hz
94 frequency: 24000 Hz
95 channel: 3
96 phase_angle: 180°
97
98 - platform: template
99 id: pwm_warm_cold
100 type: float
101 write_action:
102 - lambda: |-
103 auto warm = id(pwm_warm), cold = id(pwm_cold);
104 ESP_LOGD("cal", "warm: %f, cold: %f, phase: %f", state, 1-state, state*360.0);
105 warm->set_level(state);
106 cold->set_level(1 - state);
107 cold->set_phase_angle(state * 360.0);
108
109 # map output to range (min_power, max_power)
110 - platform: template
111 id: pwm_dim_mapped
112 type: float
113 write_action:
114 - lambda: |-
115 auto output = id(pwm_dim);
116 float min = output->get_min_power(), max = output->get_max_power();
117 float newlvl = (state) ? state * (max - min) + min : 0;
118 ESP_LOGD("cal", "dim: %f -> %f", state, newlvl);
119 output->set_level(newlvl);
120
121# closed loop not implemented
122#sensor:
123# - id: adc_cs
124# platform: adc
125# pin: GPIO0
126# accuracy_decimals: 2
127# attenuation: auto
128# update_interval: 1s