|
11 | 11 | ##### - For normal system use, modifications to this file are NOT required. #####
|
12 | 12 | ####################################################################################################
|
13 | 13 | ---
|
14 |
| -substitutions: |
15 |
| - name: tx-ultimate-easy |
16 |
| - friendly_name: TX Ultimate Easy |
17 |
| - |
18 |
| - <<: !include ../versioning/VERSION_YAML |
19 |
| - |
20 |
| - TX_MODEL_FORMAT_EU_TEXT: "EU (Square, T5-xC-86)" |
21 |
| - TX_MODEL_FORMAT_US_TEXT: "US (Rectangle, T5-xC-120)" |
22 |
| - |
23 |
| - TX_MODEL_1_GANG_TEXT: "1 Gang" |
24 |
| - TX_MODEL_2_GANG_TEXT: "2 Gang" |
25 |
| - TX_MODEL_3_GANG_TEXT: "3 Gang" |
26 |
| - TX_MODEL_4_GANG_TEXT: "4 Gang" |
27 |
| - |
28 |
| - DUMP_CONFIG_CALLER_DELAY: 10s # Delay to dump config after requested |
29 |
| - |
30 | 14 | packages:
|
31 | 15 | # yamllint disable rule:colons
|
| 16 | + core_common: !include TX-Ultimate-Easy-ESPHome_core_common.yaml |
32 | 17 | core_hw_buttons: !include TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml
|
33 | 18 | core_hw_leds: !include TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml
|
34 | 19 | core_hw_touch: !include TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml
|
35 | 20 | # yamllint enable rule:colons
|
36 |
| - |
37 |
| -api: |
38 |
| - id: api_server |
39 |
| - on_client_connected: |
40 |
| - then: |
41 |
| - - script.execute: dump_config_caller |
42 |
| - - script.execute: publish_device_info |
43 |
| - |
44 |
| -binary_sensor: |
45 |
| - - id: bs_pending_restart |
46 |
| - name: Pending Restart Status |
47 |
| - internal: false |
48 |
| - disabled_by_default: false |
49 |
| - platform: template |
50 |
| - entity_category: diagnostic |
51 |
| - device_class: problem |
52 |
| - on_state: |
53 |
| - then: |
54 |
| - - lambda: |- |
55 |
| - if (x) |
56 |
| - ESP_LOGW("core", "Pending restart: YES"); |
57 |
| - else |
58 |
| - ESP_LOGCONFIG("core", "Pending restart: No"); |
59 |
| - - script.execute: dump_config_caller |
60 |
| - |
61 |
| -esp32: |
62 |
| - board: esp32dev |
63 |
| - flash_size: 8MB |
64 |
| - |
65 |
| -esphome: |
66 |
| - name: ${name} |
67 |
| - friendly_name: ${friendly_name} |
68 |
| - comment: TX Ultimate Easy |
69 |
| - project: |
70 |
| - name: "edwardtfn.tx_ultimate_easy" |
71 |
| - version: ${version} |
72 |
| - platformio_options: |
73 |
| - build_flags: |
74 |
| - - -D TX_ULTIMATE_EASY_CORE |
75 |
| - |
76 |
| - on_boot: |
77 |
| - - priority: 700 |
78 |
| - then: |
79 |
| - - script.execute: boot_initialize |
80 |
| - |
81 |
| - - priority: 600 # This is where most sensors are set up. |
82 |
| - then: |
83 |
| - - script.execute: boot_sequence |
84 |
| - |
85 |
| - - priority: -100 # At this priority, pretty much everything should already be initialized. |
86 |
| - then: |
87 |
| - - script.execute: boot_done |
88 |
| - |
89 |
| -globals: |
90 |
| - - id: is_us_model |
91 |
| - type: bool |
92 |
| - restore_value: true |
93 |
| - initial_value: 'false' |
94 |
| - |
95 |
| - - id: gang_count |
96 |
| - type: uint8_t |
97 |
| - restore_value: true |
98 |
| - initial_value: '0' |
99 |
| - |
100 |
| - - id: gang_count_plural_suffix |
101 |
| - type: std::string |
102 |
| - restore_value: true |
103 |
| - max_restore_data_length: 3 |
104 |
| - # initial_value: "''" |
105 |
| - |
106 |
| -logger: |
107 |
| - level: DEBUG |
108 |
| - |
109 |
| -ota: |
110 |
| - platform: esphome |
111 |
| - |
112 |
| -psram: |
113 |
| - mode: octal |
114 |
| - speed: 80MHz |
115 |
| - |
116 |
| -script: |
117 |
| - - id: api_send_ha_event_boot |
118 |
| - mode: queued |
119 |
| - parameters: |
120 |
| - type: string |
121 |
| - then: |
122 |
| - - homeassistant.event: |
123 |
| - event: esphome.tx_ultimate_easy |
124 |
| - data: |
125 |
| - device_name: !lambda return tx_device_name->state.c_str(); |
126 |
| - firmware: ${version} |
127 |
| - domain: boot |
128 |
| - type: !lambda return type.c_str(); |
129 |
| - |
130 |
| - - id: boot_done |
131 |
| - mode: restart |
132 |
| - then: |
133 |
| - - script.execute: |
134 |
| - id: api_send_ha_event_boot |
135 |
| - type: done |
136 |
| - |
137 |
| - - id: boot_initialize |
138 |
| - mode: restart |
139 |
| - then: |
140 |
| - # Extended by: |
141 |
| - # - HW Buttons |
142 |
| - # - HW Relays |
143 |
| - # - HW Touch |
144 |
| - - script.execute: |
145 |
| - id: api_send_ha_event_boot |
146 |
| - type: start |
147 |
| - - wait_until: |
148 |
| - condition: |
149 |
| - - lambda: return sl_tx_model_format->active_index().has_value(); |
150 |
| - - lambda: return sl_tx_model_gang->active_index().has_value(); |
151 |
| - - lambda: |- |
152 |
| - id(is_us_model) = (sl_tx_model_format->state == "${TX_MODEL_FORMAT_US_TEXT}"); |
153 |
| - id(gang_count) = sl_tx_model_gang->active_index().value() + 1; |
154 |
| - if (id(gang_count) < 1 || id(gang_count) > 4) { |
155 |
| - ESP_LOGE("core_hw_leds", "Invalid number of gangs: %" PRIu8, id(gang_count)); |
156 |
| - } |
157 |
| - id(gang_count_plural_suffix) = id(gang_count) > 1 ? "s" : ""; |
158 |
| -
|
159 |
| - - id: boot_sequence |
160 |
| - mode: restart |
161 |
| - then: |
162 |
| - - script.execute: publish_device_info |
163 |
| - - binary_sensor.template.publish: |
164 |
| - id: bs_pending_restart |
165 |
| - state: false |
166 |
| - |
167 |
| - - id: dump_config |
168 |
| - mode: restart |
169 |
| - then: |
170 |
| - # Extended by all modules |
171 |
| - - lambda: |- |
172 |
| - // Device identification |
173 |
| - ESP_LOGCONFIG("core", "Device friendly name: ${friendly_name}"); |
174 |
| - ESP_LOGCONFIG("core", "Device name: ${name}"); |
175 |
| - ESP_LOGCONFIG("core", "Device name (HA): %s", tx_device_name->state.c_str()); |
176 |
| - ESP_LOGCONFIG("core", "Device hostname: %s", App.get_name().c_str()); |
177 |
| -
|
178 |
| - dump_config_versions->execute(); |
179 |
| -
|
180 |
| - // Framework detection |
181 |
| - #ifdef USE_ARDUINO |
182 |
| - ESP_LOGCONFIG("core", "Framework: Arduino"); |
183 |
| - #elif defined(USE_ESP_IDF) |
184 |
| - ESP_LOGCONFIG("core", "Framework: ESP-IDF"); |
185 |
| - #else |
186 |
| - ESP_LOGW("core", "Framework: UNKNOWN"); |
187 |
| - #endif |
188 |
| -
|
189 |
| - // Model configuration |
190 |
| - ESP_LOGCONFIG("core", "Model format (selected): %s", sl_tx_model_format->state.c_str()); |
191 |
| - ESP_LOGCONFIG("core", "Model format (detected): %s", id(is_us_model) ? "US" : "EU"); |
192 |
| - ESP_LOGCONFIG("core", "Gangs (selected): %s", sl_tx_model_gang->state.c_str()); |
193 |
| - ESP_LOGCONFIG("core", "Gangs (detected): %" PRIu8 "-Gang%s", id(gang_count), id(gang_count_plural_suffix).c_str()); |
194 |
| -
|
195 |
| - // System state |
196 |
| - if (bs_pending_restart->state) |
197 |
| - ESP_LOGW("core", "Pending restart: YES"); |
198 |
| - else |
199 |
| - ESP_LOGCONFIG("core", "Pending restart: No"); |
200 |
| -
|
201 |
| - - id: dump_config_caller |
202 |
| - mode: restart |
203 |
| - then: |
204 |
| - - delay: ${DUMP_CONFIG_CALLER_DELAY} |
205 |
| - - script.execute: dump_config |
206 |
| - - script.wait: dump_config |
207 |
| - - script.execute: dump_config_list_packages |
208 |
| - |
209 |
| - - id: dump_config_list_packages |
210 |
| - mode: restart |
211 |
| - then: |
212 |
| - - script.wait: dump_config |
213 |
| - - lambda: |- |
214 |
| - ESP_LOGCONFIG(ESPHOME_PROJECT_NAME, "Installed packages:"); |
215 |
| -
|
216 |
| - // Identify itself |
217 |
| - ESP_LOGCONFIG(ESPHOME_PROJECT_NAME, " - Core"); |
218 |
| -
|
219 |
| - - id: dump_config_versions |
220 |
| - mode: restart |
221 |
| - then: |
222 |
| - - lambda: |- |
223 |
| - // Version information |
224 |
| - ESP_LOGCONFIG("core", "TX Ultimate firmware version: ${version}"); |
225 |
| -
|
226 |
| - - id: publish_device_info |
227 |
| - mode: restart |
228 |
| - then: |
229 |
| - - lambda: |- |
230 |
| - tx_fw_version->publish_state("${version}"); |
231 |
| - tx_device_name->publish_state(App.get_name().c_str()); |
232 |
| -
|
233 |
| -select: |
234 |
| - - id: sl_tx_model_format |
235 |
| - name: Model (Format) |
236 |
| - platform: template |
237 |
| - options: |
238 |
| - - "${TX_MODEL_FORMAT_EU_TEXT}" |
239 |
| - - "${TX_MODEL_FORMAT_US_TEXT}" |
240 |
| - initial_option: "${TX_MODEL_FORMAT_EU_TEXT}" |
241 |
| - optimistic: true |
242 |
| - restore_value: true |
243 |
| - internal: false |
244 |
| - entity_category: config |
245 |
| - disabled_by_default: false |
246 |
| - icon: mdi:tablet-cellphone |
247 |
| - on_value: |
248 |
| - then: |
249 |
| - - binary_sensor.template.publish: |
250 |
| - id: bs_pending_restart |
251 |
| - state: true |
252 |
| - - lambda: |- |
253 |
| - id(is_us_model) = (x == "${TX_MODEL_FORMAT_US_TEXT}"); |
254 |
| - ESP_LOGI("core", "New model selected: %s", id(is_us_model) ? "US" : "EU"); |
255 |
| -
|
256 |
| - - id: sl_tx_model_gang |
257 |
| - name: Model (Gang) |
258 |
| - platform: template |
259 |
| - options: |
260 |
| - - "${TX_MODEL_1_GANG_TEXT}" |
261 |
| - - "${TX_MODEL_2_GANG_TEXT}" |
262 |
| - - "${TX_MODEL_3_GANG_TEXT}" |
263 |
| - - "${TX_MODEL_4_GANG_TEXT}" |
264 |
| - initial_option: "${TX_MODEL_1_GANG_TEXT}" |
265 |
| - optimistic: true |
266 |
| - restore_value: true |
267 |
| - internal: false |
268 |
| - entity_category: config |
269 |
| - disabled_by_default: false |
270 |
| - icon: mdi:dip-switch |
271 |
| - on_value: |
272 |
| - then: |
273 |
| - - binary_sensor.template.publish: |
274 |
| - id: bs_pending_restart |
275 |
| - state: true |
276 |
| - - lambda: |- |
277 |
| - id(gang_count) = static_cast<uint8_t>(i) + 1; |
278 |
| - ESP_LOGI("core", "New model selected: %" PRIu8 "-%s", id(gang_count), id(gang_count) > 1 ? "Gangs" : "Gang"); |
279 |
| - tx_ultimate->set_gang_count(id(gang_count)); |
280 |
| -
|
281 |
| -text_sensor: |
282 |
| - - id: tx_fw_version |
283 |
| - name: TX Ultimate Easy Firmware Version |
284 |
| - platform: template |
285 |
| - entity_category: diagnostic |
286 |
| - icon: mdi:tag-text-outline |
287 |
| - internal: false |
288 |
| - update_interval: never |
289 |
| - lambda: |- |
290 |
| - return {"${version}"}; |
291 |
| -
|
292 |
| - - id: tx_device_name |
293 |
| - name: Device Name |
294 |
| - platform: template |
295 |
| - icon: mdi:identifier |
296 |
| - entity_category: diagnostic |
297 |
| - internal: false |
298 |
| - disabled_by_default: false |
299 |
| - update_interval: never |
300 |
| - lambda: |- |
301 |
| - return {"${name}"}; |
302 |
| - filters: |
303 |
| - - lambda: |- |
304 |
| - const std::string raw_name = x; |
305 |
| - std::string result; |
306 |
| - bool last_was_underscore = false; |
307 |
| - for (const char& c : raw_name) { |
308 |
| - if (isalnum(c)) { |
309 |
| - result += tolower(c); // Add alphanumeric characters as lowercase |
310 |
| - last_was_underscore = false; |
311 |
| - } else if (!last_was_underscore) { // Replace non-alphanumeric with '_' but avoid consecutive '_' |
312 |
| - result += '_'; |
313 |
| - last_was_underscore = true; |
314 |
| - } |
315 |
| - } |
316 |
| - return result; |
317 |
| -
|
318 |
| -wifi: |
319 |
| - id: wifi_component |
320 | 21 | ...
|
0 commit comments