Skip to content

get_domains() fails with ValidationError after Home Assistant 2025.11 release #217

Description

@kilian579

Description

After upgrading to Home Assistant 2025.11 (released November 5, 2025), the client.get_domains() method fails with a Pydantic validation error. This appears to be caused by changes in the Home Assistant REST API response format where some services are missing the required name field.

Environment

  • homeassistant-api version: 5.0.2
  • Home Assistant version: 2025.11.0
  • Python version: 3.13

Steps to Reproduce

from homeassistant_api import Client

ip = "..."
token = "..."
client = Client(ip, token, cache_session=False)

# This now fails with ValidationError
domains = client.get_domains()

Error Message

Traceback (most recent call last):
  File "<python-input-18>", line 1, in <module>
    client.get_domains()
  File "lib/python3.13/site-packages/homeassistant_api/rawclient.py", line 281, in get_domains
    return {domain.domain_id: domain for domain in domains}
  File "lib/python3.13/site-packages/homeassistant_api/rawclient.py", line 278, in <lambda>
    lambda json: Domain.from_json(json, client=cast(Client, self)),
  File "lib/python3.13/site-packages/homeassistant_api/models/domains.py", line 68, in from_json
    domain._add_service(service_id, **data)
  File "ib/python3.13/site-packages/homeassistant_api/models/domains.py", line 76, in _add_service
    service_id: Service(
        service_id=service_id,
        domain=self,
        **data,
    )
