05-sep: [parental] aceptar alias simples de dispositivos
This commit is contained in:
@@ -170,6 +170,16 @@ Dispositivos iniciales:
|
|||||||
|
|
||||||
Las rutinas se definirán con nombre, dispositivos objetivo, días y franjas horarias. No se aplica ninguna hasta que el usuario indique la primera definición.
|
Las rutinas se definirán con nombre, dispositivos objetivo, días y franjas horarias. No se aplica ninguna hasta que el usuario indique la primera definición.
|
||||||
|
|
||||||
|
Los nombres de dispositivo serán tolerantes a mayúsculas, minúsculas, tildes y nombres sencillos:
|
||||||
|
|
||||||
|
```text
|
||||||
|
/parental activar Inés
|
||||||
|
/parental desactivar INES
|
||||||
|
/parental pausa Carolina 60
|
||||||
|
```
|
||||||
|
|
||||||
|
`Inés`, `INES`, `ines` y `tablet ines` identifican la misma tablet. `Carolina`, `CAROLINA` y `Caroline tablet` identifican la tablet de Carolina.
|
||||||
|
|
||||||
## Despliegue
|
## Despliegue
|
||||||
|
|
||||||
La Pi no tiene Git operativo para este flujo. El despliegue se hace por el VPS y el tunel inverso:
|
La Pi no tiene Git operativo para este flujo. El despliegue se hace por el VPS y el tunel inverso:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import unicodedata
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from asusrouter import AsusData, AsusRouter
|
from asusrouter import AsusData, AsusRouter
|
||||||
@@ -25,11 +26,29 @@ def _load_env():
|
|||||||
|
|
||||||
FILE_ENV = _load_env()
|
FILE_ENV = _load_env()
|
||||||
|
|
||||||
|
DEVICE_ALIASES = {
|
||||||
|
"ines": {"name": "TABLET INES", "mac": "04:34:F6:0C:8E:48"},
|
||||||
|
"tablet ines": {"name": "TABLET INES", "mac": "04:34:F6:0C:8E:48"},
|
||||||
|
"carolina": {"name": "Caroline-tablet", "mac": "3A:99:2B:ED:D3:5E"},
|
||||||
|
"caroline": {"name": "Caroline-tablet", "mac": "3A:99:2B:ED:D3:5E"},
|
||||||
|
"caroline tablet": {"name": "Caroline-tablet", "mac": "3A:99:2B:ED:D3:5E"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _env(name, default=""):
|
def _env(name, default=""):
|
||||||
return os.getenv(name, FILE_ENV.get(name, default)).strip()
|
return os.getenv(name, FILE_ENV.get(name, default)).strip()
|
||||||
|
|
||||||
|
|
||||||
|
def normalizar_nombre(nombre):
|
||||||
|
value = unicodedata.normalize("NFKD", nombre or "")
|
||||||
|
value = "".join(char for char in value if not unicodedata.combining(char))
|
||||||
|
return " ".join(value.lower().replace("-", " ").split())
|
||||||
|
|
||||||
|
|
||||||
|
def resolver_dispositivo(nombre):
|
||||||
|
return DEVICE_ALIASES.get(normalizar_nombre(nombre))
|
||||||
|
|
||||||
|
|
||||||
async def _parental_data():
|
async def _parental_data():
|
||||||
username = _env("ASUS_USERNAME")
|
username = _env("ASUS_USERNAME")
|
||||||
password = _env("ASUS_PASSWORD")
|
password = _env("ASUS_PASSWORD")
|
||||||
|
|||||||
Reference in New Issue
Block a user