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

Add local API support to Overkiz integration (Somfy TaHoma Developer Mode) #71644

Merged
merged 90 commits into from
Nov 22, 2023

Conversation

iMicknl
Copy link
Contributor

@iMicknl iMicknl commented May 10, 2022

Proposed change

Adds support for the local API of Somfy Developer mode. The first implementation will only support one way of connecting your hub to HA, either local or cloud. Basic discovery features have been added.

Future PR's can add:

  • Improved discovery: show local and cloud discovery next to each other
  • Improved local discovery: show local discovery when an user already has a cloud entry
  • Support multiple connections (local and cloud) per hub, since climate devices can't be used via local API. This requires quite some work since the device ids (unique ids) are the same for local and cloud, plus the event listener will broadcast the same events.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@probot-home-assistant
Copy link

Hey there @vlebourl, @tetienne, mind taking a look at this pull request as it has been labeled with an integration (overkiz) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@nyroDev
Copy link
Contributor

nyroDev commented May 28, 2022

Hello @iMicknl,

Thanks for your work.

I'm new to the home assistant community, but I'm willing to help.
My instance is not in production, so I can mess up With it.

Can I help here in order to test the local mode?
If so, what's the correct way to do it?
(I already test it on my own with the developer mode activated on my Tahoma)

@MartinHjelmare MartinHjelmare added this to Incoming in Dev Jun 26, 2022
@iMicknl
Copy link
Contributor Author

iMicknl commented Jun 26, 2022

@nyroDev sorry for the late reply, I totally missed the notification. Can you send me a message on Discord? (iMick#1903).

@gregnebu
Copy link

gregnebu commented Nov 3, 2022

Hello some feedback,

I got an issue which was hard for me to debug, I finally found it by using Postman and reproducing the API calls.
The API was reporting 2 GW, one which is my Tahoma box and another one unknown...
I had to add a small patch for the plugin to choose the right gateway as it was simply taking the last (or first don't remember) one

In config_flow.py

            for gateway in gateways:
                # Generate tokens
                # TODO check if gateway is in the right format
                parsed_gw = re.search(r"(\d{4}-\d{4}-\d{4})", gateway.id)
                if parsed_gw and parsed_gw.groups() and len(parsed_gw.groups()) == 1:
                  gateway_id = gateway.id
                  break

Other issue I get, but related to the local API, I've a Protexiom Alarm linked to my Tahoma box, the protexiom elements a properly reported using the cloud API, but not reported through the local API

@Quentame
Copy link
Member

Quentame commented Nov 3, 2022

  • Autodiscover?
  • Should we show discovery config flow, when they already use cloud?
  • How do we handle local API and Somfy Cloud connections? Not everyone can just use the local API, since climate devices are not supported for example... Should we prefix our unique id?

As not all entities can be locally controlled (😢), I think we should still discover it and propose the user the config flow, but warn him if the config flow about those restrictions.
You can prepend or append local to the config_flow_id and the unique_id.

OR

Make a new integration, local based: overkiz_local ?

The problem could be much easier to solve if all entities could be local controlled.

@iMicknl
Copy link
Contributor Author

iMicknl commented Nov 4, 2022

@gregnebu can you describe your issue and add your diagnostics file to #69558? This will help us in further development.

The problem could be much easier to solve if all entities could be local controlled.

I fully agree and I am pushing Somfy on it, however I don't think we will see this change soon... So I will have a look at the options. Perhaps we should prefix everything with local for the local integration.

@MrJuliuss
Copy link

Somfy ecosystem seems to be down this evening, so any news about this PR ? 😁

I would like to help but I dont develop in python 😬

@iMicknl
Copy link
Contributor Author

iMicknl commented Jan 19, 2023

Somfy ecosystem seems to be down this evening, so any news about this PR ? 😁

@MrJuliuss, unfortunately I haven't had time lately since I just did return from a month of traveling. Coming weeks are very busy as well, so any help is welcome indeed. It can be with extensive testing, but mainly Python help is welcome haha.

@muraj238
Copy link

@iMicknl What kind of python help would you need? I'm very interested in local support of the cover tilt, which is not accessible via the homekit integration. I'm just now deciding, if it's better to buy Somfy Tahoma, or the Vellux KLF200 controller. Somfy would be better, if the tilt support was going to be there someday. (Can you please confirm this?) I code in python at work, maybe I could help you, although I don't have much free time lately. I have covers with the Somfy J4 io Protect motors.

@iMicknl
Copy link
Contributor Author

iMicknl commented Mar 21, 2023

@muraj238 if you could add me on Discord (iMick#1903) we can discuss. Unfortunately last months I have been very busy with work, so no time to really work on this integration anymore...

@badewanne1234
Copy link
Contributor

@muraj238 FYI, cover tilt in Homekit Controller is fixed but not yet in a PR. You can apply the fix when creating a custom component. I need to add tests (which I'm not familiar with). If you can help out with tests, that would be great. See #63068 (comment) for more info.

@muraj238
Copy link

@muraj238 FYI, cover tilt in Homekit Controller is fixed but not yet in a PR. You can apply the fix when creating a custom component. I need to add tests (which I'm not familiar with). If you can help out with tests, that would be great. See #63068 (comment) for more info.

I was told it's not a bug or missing feature in HomeKit Controller, but something Apple has to implement.

@muraj238
Copy link

@muraj238 if you could add me on Discord (iMick#1903) we can discuss. Unfortunately last months I have been very busy with work, so no time to really work on this integration anymore...

Added you yesterday with one of my old gaming names Setan Fajces. :⁠-⁠)

@badewanne1234
Copy link
Contributor

@muraj238 FYI, cover tilt in Homekit Controller is fixed but not yet in a PR. You can apply the fix when creating a custom component. I need to add tests (which I'm not familiar with). If you can help out with tests, that would be great. See #63068 (comment) for more info.

I was told it's not a bug or missing feature in HomeKit Controller, but something Apple has to implement.

Not sure how you come to this conclusion... Its working flawlessly with Homekit with the fix in a couple of environments already, including mine.

@muraj238
Copy link

@muraj238 FYI, cover tilt in Homekit Controller is fixed but not yet in a PR. You can apply the fix when creating a custom component. I need to add tests (which I'm not familiar with). If you can help out with tests, that would be great. See #63068 (comment) for more info.

I was told it's not a bug or missing feature in HomeKit Controller, but something Apple has to implement.

Not sure how you come to this conclusion... Its working flawlessly with Homekit with the fix in a couple of environments already, including mine.

Thanks. I'll try as soon as the Tahoma Switch arrives. If it works, I'll help you with tests or with whatever will be needed. :⁠-⁠)

Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

Looks great 👍

homeassistant/components/overkiz/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/overkiz/strings.json Outdated Show resolved Hide resolved
Dev automation moved this from Review in progress to Reviewer approved Nov 22, 2023
@emontnemery emontnemery merged commit 75f237b into home-assistant:dev Nov 22, 2023
23 checks passed
Dev automation moved this from Reviewer approved to Done Nov 22, 2023
@iMicknl iMicknl deleted the overkiz/local_support branch November 22, 2023 16:08
@magicus
Copy link
Member

magicus commented Nov 22, 2023

@iMicknl Thank you for your hard work and effort of getting this integrated! ❤️ 🎉

@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

Implement Somfy local API in Overkiz integration