Type is not JSON serializable: memoryview

Any idea what this means?

State is not JSON serializable: <state sensor.bresser51_db_rain_168h=748.4; state_id=39740147, domain=None, entity_id=None, state=748.4, attributes=None, event_id=None, last_changed=None, last_updated=None, created=None, old_state_id=39736286, attributes_id=289262, origin_idx=0, context_id=None, context_user_id=None, context_parent_id=None, last_updated_ts=1680841004.060583, last_changed_ts=None, context_id_bin=<memory at 0x7f996bc99b40>, context_user_id_bin=None, context_parent_id_bin=None, metadata_id=333, unit_of_measurement=mm, icon=mdi:database-search, friendly_name=Bresser51 DB Rain 168H @ 2023-04-16T23:26:30.113584+02:00>: Type is not JSON serializable: memoryview

This sensor:

friendly_name=Bresser51 DB Rain 168H

Is not receiving the json formatted data it expects.

The offending item seems to be memoryview, something that is not part of my code.

No, this is the issue:

Confusing. It is an SQL sensor and does not do anything with JSON data.

I changed the SQL query from “SELECT * FROM states” to “SELECT state FROM states” and now the error disappears. I still have no clue what went wrong.

EDIT: The culprit seems to be context_id_bin, which is a binary data item apparently unsuitable for JSON serialisation.