pydantic_core._pydantic_core.ValidationError: 1 validation error for Service
name
  Field required [type=missing, input_value={'service_id': 'save_pers...vices={}), 'fields': {}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/missing

Expected Behavior

The get_domains() method should successfully return a dictionary of all available domains and their services, which I use to access available fields and functions of my devices.

Actual Behavior

The method raises a ValidationError because the Pydantic Service model requires a name field that is apparently missing from some services in the Home Assistant 2025.11 REST API response.

Analysis

It appears that Home Assistant 2025.11 has changed the format of service definitions returned by the REST API. Some services (like save_persistent_states based on the error context) no longer include the name field that the library's Pydantic model expects.

This is likely related to the extensive automation editor improvements and API changes mentioned in the [2025.11 release notes](https://www.home-assistant.io/blog/2025/11/05/release-202511/).

Proposed Solution

The Service model in homeassistant_api/models/domains.py should be updated to make the name field optional, or provide a default value when it's missing from the API response. This would maintain backward compatibility while handling the new API format.

Workaround

None currently available. The get_domains() method is completely broken after upgrading Home Assistant to 2025.11.

Additional Context

  • The trigger_service() method still works correctly for controlling devices
  • Only the get_domains() method appears to be affected
  • Other methods like get_entity() appear to work when called with the entity_id keyword argument

Activity

  1. konetzed commented on Nov 10, 2025

    @konetzed

    Any updates on this? Just curious as im kinda stuck and seems like no work around. :)

  2. jzucker2 commented on Nov 10, 2025

    @jzucker2

    I started trying to dig into this. I can't even find the docs updates for the new behavior.

    Here's the actual implementation file in Home Assistant, which hasn't been updated in 5 months: https://github.com/home-assistant/core/blame/dev/homeassistant/components/api/__init__.py

    And the deployed docs page hasn't been updated in 2 months and doesn't contain any of this info AFAIK: https://github.com/home-assistant/developers.home-assistant/blame/master/docs/api/rest.md

    And the REST API dev docs has a simple SWAGGER tool that also doesn't define parameters (or outputs):
    https://developers.home-assistant.io/docs/api/rest/

    Am I just missing something? Or does someone understand this a little better than me? I can definitely reproduce the issue by upgrading. I just don't see why this is the only project affected or what proper procedures are expected

    Edit: I think it might be related to this => home-assistant/core#147120

    This also has a dev blog post: https://developers.home-assistant.io/blog/2025/10/24/service-web-api-changes/

  3. GrandMoff100 commented on Nov 11, 2025

    @GrandMoff100
    Collaborator

    The Service model in homeassistant_api/models/domains.py should be updated to make the name field optional, or provide a default value when it's missing from the API response. This would maintain backward compatibility while handling the new API format.

    It seems like name is indeed optional in the official Service schema so I agree it should be just an easy fix.

  4. linked a pull request that will close this issueMake `Service.name` an optional field #218on Nov 11, 2025
  5. GrandMoff100 commented on Nov 11, 2025

    @GrandMoff100
    Collaborator
  6. scheidtdav commented on Dec 6, 2025

    @scheidtdav

    I am facing a very related issue with Home Assistant 2025.12. and the get_domains() call:

    pydantic_core._pydantic_core.ValidationError: 4 validation errors for Service
    fields.file.ServiceField.selector.media.multiple
      Extra inputs are not permitted [type=extra_forbidden, input_value=False, input_type=bool]
        For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
    fields.file.ServiceFieldCollection.fields
      Field required [type=missing, input_value={'required': True, 'selec...'], 'multiple': False}}}, input_type=dict]
        For further information visit https://errors.pydantic.dev/2.12/v/missing
    fields.file.ServiceFieldCollection.required
      Extra inputs are not permitted [type=extra_forbidden, input_value=True, input_type=bool]
        For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
    fields.file.ServiceFieldCollection.selector
      Extra inputs are not permitted [type=extra_forbidden, input_value={'media': {'accept': ['im...*'], 'multiple': False}}, input_type=dict]
        For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
    

    I could not find information on changes though.
    Steps to reproduce are exactly as originally outlined.

    @GrandMoff100 can this be reopened or should I create a new issue?

  7. konetzed commented on Dec 14, 2025

    @konetzed

    Upgraded last night to find out all my scripts are broken.

    Version info

    Installation method Home Assistant OS
    Core 2025.12.3
    Supervisor 2025.12.3
    Operating System 16.3
    Frontend 20251203.2
    

    Traceback output

    Traceback (most recent call last):
      File "/home/konetzed/venv/ha/shed_lights.py", line 18, in <module>
        switch = client.get_domain("switch")
      File "/home/konetzed/venv/ha/lib/python3.13/site-packages/homeassistant_api/rawclient.py", line 288, in get_domain
        return self.get_domains().get(domain_id)
               ~~~~~~~~~~~~~~~~^^
      File "/home/konetzed/venv/ha/lib/python3.13/site-packages/homeassistant_api/rawclient.py", line 281, in get_domains
        return {domain.domain_id: domain for domain in domains}
                                                       ^^^^^^^
      File "/home/konetzed/venv/ha/lib/python3.13/site-packages/homeassistant_api/rawclient.py", line 278, in <lambda>
        lambda json: Domain.from_json(json, client=cast(Client, self)),
                     ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/konetzed/venv/ha/lib/python3.13/site-packages/homeassistant_api/models/domains.py", line 68, in from_json
        domain._add_service(service_id, **data)
        ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
      File "/home/konetzed/venv/ha/lib/python3.13/site-packages/homeassistant_api/models/domains.py", line 76, in _add_service
        service_id: Service(
                    ~~~~~~~^
            service_id=service_id,
            ^^^^^^^^^^^^^^^^^^^^^^
            domain=self,
            ^^^^^^^^^^^^
            **data,
            ^^^^^^^
        )
        ^
      File "/home/konetzed/venv/ha/lib/python3.13/site-packages/pydantic/main.py", line 250, in __init__
        validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    pydantic_core._pydantic_core.ValidationError: 5 validation errors for Service
    fields.media.ServiceField.selector.media.multiple
      Extra inputs are not permitted [type=extra_forbidden, input_value=False, input_type=bool]
        For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
    fields.media.ServiceFieldCollection.fields
      Field required [type=missing, input_value={'required': True, 'selec...ontent_type": "music"}'}, input_type=dict]
        For further information visit https://errors.pydantic.dev/2.12/v/missing
    fields.media.ServiceFieldCollection.required
      Extra inputs are not permitted [type=extra_forbidden, input_value=True, input_type=bool]
        For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
    fields.media.ServiceFieldCollection.selector
      Extra inputs are not permitted [type=extra_forbidden, input_value={'media': {'multiple': False}}, input_type=dict]
        For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
    fields.media.ServiceFieldCollection.example
      Extra inputs are not permitted [type=extra_forbidden, input_value='{"media_content_id": "ht...content_type": "music"}', input_type=str]
        For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
    

    Currently on HomeAssistant-API 5.0.2.post1

  8. LukeBoland commented on Dec 15, 2025

    @LukeBoland
    Core                                2025.12.3
    Supervisor                       2025.12.3
    Operating System           16.3
    Frontend                         20251203.2
    HomeAssistant-API         5.0.2.post1
    

    Both get_domains() and get_domain() fail

      service = client.get_domains()
                ^^^^^^^^^^^^^^^^^
    File "C:\Users\user\Documents\dev\Python\RpiDash\RpiDash\Lib\site-packages\homeassistant_api\rawclient.py", line 281, in get_domains
      return {domain.domain_id: domain for domain in domains}
                                                     ^^^^^^^
    File "C:\Users\user\Documents\dev\Python\RpiDash\RpiDash\Lib\site-packages\homeassistant_api\rawclient.py", line 278, in <lambda>
      lambda json: Domain.from_json(json, client=cast(Client, self)),
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\user\Documents\dev\Python\RpiDash\RpiDash\Lib\site-packages\homeassistant_api\models\domains.py", line 68, in from_json
      domain._add_service(service_id, **data)
    File "C:\Users\user\Documents\dev\Python\RpiDash\RpiDash\Lib\site-packages\homeassistant_api\models\domains.py", line 76, in _add_service
      service_id: Service(
                  ^^^^^^^^
    File "C:\Users\user\Documents\dev\Python\RpiDash\RpiDash\Lib\site-packages\pydantic\main.py", line 250, in __init__
      validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    pydantic_core._pydantic_core.ValidationError: 5 validation errors for Service
    fields.media.ServiceField.selector.media.multiple
    Extra inputs are not permitted [type=extra_forbidden, input_value=False, input_type=bool]
      For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
    fields.media.ServiceFieldCollection.fields
    Field required [type=missing, input_value={'required': True, 'selec...ontent_type": "music"}'}, input_type=dict]
      For further information visit https://errors.pydantic.dev/2.12/v/missing
    fields.media.ServiceFieldCollection.required
    Extra inputs are not permitted [type=extra_forbidden, input_value=True, input_type=bool]
      For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
    fields.media.ServiceFieldCollection.selector
    Extra inputs are not permitted [type=extra_forbidden, input_value={'media': {'multiple': False}}, input_type=dict]
      For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
    fields.media.ServiceFieldCollection.example
    Extra inputs are not permitted [type=extra_forbidden, input_value='{"media_content_id": "ht...content_type": "music"}', input_type=str]
      For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden```
    
  9. GrandMoff100 commented on Dec 24, 2025

    @GrandMoff100
    Collaborator

    Hi guys! @LukeBoland @konetzed @scheidtdav Sorry, I've been caught up with finals and Christmas, but one temporary workaround that seems to work is to modify the model config at runtime

    from homeassistant_api.models.base import BaseModel
    
    BaseModel.model_config.pop("extra", None)

    Home Assistant seems to changed the schema of service models on us and I will try to work on it over the holidays.

    Please let me know if this workaround works for y'all, and I just ask for your patience.

  10. GrandMoff100 commented on Dec 25, 2025

    @GrandMoff100
    Collaborator

    I think I've fixed it. It seems like just an extra multiple flag inside ServiceFieldSelectorMedia did the trick?

    https://pypi.org/project/HomeAssistant-API/5.0.2.post2/

  11. konetzed commented on Dec 25, 2025

    @konetzed

    Tested and my scripts are working after upgrade to HomeAssistant-API-5.0.2.post2, TYVM!

  12. GrandMoff100 commented on Dec 25, 2025

    @GrandMoff100
    Collaborator

    Merry Christmas!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions