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

Change uid of hub to macaddress #40

Merged
merged 2 commits into from
Jun 10, 2023
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
11 changes: 10 additions & 1 deletion homepilot/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,26 @@ def __init__(
def build_from_api(api: HomePilotApi, did: str):
return asyncio.run(HomePilotHub.async_build_from_api(api, did))

@staticmethod
async def get_hub_macaddress(api):
interfaces = await api.async_get_interfaces()
for k in interfaces["interfaces"]:
if interfaces["interfaces"][k]["enabled"] == True:
return interfaces["interfaces"][k]["address"]
return None

@staticmethod
async def async_build_from_api(api: HomePilotApi, did):
fw_version = await api.async_get_fw_version()
mac_address = await self.get_hub_macaddress(api)
nodename: str = (await api.async_get_nodename())["nodename"]
capabilities_map = HomePilotDevice.get_capabilities_map(
HomePilotHub.get_capabilities()
)
return HomePilotHub(
api=api,
did=capabilities_map[APICAP_ID_DEVICE_LOC]["value"],
uid=api.host,
uid=mac_address.replace(":", "") if mac_address is not None else api.host,
name=nodename.capitalize(),
device_number=capabilities_map[APICAP_PROD_CODE_DEVICE_LOC]["value"],
model="Start2Smart"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pyrademacher",
version="0.9.14",
version="0.9.15",
author="Pedro Ribeiro",
author_email="pedroeusebio@gmail.com",
description="Control devices connected to your Rademacher Homepilot "
Expand Down