Skip to content

Commit

Permalink
Add mychevy optional country parameter (#19727)
Browse files Browse the repository at this point in the history
* Add optional country parameter

mychevy 1.2.0 provides the ability to work in canada as well as the us
(there are different service urls for each region). This creates a new
config option to enable it.

* Update mychevy.py
  • Loading branch information
sdague authored and cgarwood committed Jan 4, 2019
1 parent dbb3802 commit 03488af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions homeassistant/components/mychevy.py
Expand Up @@ -16,7 +16,7 @@
from homeassistant.helpers import discovery
from homeassistant.util import Throttle

REQUIREMENTS = ["mychevy==1.1.0"]
REQUIREMENTS = ["mychevy==1.2.0"]

DOMAIN = 'mychevy'
UPDATE_TOPIC = DOMAIN
Expand All @@ -33,10 +33,15 @@
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=30)
ERROR_SLEEP_TIME = timedelta(minutes=30)

CONF_COUNTRY = 'country'
DEFAULT_COUNTRY = 'us'

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(CONF_COUNTRY, default=DEFAULT_COUNTRY):
vol.All(cv.string, vol.In(['us', 'ca']))
}),
}, extra=vol.ALLOW_EXTRA)

Expand Down Expand Up @@ -72,7 +77,8 @@ def setup(hass, base_config):

email = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
hass.data[DOMAIN] = MyChevyHub(mc.MyChevy(email, password), hass,
country = config.get(CONF_COUNTRY)
hass.data[DOMAIN] = MyChevyHub(mc.MyChevy(email, password, country), hass,
base_config)
hass.data[DOMAIN].start()

Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Expand Up @@ -680,7 +680,7 @@ motorparts==1.0.2
mutagen==1.41.1

# homeassistant.components.mychevy
mychevy==1.1.0
mychevy==1.2.0

# homeassistant.components.mycroft
mycroftapi==2.0
Expand Down

0 comments on commit 03488af

Please sign in to comment.