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

Fix firmware version lookup #96

Merged
merged 1 commit into from
Apr 10, 2024
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
6 changes: 5 additions & 1 deletion examples/masters/dump_masters.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ async def main() -> None:
async with Vantage(args.host, args.username, args.password) as vantage:
# Print out the id and name of each Vantage controller
async for master in vantage.masters:
print(f"[{master.id}] '{master.name}' serial_number={master.serial_number}")
print(
f"[{master.id}] '{master.name}' "
f"serial_number={master.serial_number} "
f"firmware_version={master.firmware_version}"
)


with contextlib.suppress(KeyboardInterrupt):
Expand Down
23 changes: 14 additions & 9 deletions src/aiovantage/controllers/masters.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,9 @@ class MastersController(
@override
async def fetch_object_state(self, vid: int) -> None:
"""Fetch the state properties of a Vantage controller."""
state: dict[str, Any] = {}

# IntrospectionInterface is not available on 2.x firmware.
with suppress(CommandError):
state["firmware_version"] = (
await IntrospectionInterface.get_firmware_version(
self, vid, self.Firmware.Application
)
)
state: dict[str, Any] = {
"firmware_version": await self.get_version(),
}

# ObjectInterface is not available on 2.x firmware.
with suppress(CommandError):
Expand All @@ -58,3 +52,14 @@ def handle_interface_status(
}

self.update_state(vid, state)

async def get_version(self) -> str:
"""Get the firmware version of a Vantage controller.

Returns:
The firmware version of the controller.
"""
# VERSION
# -> R:VERSION {version}
response = await self.command_client.command("VERSION")
return response.args[0]
Loading