Skip to content

Commit 6fcbb5e

Browse files
committed
Fix hiding of the unwanted tabs
1 parent 58835ea commit 6fcbb5e

5 files changed

Lines changed: 44 additions & 33 deletions

File tree

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ validate-main:
3030
@echo "Validating the MAIN firmware..."
3131
source venv/bin/activate && \
3232
esphome config $(CONFIG_FILE) >$(CONFIG_FILE).validated
33+
@echo "Compiling the MAIN firmware..."
34+
source venv/bin/activate && \
35+
esphome compile $(CONFIG_FILE)
3336

37+
clean:
38+
@echo "Cleaning build files..."
39+
source venv/bin/activate && \
40+
esphome clean $(CONFIG_FILE)
3441

3542
# test with SDL emulator in local
3643

dev-sdl.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ packages:
209209
images: !include include/images.yaml
210210
scripts: !include include/scripts.yaml
211211
ui_design: !include include/lvgl_page_main.yaml
212-
heating_sensors: !include include/sensors.yaml
212+
sensors: !include include/sensors.yaml
213213
api: !include include/api.yaml
214214
time: !include include/time.yaml
215215

include/scripts.yaml

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,53 +39,62 @@ script:
3939
- lambda: |-
4040
ESP_LOGI("script", "Running hide_unwanted_tabs script");
4141
42+
std::string tab_rooms_enabled_str = to_string(${tab_rooms_enabled});
43+
std::string tab_heating_set_temp_enabled_str = to_string(${tab_heating_set_temp_enabled});
44+
std::string tab_heating_details_enabled_str = to_string(${tab_heating_details_enabled});
4245
std::string tab_cover_enabled_str = to_string(${tab_cover_enabled});
4346
std::string tab_scenes_enabled_str = to_string(${tab_scenes_enabled});
4447
std::string tab_info_enabled_str = to_string(${tab_info_enabled});
45-
std::string tab_heating_details_enabled_str = to_string(${tab_heating_details_enabled});
46-
std::string tab_heating_set_temp_enabled_str = to_string(${tab_heating_set_temp_enabled});
47-
std::string tab_rooms_enabled_str = to_string(${tab_rooms_enabled});
4848
49+
// if the order of the tabs is changed, please also update the index values below!
4950
const int idx_tab_rooms = 0;
5051
const int idx_tab_heating_set_temp = 1;
5152
const int idx_tab_heating_details = 2;
5253
const int idx_tab_covers = 3;
5354
const int idx_tab_scenes = 4;
5455
const int idx_tab_info = 5;
5556
56-
// please note that hiding buttons in the tabview's button matrix does not seem to work with ESPHome 2026.04
57-
auto *tab_buttons = lv_tabview_get_tab_btns(id(tabview_main));
58-
lv_buttonmatrix_ctrl_t hidden_state = (lv_buttonmatrix_ctrl_t)(LV_BTNMATRIX_CTRL_HIDDEN | LV_BTNMATRIX_CTRL_DISABLED);
57+
auto* button_tab_rooms = lv_tabview_get_tab_button(id(tabview_main), idx_tab_rooms);
58+
auto* button_tab_heating_set_temp = lv_tabview_get_tab_button(id(tabview_main), idx_tab_heating_set_temp);
59+
auto* button_tab_heating_details = lv_tabview_get_tab_button(id(tabview_main), idx_tab_heating_details);
60+
auto* button_tab_covers = lv_tabview_get_tab_button(id(tabview_main), idx_tab_covers);
61+
auto* button_tab_scenes = lv_tabview_get_tab_button(id(tabview_main), idx_tab_scenes);
62+
auto* button_tab_info = lv_tabview_get_tab_button(id(tabview_main), idx_tab_info);
5963
64+
// A tabview is just a lv_obj with a list of buttons; please note that there is NO buttonmatrix used.
65+
// So to hide a whole tab we need to hide both:
66+
// 1) the tab content (which is a lv_obj)
67+
// 2) the corresponding button in the tabview's button list (which is a lv_btn)
68+
// see https://lvgl.io/docs/open/9.5/API/widgets/tabview/lv_tabview_h.html
69+
if (tab_rooms_enabled_str == "0") {
70+
ESP_LOGI("script", "Hiding the 'Rooms' tab since tab_rooms_enabled is set to %s", tab_rooms_enabled_str.c_str());
71+
lv_obj_add_flag(id(tab_rooms), LV_OBJ_FLAG_HIDDEN);
72+
lv_obj_add_flag(button_tab_rooms, LV_OBJ_FLAG_HIDDEN);
73+
}
74+
if (tab_heating_set_temp_enabled_str == "0") {
75+
ESP_LOGI("script", "Hiding the 'Heating Set Temp' tab since tab_heating_set_temp_enabled is set to %s", tab_heating_set_temp_enabled_str.c_str());
76+
lv_obj_add_flag(id(tab_heating_set_temp), LV_OBJ_FLAG_HIDDEN);
77+
lv_obj_add_flag(button_tab_heating_set_temp, LV_OBJ_FLAG_HIDDEN);
78+
}
79+
if (tab_heating_details_enabled_str == "0") {
80+
ESP_LOGI("script", "Hiding the 'Heating Details' tab since tab_heating_details_enabled is set to %s", tab_heating_details_enabled_str.c_str());
81+
lv_obj_add_flag(id(tab_heating_details), LV_OBJ_FLAG_HIDDEN);
82+
lv_obj_add_flag(button_tab_heating_details, LV_OBJ_FLAG_HIDDEN);
83+
}
6084
if (tab_cover_enabled_str == "0") {
6185
ESP_LOGI("script", "Hiding the 'Cover' tab since tab_cover_enabled is set to %s", tab_cover_enabled_str.c_str());
6286
lv_obj_add_flag(id(tab_covers), LV_OBJ_FLAG_HIDDEN);
63-
lv_btnmatrix_set_btn_ctrl(tab_buttons, idx_tab_covers, hidden_state);
87+
lv_obj_add_flag(button_tab_covers, LV_OBJ_FLAG_HIDDEN);
6488
}
6589
if (tab_scenes_enabled_str == "0") {
6690
ESP_LOGI("script", "Hiding the 'Scenes' tab since tab_scenes_enabled is set to %s", tab_scenes_enabled_str.c_str());
6791
lv_obj_add_flag(id(tab_scenes), LV_OBJ_FLAG_HIDDEN);
68-
lv_btnmatrix_set_btn_ctrl(tab_buttons, idx_tab_scenes, hidden_state);
92+
lv_obj_add_flag(button_tab_scenes, LV_OBJ_FLAG_HIDDEN);
6993
}
7094
if (tab_info_enabled_str == "0") {
7195
ESP_LOGI("script", "Hiding the 'Info' tab since tab_info_enabled is set to %s", tab_info_enabled_str.c_str());
7296
lv_obj_add_flag(id(tab_info), LV_OBJ_FLAG_HIDDEN);
73-
lv_btnmatrix_set_btn_ctrl(tab_buttons, idx_tab_info, hidden_state);
74-
}
75-
if (tab_heating_details_enabled_str == "0") {
76-
ESP_LOGI("script", "Hiding the 'Heating Details' tab since tab_heating_details_enabled is set to %s", tab_heating_details_enabled_str.c_str());
77-
lv_obj_add_flag(id(tab_heating_details), LV_OBJ_FLAG_HIDDEN);
78-
lv_btnmatrix_set_btn_ctrl(tab_buttons, idx_tab_heating_details, hidden_state);
79-
}
80-
if (tab_heating_set_temp_enabled_str == "0") {
81-
ESP_LOGI("script", "Hiding the 'Heating Set Temp' tab since tab_heating_set_temp_enabled is set to %s", tab_heating_set_temp_enabled_str.c_str());
82-
lv_obj_add_flag(id(tab_heating_set_temp), LV_OBJ_FLAG_HIDDEN);
83-
lv_btnmatrix_set_btn_ctrl(tab_buttons, idx_tab_heating_set_temp, hidden_state);
84-
}
85-
if (tab_rooms_enabled_str == "0") {
86-
ESP_LOGI("script", "Hiding the 'Rooms' tab since tab_rooms_enabled is set to %s", tab_rooms_enabled_str.c_str());
87-
lv_obj_add_flag(id(tab_rooms), LV_OBJ_FLAG_HIDDEN);
88-
lv_btnmatrix_set_btn_ctrl(tab_buttons, idx_tab_rooms, hidden_state);
97+
lv_obj_add_flag(button_tab_info, LV_OBJ_FLAG_HIDDEN);
8998
}
9099
91100
- id: sync_all_window_contact_ui

