Skip to content

Commit

Permalink
Make device_tracker updateable, add hint of config source
Browse files Browse the repository at this point in the history
  • Loading branch information
rikroe committed May 11, 2020
1 parent e84e3d4 commit b6da542
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions custom_components/bmw_connected_drive/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging

from homeassistant import config_entries, core, exceptions
from homeassistant.const import CONF_USERNAME
from homeassistant.const import CONF_USERNAME, CONF_SOURCE

from . import ACCOUNT_SCHEMA as DATA_SCHEMA, DOMAIN, setup_account
from .const import CONF_REGION
Expand Down Expand Up @@ -35,7 +35,7 @@ async def validate_input(hass: core.HomeAssistant, data):
raise InvalidAuth

# Return info that you want to store in the config entry.
return {"title": data[CONF_USERNAME]}
return {"title": f"{data[CONF_USERNAME]}{data.get(CONF_SOURCE, '')}"}


class BMWConnectedDriveConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
Expand Down Expand Up @@ -71,6 +71,7 @@ async def async_step_user(self, user_input=None):

async def async_step_import(self, user_input):
"""Handle import."""
user_input[CONF_SOURCE] = " (configuration.yaml)"
return await self.async_step_user(user_input)


Expand Down
4 changes: 4 additions & 0 deletions custom_components/bmw_connected_drive/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def source_type(self):
def icon(self):
return "mdi:car"

def update(self):
"""Update state of the decvice tracker."""
self._location = self._vehicle.state.gps_position

def update_callback(self):
"""Schedule a state update."""
self.schedule_update_ha_state(True)
Expand Down

0 comments on commit b6da542

Please sign in to comment.