home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.29k stars 30.61k forks source link

Cambridge Audio Azur 851N reporting Field "preferred_order" of type int is missing in Source instance #129139

Open paulcsiki opened 1 week ago

paulcsiki commented 1 week ago

The problem

On a Cambridge Audio Network Receiver with Firmware: 1.10+0.5+8e and Service Pack: v022-a-151+a you cannot add it in HA Core 2024.10.3 and Frontend 20241002.3 as it says that an unknown error has occurred. Here's the relevant log entry:

Logger: aiohttp.server
Source: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:448
First occurred: 10:17:30 AM (8 occurrences)
Last logged: 10:17:42 AM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 477, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 559, in _handle
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 370, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 417, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 520, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/cambridge_audio/config_flow.py", line 75, in async_step_user
    await client.connect()
  File "/usr/local/lib/python3.12/site-packages/aiostreammagic/stream_magic.py", line 87, in connect
    return await self.connect_result
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiostreammagic/stream_magic.py", line 149, in _connect_handler
    ) = await asyncio.gather(
        ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiostreammagic/stream_magic.py", line 280, in get_sources
    sources = [Source.from_dict(x) for x in data["params"]["data"]["sources"]]
               ^^^^^^^^^^^^^^^^^^^
  File "<string>", line 27, in __mashumaro_from_dict__
mashumaro.exceptions.MissingField: Field "preferred_order" of type int is missing in Source instance

What version of Home Assistant Core has the issue?

2024.10.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Cambridge Audio

Link to integration documentation on our website

https://www.home-assistant.io/integrations/cambridge_audio

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 week ago

Hey there @noahhusby, mind taking a look at this issue as it has been labeled with an integration (cambridge_audio) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `cambridge_audio` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign cambridge_audio` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


cambridge_audio documentation cambridge_audio source (message by IssueLinks)

noahhusby commented 1 week ago

Hello,

The Azur 851N uses an older version of the StreamMagic engine which sometimes results in some fields missing. We likely just need to set some defaults on the library side.

Can you please go to these links and share the result from the Cambridge Audio device? (If it's a 404 / Not Found, please indicate as such):

  1. https:[your Cambridge IP address]/smoip/system/info
  2. https:[your Cambridge IP address]/smoip/system/sources
  3. https:[your Cambridge IP address]/smoip/system/update
  4. https:[your Cambridge IP address]/smoip/zone/state

Replace [your Cambridge IP address] with the actual device IP 😄

paulcsiki commented 1 week ago

Hi @noahhusby,

My Azur 851N doesn't seem to be listening on HTTPS so I have used HTTP for these calls.

http://192.168.40.237/smoip/system/info

{
  "data": {
    "name": "Office DAC",
    "timezone": "Europe/Dublin",
    "locale": "en_GB",
    "usage_reports": false,
    "setup": true,
    "sources_setup": true,
    "versions": [
      {
        "component": "MCU",
        "version": "1.10+0.5+8e"
      },
      {
        "component": "service-pack",
        "version": "v022-a-151+a"
      },
      {
        "component": "application",
        "version": "1.0+gitAUTOINC+a94a3e2ad8"
      }
    ],
    "udn": "0ef5d1f0-e092-4fad-88b1-35cc130da67a",
    "hcv": 2503,
    "model": "851N",
    "unit_id": "000d77dd",
    "max_http_body_size": 65536,
    "api": "1.8"
  }
}

http://192.168.40.237/smoip/system/sources

{
  "data": {
    "sources": [
      {
        "id": "IR",
        "name": "Internet Radio",
        "default_name": "Internet Radio",
        "class": "stream.radio",
        "nameable": false,
        "ui_selectable": false,
        "description": "Internet Radio",
        "description_locale": "Internet Radio",
        "preferred_order": 11
      },
      {
        "id": "USB_AUDIO",
        "name": "USB Audio",
        "default_name": "USB Audio",
        "class": "digital.usb",
        "nameable": true,
        "ui_selectable": true,
        "description": "USB Audio",
        "description_locale": "USB Audio",
        "preferred_order": 1
      },
      {
        "id": "SPDIF_COAX",
        "name": "D3",
        "default_name": "D3",
        "class": "digital.coax",
        "nameable": true,
        "ui_selectable": false,
        "description": "Digital Co-axial",
        "description_locale": "Digital Co-axial",
        "preferred_order": 4
      },
      {
        "id": "SPDIF_TOSLINK",
        "name": "D4",
        "default_name": "D4",
        "class": "digital.toslink",
        "nameable": true,
        "ui_selectable": false,
        "description": "Digital Optical",
        "description_locale": "Digital Optical",
        "preferred_order": 5
      },
      {
        "id": "MEDIA_PLAYER",
        "name": "Media Library",
        "default_name": "Media Library",
        "class": "stream.media",
        "nameable": false,
        "ui_selectable": false,
        "description": "Media Player",
        "description_locale": "Media Player",
        "preferred_order": 12
      },
      {
        "id": "SPDIF_COAX2",
        "name": "D1",
        "default_name": "D1",
        "class": "digital.coax",
        "nameable": true,
        "ui_selectable": false,
        "description": "Digital Co-axial",
        "description_locale": "Digital Co-axial",
        "preferred_order": 2
      },
      {
        "id": "SPDIF_TOSLINK2",
        "name": "D2",
        "default_name": "D2",
        "class": "digital.toslink",
        "nameable": true,
        "ui_selectable": false,
        "description": "Digital Optical",
        "description_locale": "Digital Optical",
        "preferred_order": 3
      },
      {
        "id": "AES_EBU",
        "name": "D5",
        "default_name": "D5",
        "class": "digital.aes",
        "nameable": true,
        "ui_selectable": false,
        "description": "Digital AES/EBU",
        "description_locale": "Digital AES/EBU",
        "preferred_order": 6
      },
      {
        "id": "AIRPLAY",
        "name": "AirPlay",
        "default_name": "AirPlay",
        "class": "stream.service.airplay",
        "nameable": false,
        "ui_selectable": false,
        "description": "AirPlay",
        "description_locale": "AirPlay",
        "preferred_order": 13
      },
      {
        "id": "SPOTIFY",
        "name": "Spotify",
        "default_name": "Spotify",
        "class": "stream.service.spotify",
        "nameable": false,
        "ui_selectable": true,
        "description": "Spotify",
        "description_locale": "Spotify",
        "preferred_order": 8,
        "normalisation": "off"
      },
      {
        "id": "ROON",
        "name": "Roon Ready",
        "default_name": "Roon Ready",
        "class": "stream.service.roon",
        "nameable": false,
        "ui_selectable": false,
        "description": "Roon Ready",
        "description_locale": "Roon Ready"
      },
      {
        "id": "TIDAL",
        "name": "TIDAL Connect",
        "default_name": "TIDAL Connect",
        "class": "stream.service.tidal",
        "nameable": false,
        "ui_selectable": false,
        "description": "TIDAL",
        "description_locale": "TIDAL",
        "preferred_order": 9
      }
    ]
  }
}

http://192.168.40.237/smoip/system/update

{
  "data": {
    "early_update": false,
    "update_available": false,
    "updating": false
  }
}

http://192.168.40.237/smoip/zone/state

{
  "zone": "ZONE1",
  "data": {
    "source": "IDLE",
    "power": false,
    "pre_amp_mode": true,
    "pre_amp_state": "on",
    "mute": false,
    "volume_step": 12,
    "volume_percent": 40,
    "volume_db": -38,
    "cbus": "amplifier"
  }
}

Hope this helps.

noahhusby commented 1 week ago

This is helpful, thanks.

Looks like preferred_order is optional for sources. I'll patch this for the upcoming November release.