Skip to content

Commit

Permalink
Merge branch 'AlexxIT:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dguihal authored Aug 13, 2023
2 parents fcf40d7 + 7dc7f75 commit 329f9df
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 22 deletions.
48 changes: 28 additions & 20 deletions custom_components/sonoff/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from homeassistant.helpers.aiohttp_client import async_get_clientsession

from .core.const import CONF_DEBUG, CONF_MODES, DOMAIN
from .core.ewelink import XRegistry, XRegistryCloud
from .core.ewelink import XRegistryCloud


def form(
Expand Down Expand Up @@ -60,21 +60,21 @@ async def async_step_user(self, data=None, error=None):
username = data.get(CONF_USERNAME)
password = data.get(CONF_PASSWORD)

entry = await self.async_set_unique_id(username)
if entry and password == "token":
# a special way to share a user's token
await self.cloud.login(
entry.data[CONF_USERNAME], entry.data[CONF_PASSWORD], 1
)
return form(
self,
"user",
schema,
data,
template={"error": "Token: " + self.cloud.token},
)

try:
entry = await self.async_set_unique_id(username)
if entry and password == "token":
# a special way to share a user's token
await self.cloud.login(
entry.data[CONF_USERNAME], entry.data[CONF_PASSWORD], 1
)
return form(
self,
"user",
schema,
data,
template={"error": "Token: " + self.cloud.token},
)

if username and password:
await self.cloud.login(username, password)

Expand Down Expand Up @@ -111,11 +111,19 @@ async def async_step_init(self, data: dict = None):
if data is not None:
return self.async_create_entry(title="", data=data)

try:
ewelink: XRegistry = self.hass.data[DOMAIN][self.entry.entry_id]
homes = await ewelink.cloud.get_homes()
except Exception:
homes = {}
homes = {}

username = self.entry.data.get(CONF_USERNAME)
password = self.entry.data.get(CONF_PASSWORD)
if username and password:
try:
# important to use another accout for get user homes
session = async_get_clientsession(self.hass)
cloud = XRegistryCloud(session)
await cloud.login(username, password, app=1)
homes = await cloud.get_homes()
except:
pass

for home in self.entry.options.get("homes", []):
if home not in homes:
Expand Down
4 changes: 4 additions & 0 deletions custom_components/sonoff/core/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ def spec(cls, base: str = None, enabled: bool = None, **kwargs) -> type:
spec(XZigbeeSwitches, channel=2, uid="3"),
spec(XZigbeeSwitches, channel=3, uid="4"),
],
7000: [
XRemoteButton,
Battery,
],
7014: [
spec(XSensor100, param="temperature"),
spec(XSensor100, param="humidity"),
Expand Down
3 changes: 2 additions & 1 deletion custom_components/sonoff/core/ewelink/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@

APP = [
# ("oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq", "6Nz4n0xA8s8qdxQf2GqurZj2Fs55FUvM"),
("KOBxGJna5qkk3JLXw3LHLX3wSNiPjAVi", "4v0sv6X5IM2ASIBiNDj6kGmSfxo40w7n"),
# ("KOBxGJna5qkk3JLXw3LHLX3wSNiPjAVi", "4v0sv6X5IM2ASIBiNDj6kGmSfxo40w7n"),
("4s1FXKC9FaGfoqXhmXSJneb3qcm1gOak", "oKvCM06gvwkRbfetd6qWRrbC3rFrbIpV"),
("R8Oq3y0eSZSYdKccHlrQzT1ACCOUT9Gv", "1ve5Qk9GXfUhKAn1svnKwpAlxXkMarru"),
]

Expand Down
2 changes: 1 addition & 1 deletion custom_components/sonoff/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"requirements": [
"pycryptodome>=3.6.6"
],
"version": "3.5.1",
"version": "3.5.2",
"iot_class": "local_push"
}
39 changes: 39 additions & 0 deletions custom_components/sonoff/translations/fr-ca.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"config": {
"abort": {
"reauth_successful": "Ré-authentification réussi"
},
"error": {
"exists": "Ce compte est déjà configuré",
"template": "{error}"
},
"step": {
"user": {
"description": "Entrer votre [eWeLink account](https://www.ewelink.cc/en/) identification",
"data": {
"username": "Courriel ou téléphone (utiliser n'importe quel pour le mode DIY)",
"password": "Mot de passe (laisser vide pour le mode DIY)"
}
}
}
},
"options": {
"step": {
"init": {
"data": {
"mode": "Mode (auto est recommendé pour la pluspart des utilisateurs)",
"homes": "Homes (laisser décoché pour \"current\" Home)",
"debug": "Page de débogage (Integration > Menu > Known issues)"
}
}
}
},
"system_health": {
"info": {
"version": "Version",
"cloud_online": "Appareils du nuage en ligne",
"local_online": "Appareils locale en ligne",
"debug": "Page de débogage"
}
}
}
39 changes: 39 additions & 0 deletions custom_components/sonoff/translations/tr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"config": {
"abort": {
"reauth_successful": "Yeniden kimlik doğrulama başarılı oldu"
},
"error": {
"exists": "Bu hesap zaten yapılandırılmış",
"template": "{error}"
},
"step": {
"user": {
"description": "[eWeLink hesabınızın](https://www.ewelink.cc/en/) bilgilerini girin",
"data": {
"username": "E-posta veya telefon (DIY modu için herhangi birini kullanın)",
"password": "Parola (DIY modu için boş bırakın)"
}
}
}
},
"options": {
"step": {
"init": {
"data": {
"mode": "Mod (çoğu kullanıcı için otomatik önerilir)",
"homes": "Evler (\"Geçerli\" ev için işaretlemeden bırakın)",
"debug": "Hata ayıklama sayfası (Entegrasyon > Menü > Bilinen sorunlar)"
}
}
}
},
"system_health": {
"info": {
"version": "Sürüm",
"cloud_online": "Çevrimiçi bulut cihazları",
"local_online": "Çevrimiçi yerel cihazlar",
"debug": "Hata ayıklama sayfası"
}
}
}

0 comments on commit 329f9df

Please sign in to comment.