Skip to content

Add support for multiple N26 accounts#24345

Closed
gorynychzmey wants to merge 620 commits into
home-assistant:devfrom
gorynychzmey:dev
Closed

Add support for multiple N26 accounts#24345
gorynychzmey wants to merge 620 commits into
home-assistant:devfrom
gorynychzmey:dev

Conversation

@gorynychzmey
Copy link
Copy Markdown
Contributor

@gorynychzmey gorynychzmey commented Jun 6, 2019

Breaking Change:

Changed generation of unique ids for spaces. Previous format was space_<name>, new format is space_<iban[-4:]_<name>. Otherwise we cannot guarantee uniqueness of ids in case of two accounts have spaces with same name, f.e. "main" spaces have always same name by default.

The stale spaces (with old ids) need to be removed from registry.

Description:

Added support for multiple N26 accounts.

Docs PR:

home-assistant/home-assistant.io#9577

Example entry for configuration.yaml (if applicable):

n26:                                                                                                                                                   
    - username: email1@example.com                                                                                                                    
      password: !secret n26_password1                                                                                                                     
    - username: email2@example.com 
      password: !secret n26_password2    

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

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. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

Comment thread homeassistant/components/n26/__init__.py Outdated
Comment thread homeassistant/components/n26/__init__.py Outdated
Comment thread homeassistant/components/n26/__init__.py Outdated
Comment thread homeassistant/components/n26/sensor.py Outdated
Comment thread homeassistant/components/n26/sensor.py Outdated
Comment thread homeassistant/components/n26/sensor.py Outdated
Comment thread homeassistant/components/n26/switch.py Outdated
@@ -15,12 +15,17 @@ def setup_platform(
hass, config, add_entities, discovery_info=None):
"""Set up the N26 switch platform."""
api_data = hass.data[DOMAIN][DATA]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please make all the same changes in this module as above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've made all the changes you've mentioned, but can't pass check - it fails for Python 3.7 in module, which I've never thought to change. I suppose that failure is temporary. Can I somehow redo check later?

@MartinHjelmare MartinHjelmare changed the title Added support for multiple N26 accounts Add support for multiple N26 accounts Jul 11, 2019
@MartinHjelmare
Copy link
Copy Markdown
Member

Please add to the breaking change paragraph what the user needs to do to cope with the breaking change. In this case, the user needs to remove existing stale entities from the entity registry.

hass, config, add_entities, discovery_info=None):
"""Set up the N26 sensor platform."""
api_data = hass.data[DOMAIN][DATA]
api_list = hass.data[DOMAIN][DATA]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add a guard clause here that checks if discovery_info is None and return if so.

api_list = hass.data[DOMAIN][DATA]

sensor_entities = [N26Account(api_data)]
if api_list is None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The api_list can never be None. We can remove this.

api_data = hass.data[DOMAIN][DATA]
api_list = hass.data[DOMAIN][DATA]

if api_list is None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See above.

@MartinHjelmare
Copy link
Copy Markdown
Member

Please rebase on latest dev branch to let the build pass.

@gorynychzmey gorynychzmey requested a review from a team as a code owner July 11, 2019 15:20
andrewsayre and others added 20 commits July 11, 2019 20:39
…ytadin component (#24652)

* Fix AttributeError: 'NoneType' object has no attribute 'group'

* Update sensor.py
* braviatv, nmap_tracker: use getmac for getting MAC addresses

Refs #24601

* Move getmac imports to top level
* Breaking change: Rewrite opentherm_gw to add support for more than one OpenTherm Gateway.
Breaks config layout and child entity ids and adds a required parameter to all service calls (gateway_id).

* Add schema and parameter description for service opentherm_gw.reset_gateway.

* Add optional name attribute in config to be used for friendly names.
Fix bugs in binary_sensor and climate platforms.

* pylint fixes

* Remove unused variables.

* Update manifest.json, remove REQUIREMENTS from .py file

* Update CODEOWNERS

* Address issues that were brought up (requested changes):
- Move imports to module level
- Change certain functions from async to sync
- Move constants to const.py (new file)
- Call gateway setup from outside of __init__()
- Move validation of monitored_variables to config schema

* Address requested changes:
- Make module imports relative
- Move more functions from async to sync, decorate with @callback where necessary
- Remove monitored_variables option, add all sensors by default
* Vlc telnet first commit

First functional version, remains to add more functionality.

* New functions added and bugfixes

* Compliance with dev checklist

* Compliance with dev checklist

* Compliance with pydocstyle

* Removed unused import

* Fixed wrong reference for exception

* Module renamed

* Fixed module rename in other

* Fixed wrong reference for exception


Module renamed


Fixed module rename in other

* Update homeassistant/components/vlc_telnet/media_player.py

Accepted suggestion by @OttoWinter

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* Update homeassistant/components/vlc_telnet/media_player.py

Accepted suggestion by @OttoWinter

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* Update homeassistant/components/vlc_telnet/media_player.py

Accepted suggestion by @OttoWinter

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* Update homeassistant/components/vlc_telnet/media_player.py

Accepted suggestion by @OttoWinter

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* Suggestions by @OttoWinter

+Manage error when the VLC dissapears to show status unavailable.

* Removed error log, instead set unavailable state

* Changes suggested by @pvizeli

-Import location
-Use of constants

* Implemented available method

* Improved available method
* Clean up Google Config

* Lint

* pylint

* pylint2
* Vlc telnet first commit

First functional version, remains to add more functionality.

* New functions added and bugfixes

* Compliance with dev checklist

* Compliance with dev checklist

* Compliance with pydocstyle

* Removed unused import

* Fixed wrong reference for exception

* Module renamed

* Fixed module rename in other

* Fixed wrong reference for exception


Module renamed


Fixed module rename in other

* Update homeassistant/components/vlc_telnet/media_player.py

Accepted suggestion by @OttoWinter

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* Update homeassistant/components/vlc_telnet/media_player.py

Accepted suggestion by @OttoWinter

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* Update homeassistant/components/vlc_telnet/media_player.py

Accepted suggestion by @OttoWinter

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* Update homeassistant/components/vlc_telnet/media_player.py

Accepted suggestion by @OttoWinter

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* Suggestions by @OttoWinter

+Manage error when the VLC dissapears to show status unavailable.

* Removed error log, instead set unavailable state

* Changes suggested by @pvizeli

-Import location
-Use of constants

* Implemented available method

* Improved available method
* Improve autodiscovered yeelights model detection

* Lint fixes

* Logger warn fix
* Add extra_module_url and extra_module_url_es5 to frontend options

* Address review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.