I have an LVGL page with multiple objects to display the Current Room Temperature and Setpoint (from the associated HA Climate entity) for a number of Rooms.
When you click on the room object it navigates to a Climate Settings page where the Mode and Setpoint can be adjusted. I am trying to find a way to have a single, reusable Climate Settings page where the selected room can be passed as a variable/parameter and that value is then used in the HA Entity ID parameters e.g. for reading current values or call the HA Actions to change the parameters of the correct Climate instance.
Currently I see the only option of creating a Climate Settings page per Room which makes for large YAML and I guess more resource intensive.
You can use includes with substitution to have multiple things from common code. This ends up with lines like this:
- button: !include { file: modules/lvgl/basic_switch_button.yaml, vars: { id: 1, height: $button_height_single } }
See GitHub - agillis/esphome-modular-lvgl-buttons: A modular LVGL button platform for ESPHome for some examples.
@clydebarrow many thanks for pointing me to this. I learnt a lot about Substitutions and Includes which has simplified my YAML. More importantly SDL, which has accelerated my LVGL development time
1 Like
Great! Good to hear my code is working for you.
2 Likes
Yes, Kudos to you too Andrew. Your design has given me some great inspiration. A week ago I didn’t think I had the time to spend on developing these screens. Now I have an idea that is turned into reality within the same evening
1 Like