include/sensors.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
#
2121

2222
packages:
23-
2423
# import basic sensors depending on the target platform
2524
basic: !include {
2625
file: "sensors_basic_${target_platform}.yaml",
2726
vars: {}
2827
}
2928

29+
# helper to troubleshoot misconfigurations:
30+
import_health: !include sensors_import_health.yaml
3031

3132
# Import from HA the room sensors
32-
3333
room1: !include {
3434
file: sensors_room_status.yaml,
3535
vars: {
@@ -75,10 +75,7 @@ packages:
7575
}
7676
}
7777

78-
79-
8078
# Import from HA the helpers that drive heating automations
81-
8279
temp_setting_daytime: !include {
8380
file: sensors_temperature_settings.yaml,
8481
vars: {
@@ -99,5 +96,3 @@ packages:
9996
ha_temperature_sensor_id: "${ha_temperature_target_sensor}",
10097
}
10198
}
102-
103-
import_health: !include sensors_import_health.yaml

main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,6 @@ packages:
211211
images: !include include/images.yaml
212212
scripts: !include include/scripts.yaml
213213
ui_design: !include include/lvgl_page_main.yaml
214-
heating_sensors: !include include/sensors.yaml
214+
sensors: !include include/sensors.yaml
215215
api: !include include/api.yaml
216216
time: !include include/time.yaml

0 commit comments

Comments
 (0)