mirror of
https://github.com/esphome/esphome.git
synced 2025-08-02 00:17:48 +00:00
Merge branch 'entity_dupe_code' into integration
This commit is contained in:
commit
8fcbcebf84
@ -277,34 +277,6 @@ class APIConnection : public APIServerConnection {
|
|||||||
// Helper function to handle authentication completion
|
// Helper function to handle authentication completion
|
||||||
void complete_authentication_();
|
void complete_authentication_();
|
||||||
|
|
||||||
// Helper function to fill common entity info fields
|
|
||||||
static void fill_entity_info_base(esphome::EntityBase *entity, InfoResponseProtoMessage &response) {
|
|
||||||
// Set common fields that are shared by all entity types
|
|
||||||
response.key = entity->get_object_id_hash();
|
|
||||||
response.object_id = entity->get_object_id();
|
|
||||||
|
|
||||||
if (entity->has_own_name())
|
|
||||||
response.name = entity->get_name();
|
|
||||||
|
|
||||||
// Set common EntityBase properties
|
|
||||||
#ifdef USE_ENTITY_ICON
|
|
||||||
response.icon = entity->get_icon();
|
|
||||||
#endif
|
|
||||||
response.disabled_by_default = entity->is_disabled_by_default();
|
|
||||||
response.entity_category = static_cast<enums::EntityCategory>(entity->get_entity_category());
|
|
||||||
#ifdef USE_DEVICES
|
|
||||||
response.device_id = entity->get_device_id();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper function to fill common entity state fields
|
|
||||||
static void fill_entity_state_base(esphome::EntityBase *entity, StateResponseProtoMessage &response) {
|
|
||||||
response.key = entity->get_object_id_hash();
|
|
||||||
#ifdef USE_DEVICES
|
|
||||||
response.device_id = entity->get_device_id();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Non-template helper to encode any ProtoMessage
|
// Non-template helper to encode any ProtoMessage
|
||||||
static uint16_t encode_message_to_buffer(ProtoMessage &msg, uint8_t message_type, APIConnection *conn,
|
static uint16_t encode_message_to_buffer(ProtoMessage &msg, uint8_t message_type, APIConnection *conn,
|
||||||
uint32_t remaining_size, bool is_single);
|
uint32_t remaining_size, bool is_single);
|
||||||
|
@ -176,7 +176,7 @@ void SSD1306::setup() {
|
|||||||
// Disable scrolling mode (0x2E)
|
// Disable scrolling mode (0x2E)
|
||||||
this->command(SSD1306_COMMAND_DEACTIVATE_SCROLL);
|
this->command(SSD1306_COMMAND_DEACTIVATE_SCROLL);
|
||||||
|
|
||||||
// Contrast and brighrness
|
// Contrast and brightness
|
||||||
// SSD1306 does not have brightness setting
|
// SSD1306 does not have brightness setting
|
||||||
set_contrast(this->contrast_);
|
set_contrast(this->contrast_);
|
||||||
if (this->is_ssd1305_())
|
if (this->is_ssd1305_())
|
||||||
|
@ -41,7 +41,7 @@ async def test_host_mode_api_password(
|
|||||||
# Wait for at least one state with timeout
|
# Wait for at least one state with timeout
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(state_future, timeout=5.0)
|
await asyncio.wait_for(state_future, timeout=5.0)
|
||||||
except asyncio.TimeoutError:
|
except TimeoutError:
|
||||||
pytest.fail("No states received within timeout")
|
pytest.fail("No states received within timeout")
|
||||||
|
|
||||||
# Should have received at least one state (the test sensor)
|
# Should have received at least one state (the test sensor)
|
||||||
|
@ -65,13 +65,13 @@ async def test_runtime_stats(
|
|||||||
# Wait for first "Total stats" log (should happen at 1s)
|
# Wait for first "Total stats" log (should happen at 1s)
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(first_stats_future, timeout=5.0)
|
await asyncio.wait_for(first_stats_future, timeout=5.0)
|
||||||
except asyncio.TimeoutError:
|
except TimeoutError:
|
||||||
pytest.fail("First 'Total stats' log not seen within 5 seconds")
|
pytest.fail("First 'Total stats' log not seen within 5 seconds")
|
||||||
|
|
||||||
# Wait for second "Total stats" log (should happen at 2s)
|
# Wait for second "Total stats" log (should happen at 2s)
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(second_stats_future, timeout=5.0)
|
await asyncio.wait_for(second_stats_future, timeout=5.0)
|
||||||
except asyncio.TimeoutError:
|
except TimeoutError:
|
||||||
pytest.fail(f"Second 'Total stats' log not seen. Total seen: {stats_count}")
|
pytest.fail(f"Second 'Total stats' log not seen. Total seen: {stats_count}")
|
||||||
|
|
||||||
# Verify we got at least 2 stats logs
|
# Verify we got at least 2 stats logs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user