Skip to content

Add config flow to iCloud#26590

Closed
Quentame wants to merge 37 commits into
home-assistant:devfrom
Quentame:icloud/config-flow
Closed

Add config flow to iCloud#26590
Quentame wants to merge 37 commits into
home-assistant:devfrom
Quentame:icloud/config-flow

Conversation

@Quentame
Copy link
Copy Markdown
Member

@Quentame Quentame commented Sep 11, 2019

Breaking Change:

The iCloud component leaves the device_tracker platform to become an integration.

From:

device_tracker:
  - platform: icloud
    username: __email__
    password: __password__

To:

icloud:
  - username: __email__
    password: __password__

Here are all the services :
SERVICE_ICLOUD_PLAY_SOUND = "play_sound"
SERVICE_ICLOUD_DISPLAY_MESSAGE = "display_message"
SERVICE_ICLOUD_LOST_DEVICE = "lost_device"
SERVICE_ICLOUD_UPDATE = "update"
SERVICE_ICLOUD_RESET = "reset"

Some services are renamed :
'icloud_lost_device' --> 'lost_device'
'icloud_update' --> 'update'
'icloud_reset' --> 'reset'

Description:

Dramatically improve the iCloud integration addition UX with config flow, translated steps (will do),
and list selection while choosing the trusted device (instead of a number).

It also adds documentation to services, and should fix two issues.

Following the draft PR #24053

PR doing :

  • add config flow
  • fix existing services
  • add play_sound & display_message services
  • document services
  • prepare to add sensor platform (battery for devices)

Related issue (if applicable):
fixes #13312
fixes #20195
fixes #28826

Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#<home-assistant.io PR number goes here>

NOT YET

Example entry for configuration.yaml (if applicable):

icloud:
  - username: __email__
    password: __password__

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.

@Quentame
Copy link
Copy Markdown
Member Author

Quentame commented Sep 11, 2019

@MartinHjelmare : I've take care of your reviews from the old PR #24053 and from the Linky one #26076.

But I've still some issues to understand coroutine stuff, use of @callback and async & await.

Also, the TrackerEntity isn't showing entities on the map, is not normal ? Or maybe I still should use see()

@Quentame Quentame changed the title iCloud: setup ConfigFlow and prepare for more platforms Add config flow to iCloud Sep 12, 2019
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

I haven't looked at the config flow or the tests yet.

Comment thread homeassistant/components/icloud/device_tracker.py Outdated
Comment thread homeassistant/components/icloud/device_tracker.py Outdated
Comment thread homeassistant/components/icloud/device_tracker.py Outdated
Comment thread homeassistant/components/icloud/device_tracker.py Outdated
Comment thread homeassistant/components/icloud/__init__.py Outdated
Comment thread homeassistant/components/icloud/__init__.py Outdated
Comment thread homeassistant/components/icloud/__init__.py Outdated
Comment thread homeassistant/components/icloud/__init__.py Outdated
Comment thread homeassistant/components/icloud/__init__.py Outdated
Comment thread homeassistant/components/icloud/__init__.py Outdated
Comment thread homeassistant/components/icloud/config_flow.py Outdated
Comment thread homeassistant/components/icloud/config_flow.py Outdated
Comment thread homeassistant/components/icloud/config_flow.py Outdated
Comment thread homeassistant/components/icloud/config_flow.py Outdated
Comment thread homeassistant/components/icloud/config_flow.py Outdated
Comment thread homeassistant/components/icloud/config_flow.py Outdated
Comment thread homeassistant/components/icloud/const.py Outdated
@Quentame
Copy link
Copy Markdown
Member Author

@MartinHjelmare : Is it possible to make my IcloudTrackerEntity(TrackerEntity) visible in the map component ?

@MartinHjelmare
Copy link
Copy Markdown
Member

MartinHjelmare commented Sep 16, 2019

Entities with latitude and longitude as state attributes should be visible on the map by default.

Comment thread homeassistant/components/icloud/__init__.py Outdated
Comment thread homeassistant/components/icloud/__init__.py Outdated
Comment thread homeassistant/components/icloud/__init__.py Outdated
Comment thread homeassistant/components/icloud/__init__.py Outdated
Comment thread homeassistant/components/icloud/__init__.py Outdated
Comment thread homeassistant/components/icloud/config_flow.py Outdated
Comment thread homeassistant/components/icloud/device_tracker.py Outdated
Comment thread homeassistant/components/icloud/config_flow.py Outdated
Comment thread homeassistant/components/icloud/__init__.py Outdated
Comment thread homeassistant/components/icloud/config_flow.py Outdated
Comment thread homeassistant/components/icloud/config_flow.py Outdated
Comment thread tests/components/icloud/test_config_flow.py Outdated
Comment thread tests/components/icloud/test_config_flow.py Outdated
Comment thread homeassistant/components/icloud/__init__.py Outdated
@Quentame
Copy link
Copy Markdown
Member Author

Quentame commented Sep 19, 2019

@MartinHjelmare : devices are displayed in the map (actually some kind of not showing when home and position updates made me think that).

Do you know how to add the battery infos on the new config -> devices panel ?
Capture d’écran 2019-09-19 à 13 42 38

I tried multiple key in the device_info, but none of them are working (battery, battery_level, battery_percent, batteryLevel, batteryPercent).
While writing I notice that maybe I should add a dict with the level and the status, or a battery sensor (next PR anyway).
I found nothing on the current code that can help me.

@MartinHjelmare
Copy link
Copy Markdown
Member

It's not possible to add custom keys to device_info. Only the keys in the docs are available to be set:
https://developers.home-assistant.io/docs/en/device_registry_index.html#device-properties

Probably create a separate sensor, measuring battery level, and make sure the sensor has the device id of the device in question in the device_info.

@Quentame
Copy link
Copy Markdown
Member Author

Okey @MartinHjelmare, will do it in a next PR, with the sensor

Comment thread tests/components/icloud/test_config_flow.py Outdated
Comment thread tests/components/icloud/test_config_flow.py Outdated
@Quentame
Copy link
Copy Markdown
Member Author

I'm kinda stuck with the tests, can you take a quick look @MartinHjelmare ?

Thanks a lot.

Comment thread tests/components/icloud/test_config_flow.py Outdated
Comment thread tests/components/icloud/test_config_flow.py Outdated
Comment thread tests/components/icloud/test_config_flow.py Outdated
Comment thread tests/components/icloud/test_config_flow.py Outdated
Comment thread tests/components/icloud/test_config_flow.py Outdated
Comment thread tests/components/icloud/test_config_flow.py Outdated
@Quentame Quentame force-pushed the icloud/config-flow branch 3 times, most recently from 5ee9b15 to 3ad12f8 Compare October 8, 2019 11:55
@Quentame
Copy link
Copy Markdown
Member Author

The pipeline is passing @MartinHjelmare
Do the code nice to you now ? 😊

I'm gonna work on the documentation then.
Do you think I should close this messy PR and open a new one ?

@Quentame Quentame closed this Nov 22, 2019
@Quentame Quentame deleted the icloud/config-flow branch November 22, 2019 23:11
@Quentame Quentame mentioned this pull request Nov 22, 2019
8 tasks
@Quentame
Copy link
Copy Markdown
Member Author

Opened a fresh PR #28968

@lock lock Bot locked and limited conversation to collaborators Nov 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

4 participants