teddycloud icon indicating copy to clipboard operation
teddycloud copied to clipboard

Home Assistant MQTT: encode.stream_max_size produces invalid entity ID and growing callback error flood

Open 7weazel7 opened this issue 1 month ago • 7 comments

Describe the bug

With teddyCloud's Home Assistant MQTT integration, the number entity for encode.stream_max_size repeatedly fails to be added in Home Assistant Core 2026.10.1. The generated entity ID contains the setting's long explanatory text and is rejected with InvalidEntityFormatError.

After the first failed setup, messages on teddyCloud/encode-stream_max_size/status repeatedly trigger AttributeError: 'NoneType' object has no attribute 'data' in Home Assistant's MQTT entity callback. The number of logged exceptions grows substantially over time.

To Reproduce

Observed sequence in my existing installation (not yet independently reproduced in a clean installation):

  1. Run teddyCloud with its Home Assistant MQTT integration enabled.
  2. Start Home Assistant Core 2026.10.1 with the MQTT integration configured.
  3. The encode.stream_max_size number entity fails to be added.
  4. Leave the installation running; repeated entity-add failures and an increasing number of MQTT callback exceptions appear.

Expected behavior

The setting should be discovered with a valid, compact entity ID and work without repeated setup failures or callback exceptions.

Technical Details

  • Home Assistant Core: 2026.10.1 (confirmed by the startup log).
  • teddyCloud image tag: latest (as configured by the reporter). Exact running release/commit and image digest have not yet been captured; this does not establish that the running image is current.
  • MQTT state topic: teddyCloud/encode-stream_max_size/status
  • State payload: 251658239
  • Broker version and original discovery payload: not yet captured.

Relevant Home Assistant logs

Initial entity-add failure (stack trace shortened; entity ID preserved):

2026-10-10 22:31:10.819 ERROR (MainThread) [homeassistant.components.number] Error adding entity number.teddycloud_encode_stream_max_size_the_box_may_create_an_empty_file_this_length_for_each_stream_so_if_you_have_10_streaming_tonies_you_use_the_box_may_block_10_240mb_the_only_downside_is_that_the_box_will_stop_after_the_file_is_full_and_you_ll_need_ for domain number with platform mqtt
...
  File "/usr/src/homeassistant/homeassistant/core.py", line 1923, in __init__
    raise InvalidEntityFormatError(
homeassistant.exceptions.InvalidEntityFormatError: Invalid entity id encountered: number.teddycloud_encode_stream_max_size_the_box_may_create_an_empty_file_this_length_for_each_stream_so_if_you_have_10_streaming_tonies_you_use_the_box_may_block_10_240mb_the_only_downside_is_that_the_box_will_stop_after_the_file_is_full_and_you_ll_need_. Format should be <domain>.<object_id>

Subsequent callback error:

2026-10-10 22:32:11.071 ERROR (MainThread) [homeassistant.components.mqtt.client] Exception in _message_received when handling msg on 'teddyCloud/encode-stream_max_size/status': '251658239'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/entity.py", line 1720, in _message_callback
    mqtt_data = self.hass.data[DATA_MQTT]
                ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'data'

Frequency and impact

In the log window from 2026-10-10 22:30 to 2026-10-11 15:46:

  • 1,028 entity-add failures for this number entity.
  • 528,905 _message_received exceptions for its state topic.
  • Hourly callback exception counts increased from 3,570 (23:00-23:59) to 35,550 (08:00-08:59) and 57,138 (14:00-14:59).
  • The entire Home Assistant log reached approximately 248 MB / 3.75 million lines, dominated by these repeated exceptions.

These are exception counts, not measured MQTT packet counts. The pattern could indicate callbacks accumulating after failed setup retries, but that is a hypothesis requiring investigation in Home Assistant. CPU/memory impact and any causal link to other connection issues have not been measured.

Additional context

Related: #272 concerned the same setting but a different min/max discovery error. This report concerns the invalid generated entity ID and subsequent callback error flood.

Please check whether the discovery name includes the long help text and whether publishing a short name and a valid explicit entity ID would prevent the initial failure. The downstream callback handling may also require a Home Assistant fix. The original discovery payload is still needed to confirm the exact trigger and distinguish a current teddyCloud issue from stale retained discovery data.

No workaround has been tested yet. teddyCloud-side logs are not currently available; the excerpts above are from Home Assistant. Unrelated private network details have been omitted.

7weazel7 avatar Oct 12 '26 19:10 7weazel7

I can confirm this bug. This bug caused my Homeassistant to become unresponsive. Propably the mqtt-broker, which is running as addon on homeassistant, caused this. What I saw was that this happened exactly once every minute.

I am running also HA 2026.10.1 with mqtt-broker on 7.1.1 Teddycloud 0.7.0 is running in docker on a separate VM

Se7enair avatar Oct 14 '26 20:10 Se7enair

The long name is only half of it. Home Assistant truncates the entity id at 255 characters, and with the device name teddyCloud the cut lands right after an underscore, which is an invalid id. With the default teddyCloud - Server the id is accepted, it is just very long.

I could reproduce it with v0.7.0 and Home Assistant 2026.10.1 in Docker. The entity fails once per minute, and every failed retry leaves another subscription behind, so the exceptions per status message keep growing. That part looks like a Home Assistant bug.

Fix is in #567

weatherhog avatar Oct 28 '26 08:10 weatherhog

The growing exceptions are a Home Assistant bug, it leaks the MQTT subscriptions when adding the entity fails. Fix is in https://github.com/home-assistant/core/pull/189192

weatherhog avatar Oct 28 '26 10:10 weatherhog

This is not MQTT specific.

jbouwh avatar Oct 29 '26 06:10 jbouwh

agree. The root cause is the truncation of long entity ids in core, fix is in https://github.com/home-assistant/core/pull/189403

weatherhog avatar Oct 29 '26 08:10 weatherhog

https://github.com/home-assistant/core/pull/189403 is merged, so Home Assistant no longer ends a truncated entity id with an underscore and the entity is added instead of failing every minute. It is in the 2026.11.0 milestone, so it ships with 2026.11.0.

Until then the workaround is to keep the default device name teddyCloud - Server. #567 is still open for the long names on the teddyCloud side.

weatherhog avatar Oct 29 '26 20:10 weatherhog

@7weazel7 Home Assistant 2026.11.0 is out with the core fix, so the entity id is valid again and the error flood should be gone. #567 for the shorter names is merged into develop and comes with the next release after v0.7.1. Is this fixed for you with 2026.11.0 or can it be closed?

weatherhog avatar Nov 06 '26 16:11 weatherhog