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

Refactor supported hubs/servers and load them from pyhoma #418

Merged
merged 14 commits into from
Aug 10, 2021

Conversation

iMicknl
Copy link
Owner

@iMicknl iMicknl commented Apr 13, 2021

Backported from core PR. Eventually it would be good to maybe rename this to 'manufacturer', since I removed the model names (Tahoma / Connexoon) from the list. Apparently Somfy has server regions, which I identified as Connexoon RTS in the past...

@iMicknl iMicknl marked this pull request as draft April 13, 2021 13:21
@github-actions github-actions bot added the enhancement New feature or request label Apr 13, 2021
@iMicknl
Copy link
Owner Author

iMicknl commented May 27, 2021

I should add

"Hi Kumo (Europe)": "https://ha117-1.overkiz.com/enduser-mobile-web/enduserAPI/",
"Hi Kumo (Asia)": "https://ha203-1.overkiz.com/enduser-mobile-web/enduserAPI/",
"Hi Kumo (Oceania)": "https://ha203-1.overkiz.com/enduser-mobile-web/enduserAPI/",

as well!

@tetienne
Copy link
Collaborator

Where did you find these ones?

@iMicknl
Copy link
Owner Author

iMicknl commented May 27, 2021

Where did you find these ones?

I pulled them from the original Hi Kumo iOS app.

@iMicknl iMicknl added the breaking Breaking Change label Jul 14, 2021
@iMicknl iMicknl marked this pull request as ready for review July 14, 2021 17:28
@iMicknl
Copy link
Owner Author

iMicknl commented Jul 21, 2021

@tetienne maybe we should have a different approach here, where we change to a different dictionary model with keys. It would be good to be able to change the cosmetic name, without breaking the integration in the future. Any suggestions?

@tetienne
Copy link
Collaborator

@tetienne maybe we should have a different approach here, where we change to a different dictionary model with keys. It would be good to be able to change the cosmetic name, without breaking the integration in the future. Any suggestions?

What about somethink like:

endpoints = {
  "endpoint_1": ("Tahoma", "https://..."),
  "endpoint_2: ("Overkiz", "https://...),
}

To the end user we display endpoints[i][0], and when it selects an endpoint we look for the key matching its choice in endpoints.

@iMicknl
Copy link
Owner Author

iMicknl commented Jul 22, 2021

To the end user we display endpoints[i][0], and when it selects an endpoint we look for the key matching its choice in endpoints.

Would it make sense to have them typed? So we don't have to pull them like endpoints[i][0]? I am not sure how to type them easily, but perhaps just like this? And maybe we should just add this to python-tahoma-api finally?

@dataclass
class Hub:
    """Class to describe a hub."""
    endpoint: str
    name: str
    manufacturer: str


endpoints = {
    "atlantic_cozytouch": Hub(
        name="Atlantic Cozytouch",
        endpoint="https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/",
        manufacturer="Atlantic",
    ),
}

@iMicknl iMicknl changed the title Add Somfy North America and restructure hubs Refactor supported hubs/servers and load them from pyhoma Aug 4, 2021
@iMicknl
Copy link
Owner Author

iMicknl commented Aug 5, 2021

A Dutch user just verified that he has to use the Europe server with this Connexoon RTS. The new server list is correct thus :-).

@iMicknl iMicknl removed the breaking Breaking Change label Aug 9, 2021
@@ -90,21 +89,50 @@ async def async_setup(hass: HomeAssistant, config: dict):
return True


async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry):
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works like a charm! Doesn't make this PR breaking anymore, and easy to remove for core PR.

2021-08-09 22:41:33 DEBUG (MainThread) [custom_components.tahoma] Migrating from version 1
2021-08-09 22:41:33 INFO (MainThread) [custom_components.tahoma] Migrated Somfy TaHoma to somfy_europe
2021-08-09 22:41:33 INFO (MainThread) [custom_components.tahoma] Migration to version 2 successful

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@iMicknl iMicknl merged commit 162a839 into master Aug 10, 2021
@iMicknl iMicknl deleted the enhancement/restructure_endpoints branch August 10, 2021 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants