From 63de88dd57963dbbc495001634ed16336d5db3b9 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 21 Jun 2025 13:33:05 +0200 Subject: [PATCH] fixes --- esphome/components/api/api_connection.h | 3 --- esphome/core/config.py | 8 +++----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/esphome/components/api/api_connection.h b/esphome/components/api/api_connection.h index 9166dbbc94..66b7ce38a7 100644 --- a/esphome/components/api/api_connection.h +++ b/esphome/components/api/api_connection.h @@ -301,9 +301,6 @@ class APIConnection : public APIServerConnection { response.icon = entity->get_icon(); response.disabled_by_default = entity->is_disabled_by_default(); response.entity_category = static_cast(entity->get_entity_category()); -#ifdef USE_SUB_DEVICE - response.device_id = entity->get_device_id(); -#endif } // Helper function to fill common entity state fields diff --git a/esphome/core/config.py b/esphome/core/config.py index 2c33ad1df0..76c7505393 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -462,10 +462,8 @@ async def to_code(config): cg.add(dev.set_device_id(fnv1a_32bit_hash(str(dev_conf[CONF_ID])))) cg.add(dev.set_name(dev_conf[CONF_NAME])) if CONF_AREA_ID in dev_conf: - # The area_id in dev_conf is the ID reference from cv.use_id - # We need to get the same hash that was used when creating the area - area_id_str = str(dev_conf[CONF_AREA_ID].id) - area_id = fnv1a_32bit_hash(area_id_str) - cg.add(dev.set_area_id(area_id)) + # Get the area variable and use its area_id + area = await cg.get_variable(dev_conf[CONF_AREA_ID]) + cg.add(dev.set_area_id(area.get_area_id())) cg.add(cg.App.register_sub_device(dev)) cg.add_define("USE_SUB_DEVICE")