Skip to content

Commit

Permalink
Merge pull request #96 from loopj/fix-firmware-version-lookup
Browse files Browse the repository at this point in the history
Fix firmware version lookup
  • Loading branch information
loopj authored Apr 10, 2024
2 parents fbd0114 + cecd028 commit 712cdb7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
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]

0 comments on commit 712cdb7

Please sign in to comment.