1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-01 10:52:19 +01:00

[api] Dump bytes fields as hex instead of unreadable string (#9288)

This commit is contained in:
Jesse Hills
2025-07-02 13:36:15 +12:00
committed by GitHub
parent 04a46de237
commit 6a096c1d5a
4 changed files with 34 additions and 15 deletions

View File

@@ -530,7 +530,7 @@ class BytesType(TypeInfo):
wire_type = WireType.LENGTH_DELIMITED # Uses wire type 2
def dump(self, name: str) -> str:
o = f'out.append("\'").append({name}).append("\'");'
o = f"out.append(format_hex_pretty({name}));"
return o
def get_size_calculation(self, name: str, force: bool = False) -> str:
@@ -1255,6 +1255,7 @@ def main() -> None:
#include "api_pb2.h"
#include "api_pb2_size.h"
#include "esphome/core/log.h"
#include "esphome/core/helpers.h"
#include <cinttypes>