Skip to content

Add services for bmw_connected_drive#13497

Merged
MartinHjelmare merged 11 commits intohome-assistant:devfrom
ChristianKuehnel:bimmer_services
Apr 17, 2018
Merged

Add services for bmw_connected_drive#13497
MartinHjelmare merged 11 commits intohome-assistant:devfrom
ChristianKuehnel:bimmer_services

Conversation

@ChristianKuehnel
Copy link
Copy Markdown
Contributor

@ChristianKuehnel ChristianKuehnel commented Mar 27, 2018

Description:

Added services to bmw_connected_drive so that the Remote Services of the vehicle can also be triggered from Home Assistant.

  • Added vin to attributes of tracker, so that the users can see the VIN of the vehicle
  • I had to move the component to new package, so that I can add the services.yaml
  • Added service description in services.yaml

Related issue (if applicable): N/A

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5055

Example entry for configuration.yaml (if applicable):

no changes

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

von -> of

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.

fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is trackr_id used for something specific? As this field has the same value as id it seems a bit double.

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.

the attributes are removed in #12999

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.

CONF_ constants are only used in config schemas. Here you want to use ATTR_ in the service schema.

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.

fixed

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.

Do this directly in setup instead.

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.

fixed

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.

Make function to handle service calls directly inside setup instead. You have access to this instance there, so this doesn't have to be a method here.

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.

fixed

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare Mar 29, 2018

Choose a reason for hiding this comment

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

Service handlers don't return anything.

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.

fixed

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.

Remove this, it's duplicate info from host_name.

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.

fixed, see also #12999

@MartinHjelmare
Copy link
Copy Markdown
Member

Please also document the services in the docs.

Copy link
Copy Markdown
Member

@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

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

Split this into a component with a device tracker and lock platform. So you can add the needed service to main component.

@MartinHjelmare
Copy link
Copy Markdown
Member

MartinHjelmare commented Mar 29, 2018

Good point @pvizeli.

@ChristianKuehnel
This component already exposes some of these services in the lock platform eg. Why add them again in the main component?

@ChristianKuehnel
Copy link
Copy Markdown
Contributor Author

ChristianKuehnel commented Mar 30, 2018

@pvizeli @MartinHjelmare
My assumption was: offer all services that the underlying library offers also in a common API in hass. But I'm also fine with splitting in keeping the locking-related services with the lock and only offer the rest here. I implemented your proposal now.

Added documentation for the services (see link above).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'result' is assigned to but never used

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

'bimmer_connected.remote_services.ExecutionState' imported but unused

@ChristianKuehnel
Copy link
Copy Markdown
Contributor Author

Build failed because of flaky test --> re-triggering build with open/close.

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.

Some minor comments left to attend. Otherwise looks good!


for account in accounts:
account.update()
def _update_all(_) -> 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.

Please add a parameter, service or call, even though you don't use it, it's clearer and according to our standard.

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.

ACK

account.update()
def _update_all(_) -> None:
"""Update all BMW accounts."""
for account_update in hass.data[DOMAIN]:
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare Apr 8, 2018

Choose a reason for hiding this comment

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

Below you call the item bimmer. Why not call it the same here? It would read nicer.

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.

ACK calling the object cd_account (Connected Drive Account).

object here.
"""
vin = call.data[ATTR_VIN]
_LOGGER.debug('Triggering service %s of vehicle %s',
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.

This is already logged in the core at info level.

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.

removed it


# register the remote services
for service in _SERVICE_MAP:
_LOGGER.debug('Registering service %s', service)
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.

We usually don't log this.

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.

removed it

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.

Great! Can be merged when build passes.

@MartinHjelmare MartinHjelmare changed the title bmw_connected_drive - added services Add services for bmw_connected_drive Apr 17, 2018
@MartinHjelmare MartinHjelmare merged commit e472436 into home-assistant:dev Apr 17, 2018
@ChristianKuehnel ChristianKuehnel deleted the bimmer_services branch April 19, 2018 15:20
@balloob balloob mentioned this pull request Apr 27, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants