Skip to content

Commit

Permalink
Merge pull request #40 from peribeir/dev
Browse files Browse the repository at this point in the history
Change uid of hub to macaddress
  • Loading branch information
peribeir authored Jun 10, 2023
2 parents 4fab08f + c87b7c9 commit e992206
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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

0 comments on commit e992206

Please sign in to comment.