diff --git a/esphome/components/bthome/__init__.py b/esphome/components/bthome/__init__.py index 6c465dc506..9482162ded 100644 --- a/esphome/components/bthome/__init__.py +++ b/esphome/components/bthome/__init__.py @@ -32,4 +32,5 @@ async def to_code(config): await esp32_ble_tracker.register_ble_device(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) - cg.add(var.set_encryption_key(config[CONF_ENCRYPTION_KEY])) + if CONF_ENCRYPTION_KEY in config: + cg.add(var.set_encryption_key(config[CONF_ENCRYPTION_KEY]))