Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shelly: Download diagnostics result in HTTP-Error 500: KeyError: 'ws' #140471

Open
Commifreak opened this issue Mar 12, 2025 · 6 comments
Open

Shelly: Download diagnostics result in HTTP-Error 500: KeyError: 'ws' #140471

Commifreak opened this issue Mar 12, 2025 · 6 comments

Comments

@Commifreak
Copy link

Commifreak commented Mar 12, 2025

The problem

I setup a new Shelly AZ Plug (S3PL-10112EU). However, HA listing this device with model-code "unknown", so I wanted to download diagnostics. As soon as I hit the download button, I get HTTP-Error 500 in my browser.

HA logs this:

Logger: aiohttp.server
Quelle: /usr/local/lib/python3.13/site-packages/aiohttp/web_protocol.py:451
Erstmals aufgetreten: 16:37:10 (4 Vorkommnisse)
Zuletzt protokolliert: 20:13:11

Error handling request from 127.0.0.1
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/aiohttp/web_protocol.py", line 480, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/web_app.py", line 569, in _handle
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/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 77, 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 86, 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/diagnostics/__init__.py", line 282, in get
    data = await info.config_entry_diagnostics(hass, config_entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/shelly/diagnostics.py", line 77, in async_get_config_entry_diagnostics
    ws_config = rpc_coordinator.device.config["ws"]
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: 'ws'

Wanted to let u know.

What version of Home Assistant Core has the issue?

2025.2.4

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

Shelly

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

Anything in the logs that might be useful for us?

Additional information

Maybe the Shelly dev also could add this model in the known models list?

S3PL-10112EU => https://kb.shelly.cloud/knowledge-base/shelly-az-plug

It does NOT support Outbound websocket, but HA detected it and get live updates anyway.

@home-assistant
Copy link

Hey there @balloob, @bieniu, @thecode, @chemelli74, @bdraco, mind taking a look at this issue as it has been labeled with an integration (shelly) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of shelly 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 shelly 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)


shelly documentation
shelly source
(message by IssueLinks)

@thecode
Copy link
Member

thecode commented Mar 12, 2025

Thanks @Commifreak the issue is clear from the error, but just just to be sure can you add a debug log from the device?

Please enable Debug for Shelly integration, reload the device, disable debug and attach the log.

Note: it is better to drag the log into the comment (which will add it as an attachment) and not copy paste as it is hard to read logs in GitHub.

Thanks

@Commifreak
Copy link
Author

reload the device

Sorry, this seems unclear. HA teels me to do a additional restart to complete, but I dont know if you want that much data, so I decided to start with no restart. Attached.

And this lines comes from the "big" debug (with restart) - cherry picked by me:

