Handle bytes data in sql sensors (#89169)
This commit is contained in:
@@ -242,10 +242,15 @@ class SQLSensor(SensorEntity):
|
||||
for key, value in res.items():
|
||||
if isinstance(value, decimal.Decimal):
|
||||
value = float(value)
|
||||
if isinstance(value, date):
|
||||
elif isinstance(value, date):
|
||||
value = value.isoformat()
|
||||
elif isinstance(value, (bytes, bytearray)):
|
||||
value = f"0x{value.hex()}"
|
||||
self._attr_extra_state_attributes[key] = value
|
||||
|
||||
if data is not None and isinstance(data, (bytes, bytearray)):
|
||||
data = f"0x{data.hex()}"
|
||||
|
||||
if data is not None and self._template is not None:
|
||||
self._attr_native_value = (
|
||||
self._template.async_render_with_possible_json_value(data, None)
|
||||
|
||||
Reference in New Issue
Block a user