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

Rename object fields to directly match original names #185

Merged
merged 1 commit into from
Jan 26, 2025
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
2 changes: 1 addition & 1 deletion examples/load_groups/dump_load_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def main() -> None:
# Print out the id, name, and members of each load group
async for load_group in vantage.load_groups:
print(
f"[{load_group.id}] '{load_group.name}' loads={load_group.load_ids} level={load_group.level}%"
f"[{load_group.id}] '{load_group.name}' loads={load_group.load_table} level={load_group.level}%"
)


Expand Down
2 changes: 1 addition & 1 deletion src/aiovantage/controllers/blind_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def blinds(self, vid: int) -> QuerySet[BlindBase]:
if isinstance(blind_group, BlindGroup):

def _filter1(blind: BlindBase) -> bool:
return blind.id in blind_group.blind_ids
return blind.id in blind_group.blind_table

return self._vantage.blinds.filter(_filter1)

Expand Down
2 changes: 1 addition & 1 deletion src/aiovantage/controllers/load_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ def loads(self, vid: int) -> QuerySet[Load]:
"""Return a queryset of all loads in this load group."""
load_group = self[vid]

return self._vantage.loads.filter(lambda load: load.id in load_group.load_ids)
return self._vantage.loads.filter(lambda load: load.id in load_group.load_table)
4 changes: 2 additions & 2 deletions src/aiovantage/objects/blind_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
class BlindBase(SystemObject):
"""Blind base class."""

orientation: str | None = field(
shade_orientation: str | None = field(
default=None,
metadata={
"name": "ShadeOrientation",
"type": "Attribute",
},
)

type: str | None = field(
shade_type: str | None = field(
default=None,
metadata={
"name": "ShadeType",
Expand Down
2 changes: 1 addition & 1 deletion src/aiovantage/objects/blind_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class BlindGroup(BlindGroupBase, LocationObject):
"""BlindGroup object."""

blind_ids: list[int] = field(
blind_table: list[int] = field(
default_factory=list,
metadata={
"name": "Blind",
Expand Down
6 changes: 3 additions & 3 deletions src/aiovantage/objects/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ class Button(SystemObject):
}
)

down_id: int = field(
down: int = field(
metadata={
"name": "Down",
}
)

up_id: int = field(
up: int = field(
metadata={
"name": "Up",
}
)

hold_id: int = field(
hold: int = field(
metadata={
"name": "Hold",
}
Expand Down
2 changes: 1 addition & 1 deletion src/aiovantage/objects/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Load(LocationObject):
}
)

power_profile_id: int = field(
power_profile: int = field(
metadata={
"name": "PowerProfile",
}
Expand Down
2 changes: 1 addition & 1 deletion src/aiovantage/objects/load_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class LoadGroup(LocationObject):
"""LoadGroup object."""

load_ids: list[int] = field(
load_table: list[int] = field(
default_factory=list,
metadata={
"name": "Load",
Expand Down
2 changes: 1 addition & 1 deletion src/aiovantage/objects/location_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LocationObject(SystemObject):
"""Base class for system objects in an area."""

# Some objects in firmware 2.x do not have an area_id
area_id: int | None = field(
area: int | None = field(
default=None,
metadata={
"name": "Area",
Expand Down
2 changes: 1 addition & 1 deletion src/aiovantage/objects/station_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class StationObject(LocationObject):
}
)

bus_id: int = field(
bus: int = field(
metadata={
"name": "Bus",
}
Expand Down
16 changes: 13 additions & 3 deletions src/aiovantage/objects/system_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
class SystemObject:
"""Base class for all objects."""

id: int = field(
vid: int = field(
metadata={
"name": "VID",
"type": "Attribute",
}
)

master_id: int = field(
master: int = field(
metadata={
"name": "Master",
"type": "Attribute",
Expand Down Expand Up @@ -51,13 +51,23 @@ class SystemObject:
)

# Not available in 2.x firmware
display_name: str | None = field(
dname: str | None = field(
default=None,
metadata={
"name": "DName",
},
)

@property
def id(self) -> int:
"""Return the ID of the object."""
return self.vid

@property
def display_name(self) -> str:
"""Return the display name of the object."""
return self.dname or self.name

@classmethod
def vantage_type(cls) -> str:
"""Return the Vantage type for this object."""
Expand Down
Loading