2025-03-12 21:34:55.063 DEBUG (MainThread) [aioshelly.rpc_device.wsrpc] recv(192.168.178.56:80): {'id': 1, 'src': 'shellyazplug-e4b3232e1f4c', 'dst': 'aios-23359691362240', 'result': {'name': None, 'id': 'shellyazplug-e4b3232e1f4c', 'mac': 'E4B3232E1F4C', 'slot': 1, 'model': 'S3PL-10112EU', 'gen': 3, 'fw_id': '20241011-114453/1.4.4-g6d2a586', 'ver': '1.4.4', 'app': 'PlugAZ', 'auth_en': True, 'auth_domain': 'shellyazplug-e4b3232e1f4c'}}
2025-03-12 21:34:55.063 DEBUG (MainThread) [aioshelly.rpc_device.wsrpc] result(192.168.178.56:80): Shelly.GetDeviceInfo(None) -> {'name': None, 'id': 'shellyazplug-e4b3232e1f4c', 'mac': 'E4B3232E1F4C', 'slot': 1, 'model': 'S3PL-10112EU', 'gen': 3, 'fw_id': '20241011-114453/1.4.4-g6d2a586', 'ver': '1.4.4', 'app': 'PlugAZ', 'auth_en': True, 'auth_domain': 'shellyazplug-e4b3232e1f4c'}
2025-03-12 21:34:55.064 DEBUG (MainThread) [aioshelly.rpc_device.wsrpc] send(192.168.178.56:80): {'id': 2, 'method': 'Shelly.GetConfig', 'src': 'aios-23359691362240', 'dst': 'shellyazplug-e4b3232e1f4c', 'auth': {'realm': 'shellyazplug-e4b3232e1f4c', 'username': 'admin', 'nonce': 1741809895, 'cnonce': 1741811695, 'response': '7106ccc0b37af897abbe49bd790fe5d191a5d5cd1c16dbf5b94c1762c6b40cc6', 'algorithm': 'SHA-256'}}
2025-03-12 21:34:55.064 DEBUG (MainThread) [aioshelly.rpc_device.wsrpc] send(192.168.178.56:80): {'id': 3, 'method': 'Shelly.GetStatus', 'src': 'aios-23359691362240', 'dst': 'shellyazplug-e4b3232e1f4c', 'auth': {'realm': 'shellyazplug-e4b3232e1f4c', 'username': 'admin', 'nonce': 1741809895, 'cnonce': 1741811695, 'response': '7106ccc0b37af897abbe49bd790fe5d191a5d5cd1c16dbf5b94c1762c6b40cc6', 'algorithm': 'SHA-256'}}
2025-03-12 21:34:55.064 DEBUG (MainThread) [aioshelly.rpc_device.wsrpc] send(192.168.178.56:80): {'id': 4, 'method': 'Shelly.GetComponents', 'src': 'aios-23359691362240', 'params': {'dynamic_only': True}, 'dst': 'shellyazplug-e4b3232e1f4c', 'auth': {'realm': 'shellyazplug-e4b3232e1f4c', 'username': 'admin', 'nonce': 1741809895, 'cnonce': 1741811695, 'response': '7106ccc0b37af897abbe49bd790fe5d191a5d5cd1c16dbf5b94c1762c6b40cc6', 'algorithm': 'SHA-256'}}

If you indeed neede the full log (with restart of HA), let me know.

home-assistant_shelly_2025-03-12T20-35-54.276Z.log

@thecode
Copy link
Member

thecode commented Mar 12, 2025

I am mostly looking for the result of:

2025-03-12 21:34:55.064 DEBUG (MainThread) [aioshelly.rpc_device.wsrpc] send(192.168.178.56:80): {'id': 2, 'method': 'Shelly.GetConfig', 'src': 'aios-23359691362240', 'dst': 'shellyazplug-e4b3232e1f4c', 'auth': {'realm': 'shellyazplug-e4b3232e1f4c', 'username': 'admin', 'nonce': 1741809895, 'cnonce': 1741811695, 'response': '7106ccc0b37af897abbe49bd790fe5d191a5d5cd1c16dbf5b94c1762c6b40cc6', 'algorithm': 'SHA-256'}}
2025-03-12 21:34:55.064 DEBUG (MainThread) [aioshelly.rpc_device.wsrpc] send(192.168.178.56:80): {'id': 3, 'method': 'Shelly.GetStatus', 'src': 'aios-23359691362240', 'dst': 'shellyazplug-e4b3232e1f4c', 'auth': {'realm': 'shellyazplug-e4b3232e1f4c', 'username': 'admin', 'nonce': 1741809895, 'cnonce': 1741811695, 'response': '7106ccc0b37af897abbe49bd790fe5d191a5d5cd1c16dbf5b94c1762c6b40cc6', 'algorithm': 'SHA-256'}}

Which are not in the log. You can also just query them from the device:

http://192.168.178.56/rpc/Shelly.GetConfig
http://192.168.178.56/rpc/Shelly.GetStatus

feel free to mask WIFI name or other from the result

@Commifreak
Copy link
Author

Just saw another Exception within the attached log, maybe worth noting. I dont know if this is normal in this case?

aioshelly.exceptions.RpcCallError: (404, 'No handler for Script.List')

Thanks so far! 😃🙏

@Commifreak
Copy link
Author

You can also just query them from the device

No problem!

