Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.2.25
- Handle zeroconf discovery payloads delivered as objects to avoid setup errors when reconfiguring.
- Format container list strings with spaces after commas for readability.

## v1.2.24
- Added a number box input for configuring the update interval during setup and in the options flow.
- Parallelized initial coordinator refreshes to speed up startup when multiple servers are configured.
Expand Down
16 changes: 12 additions & 4 deletions custom_components/vserver_ssh_stats/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,24 @@ async def async_step_user(self, user_input: dict[str, Any] | None = None):
errors=errors,
)

async def async_step_zeroconf(self, discovery_info: dict[str, Any]):
async def async_step_zeroconf(self, discovery_info: Any):
"""Handle zeroconf discovery."""

host = discovery_info.get("host")
if isinstance(discovery_info, dict):
host = discovery_info.get("host")
name = discovery_info.get("hostname", host)
else:
host = getattr(discovery_info, "host", None)
name = (
getattr(discovery_info, "hostname", None)
or getattr(discovery_info, "name", None)
or host
)
if not host:
return self.async_abort(reason="unknown")
if self._host_already_configured(host):
return self.async_abort(reason="already_configured")
self._discovered_host = host
self._discovered_name = discovery_info.get("hostname", host)
self._discovered_name = name
self.context["title_placeholders"] = {"name": self._discovered_name}
return await self.async_step_user()

Expand Down
1 change: 1 addition & 0 deletions custom_components/vserver_ssh_stats/remote_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
docker=1
containers=$(docker ps --format '{{.Names}}' 2>/dev/null | tr '\n' ',' )
containers=$(trim_comma "$containers")
containers=${containers//,/, }
stats=$(docker stats --no-stream --format '{{.Name}}:{{.CPUPerc}}:{{.MemPerc}}' 2>/dev/null | sed 's/%//g' |
awk -F: '{cpu=$2+0; mem=$3+0; printf "{\"name\":\"%s\",\"cpu\":%.2f,\"mem\":%.2f},", $1, cpu, mem}')
if [ -n "$stats" ]; then
Expand Down