mirror of
https://github.com/esphome/esphome.git
synced 2026-09-27 06:50:22 +00:00
[core] Pack entity flags into configure_entity_() and protect setters
Move set_internal(), set_disabled_by_default(), set_entity_category(), and set_device() to protected on EntityBase. These were codegen-only setters never intended for runtime use. internal, disabled_by_default, and entity_category are now packed into the existing configure_entity_() uint32 parameter alongside string indices, eliminating up to 3 separate function calls per entity. set_device() is renamed to set_device_() per protected naming convention and remains a separate call (pointer can't be packed). Entity category integer mapping is derived from cv.ENTITY_CATEGORIES to stay in sync with the C++ enum automatically.
This commit is contained in:
@@ -45,8 +45,9 @@ def test_binary_sensor_config_value_internal_set(generate_main):
|
||||
)
|
||||
|
||||
# Then
|
||||
assert "bs_1->set_internal(true);" in main_cpp
|
||||
assert "bs_2->set_internal(false);" in main_cpp
|
||||
# internal flag is now packed into configure_entity_() third argument (bit 24)
|
||||
assert "bs_1->configure_entity_(" in main_cpp
|
||||
assert "bs_2->configure_entity_(" in main_cpp
|
||||
|
||||
|
||||
def test_binary_sensor_config_value_use_raw_set(generate_main):
|
||||
|
||||
Reference in New Issue
Block a user