GetConfig
{
  "ble": {
    "enable": false,
    "rpc": {
      "enable": false
    },
    "observer": {
      "enable": false
    }
  },
  "cloud": {
    "enable": false,
    "server": "shellyffs-1-eu.shelly.cloud:6022/jrpc"
  },
  "mqtt": {
    "enable": false,
    "server": null,
    "client_id": "shellyazplug-e4b3232e1f4c",
    "user": null,
    "ssl_ca": null,
    "topic_prefix": "shellyazplug-e4b3232e1f4c",
    "rpc_ntf": true,
    "status_ntf": false,
    "enable_rpc": true,
    "enable_control": true
  },
  "plugs_ui": {
    "leds": {
      "mode": "power",
      "colors": {
        "switch:0": {
          "on": {
            "rgb": [
              0,
              100,
              0
            ],
            "brightness": 100
          },
          "off": {
            "rgb": [
              100,
              0,
              0
            ],
            "brightness": 100
          }
        },
        "power": {
          "brightness": 100
        }
      },
      "night_mode": {
        "enable": false,
        "brightness": 100,
        "active_between": []
      }
    },
    "controls": {
      "switch:0": {
        "in_mode": "momentary"
      }
    }
  },
  "switch:0": {
    "id": 0,
    "name": null,
    "initial_state": "off",
    "auto_on": false,
    "auto_on_delay": 60,
    "auto_off": false,
    "auto_off_delay": 60,
    "power_limit": 2500,
    "voltage_limit": 280,
    "autorecover_voltage_errors": false,
    "current_limit": 12
  },
  "sys": {
    "device": {
      "name": null,
      "mac": "E4B3232E1F4C",
      "fw_id": "20241011-114453/1.4.4-g6d2a586",
      "discoverable": true,
      "eco_mode": false
    },
    "location": {
      "tz": "Europe/Berlin",
      "lat": 51.7859,
      "lon": 11.1518
    },
    "debug": {
      "level": 2,
      "file_level": null,
      "mqtt": {
        "enable": false
      },
      "websocket": {
        "enable": false
      },
      "udp": {
        "addr": null
      }
    },
    "ui_data": {},
    "rpc_udp": {
      "dst_addr": null,
      "listen_port": null
    },
    "sntp": {
      "server": "time.google.com"
    },
    "cfg_rev": 10
  },
  "wifi": {
    "ap": {
      "ssid": "ShellyAZPlug-E4B3232E1F4C",
      "is_open": true,
      "enable": false
    },
    "sta": {
      "ssid": "WLAN L22",
      "is_open": false,
      "enable": true,
      "ipv4mode": "static",
      "ip": "192.168.178.56",
      "netmask": "255.255.255.0",
      "gw": "192.168.178.1",
      "nameserver": "192.168.178.1"
    },
    "sta1": {
      "ssid": null,
      "is_open": true,
      "enable": false,
      "ipv4mode": "dhcp",
      "ip": null,
      "netmask": null,
      "gw": null,
      "nameserver": null
    },
    "roam": {
      "rssi_thr": -80,
      "interval": 60
    }
  }
}
GetStatus
{
  "ble": {},
  "cloud": {
    "connected": false
  },
  "mqtt": {
    "connected": false
  },
  "plugs_ui": {},
  "switch:0": {
    "id": 0,
    "source": "button",
    "output": true,
    "apower": 73.6,
    "voltage": 236.5,
    "freq": 49.9,
    "current": 0.698,
    "aenergy": {
      "total": 234.207,
      "by_minute": [
        2102.357,
        1892.122,
        1892.122
      ],
      "minute_ts": 1741812900
    },
    "ret_aenergy": {
      "total": 0,
      "by_minute": [
        0,
        0,
        0
      ],
      "minute_ts": 1741812900
    },
    "temperature": {
      "tC": 39.1,
      "tF": 102.3
    }
  },
  "sys": {
    "mac": "E4B3232E1F4C",
    "restart_required": false,
    "time": "21:55",
    "unixtime": 1741812915,
    "uptime": 6626,
    "ram_size": 257604,
    "ram_free": 138184,
    "fs_size": 1048576,
    "fs_free": 663552,
    "cfg_rev": 10,
    "kvs_rev": 0,
    "schedule_rev": 0,
    "webhook_rev": 0,
    "available_updates": {
      "beta": {
        "version": "1.5.1-beta2"
      }
    },
    "reset_reason": 1
  },
  "wifi": {
    "sta_ip": "192.168.178.56",
    "status": "got ip",
    "ssid": "WLAN L22",
    "rssi": -52
  }
}

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

No branches or pull requests

7 participants