Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b651f933e | |||
| a8274f7fd1 | |||
| ef783db79b | |||
| 18de851e4d | |||
|
|
cbed2cebb3 |
@@ -41,27 +41,32 @@ class GeorideConfigFlow(config_entries.ConfigFlow):
|
||||
|
||||
async def async_step_georide_login(self, user_input):
|
||||
""" try to seupt GeoRide Account """
|
||||
errors = {}
|
||||
|
||||
schema = vol.Schema({
|
||||
vol.Required(CONF_EMAIL): vol.All(str, vol.Length(min=3)),
|
||||
vol.Required(CONF_PASSWORD): vol.All(str)
|
||||
})
|
||||
|
||||
if user_input is None:
|
||||
return self.async_show_form(step_id='georide_login', data_schema=schema)
|
||||
|
||||
email = user_input[CONF_EMAIL]
|
||||
password = user_input[CONF_PASSWORD]
|
||||
|
||||
try:
|
||||
account = GeorideApi.get_authorisation_token(
|
||||
user_input[CONF_EMAIL],
|
||||
user_input[CONF_PASSWORD])
|
||||
return self.async_create_entry(
|
||||
title=user_input[CONF_EMAIL],
|
||||
account = GeorideApi.get_authorisation_token(email, password)
|
||||
data = {
|
||||
CONF_EMAIL: user_input[CONF_EMAIL],
|
||||
CONF_PASSWORD: user_input[CONF_PASSWORD],
|
||||
CONF_EMAIL: email,
|
||||
CONF_PASSWORD: password,
|
||||
CONF_TOKEN: account.auth_token
|
||||
}
|
||||
)
|
||||
return self.async_create_entry(title=email, data=data)
|
||||
except (GeorideException.SeverException, GeorideException.LoginException):
|
||||
_LOGGER.error("Invalid credentials provided, config not created")
|
||||
errors["base"] = "faulty_credentials"
|
||||
return self.async_show_form(step_id="georide_login", errors=errors)
|
||||
errors = {"base": "faulty_credentials"}
|
||||
return self.async_show_form(step_id="georide_login", data_schema=schema, errors=errors)
|
||||
except:
|
||||
_LOGGER.error("Unknown error")
|
||||
errors["base"] = "faulty_credentials"
|
||||
return self.async_show_form(step_id="georide_login", errors=errors)
|
||||
|
||||
|
||||
errors = {"base": "unkonwn"}
|
||||
return self.async_show_form(step_id="georide_login", data_schema=schema, errors=errors)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.device_tracker.const import ENTITY_ID_FORMAT, SOURCE_TYPE_GPS
|
||||
from homeassistant.components.device_tracker.const import DOMAIN, SOURCE_TYPE_GPS
|
||||
from homeassistant.components.device_tracker.config_entry import TrackerEntity
|
||||
|
||||
import georideapilib.api as GeorideApi
|
||||
@@ -50,7 +50,7 @@ class GeorideTrackerEntity(TrackerEntity):
|
||||
self._get_tracker_callback = get_tracker_callback
|
||||
self._name = tracker.tracker_name
|
||||
self._data = tracker or {}
|
||||
self.entity_id = ENTITY_ID_FORMAT.format(tracker_id)
|
||||
self.entity_id = DOMAIN + ".{}".format(tracker_id)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
"domain": "georide",
|
||||
"name": "Georide",
|
||||
"config_flow": true,
|
||||
"documentation": "https://git.tontontux.fr/mduval/GeorideHA",
|
||||
"documentation": "https://github.com/ptimatth/GeorideHA",
|
||||
"requirements": [
|
||||
"georideapilib>=0.4.4",
|
||||
"pyjwt>=1.7.1"
|
||||
],
|
||||
"dependencies": [],
|
||||
"codeowners": ["@ptimatth"]
|
||||
"codeowners": ["ptimatth"]
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
import logging
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.components.switch import ENTITY_ID_FORMAT
|
||||
|
||||
import georideapilib.api as GeorideApi
|
||||
@@ -34,7 +34,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): # pylint: d
|
||||
|
||||
return True
|
||||
|
||||
class GeorideOdometerSensorEntity(SwitchDevice):
|
||||
class GeorideOdometerSensorEntity(SwitchEntity):
|
||||
"""Represent a tracked device."""
|
||||
|
||||
def __init__(self, tracker_id, get_token_callback, get_tracker_callback, data):
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import logging
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.components.switch import ENTITY_ID_FORMAT
|
||||
|
||||
import georideapilib.api as GeorideApi
|
||||
@@ -38,7 +38,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): # pylint: d
|
||||
|
||||
|
||||
|
||||
class GeorideLockSwitchEntity(SwitchDevice):
|
||||
class GeorideLockSwitchEntity(SwitchEntity):
|
||||
"""Represent a tracked device."""
|
||||
|
||||
def __init__(self, tracker_id, get_token_callback, get_tracker_callback, data):
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
"unknown": "Unknown error"
|
||||
},
|
||||
"abort": {
|
||||
"one_instance_allowed": "Only a single instance is allowed."
|
||||
"one_instance_allowed": "Only one instance is allowed."
|
||||
},
|
||||
"create_entry": {
|
||||
"default": "\n\nLogin succes"
|
||||
"default": "\n\nLogin success"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
"step": {
|
||||
"georide_login": {
|
||||
"title": "Configuration de GeoRide",
|
||||
"description": "T'es un mortard ! V",
|
||||
"description": "T'es un motard ! V",
|
||||
"data": {
|
||||
"email": "email",
|
||||
"password": "password"
|
||||
@@ -12,11 +12,11 @@
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"faulty_credentials": "Connexion \u00e9chou\u00e9",
|
||||
"unkonwn": "Erreur inconue"
|
||||
"faulty_credentials": "Connexion \u00e9chou\u00e9e",
|
||||
"unkonwn": "Erreur inconnue"
|
||||
},
|
||||
"abort": {
|
||||
"one_instance_allowed": "Seulement un instance est authoris\u00e9e"
|
||||
"one_instance_allowed": "Seulement une instance est autoris\u00e9e"
|
||||
},
|
||||
"create_entry": {
|
||||
"default": "\n\nConnexion r\u00e9ussie !"
|
||||
Reference in New Issue
Block a user