Add developer log.

pull/3/head
schizza 2024-03-09 16:38:42 +01:00
parent 400b449e44
commit ad2fad8001
2 changed files with 16 additions and 3 deletions

View File

@ -11,8 +11,8 @@ from homeassistant.exceptions import InvalidStateError, PlatformNotReady
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from .const import API_ID, API_KEY, DEFAULT_URL, DOMAIN, WINDY_ENABLED from .const import API_ID, API_KEY, DEFAULT_URL, DEV_DBG, DOMAIN, WINDY_ENABLED
from .utils import remap_items from .utils import anonymize, remap_items
from .windy_func import WindyPush from .windy_func import WindyPush
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -57,8 +57,10 @@ class WeatherDataUpdateCoordinator(DataUpdateCoordinator):
self.async_set_updated_data(remap_items(data)) self.async_set_updated_data(remap_items(data))
response = response if response else "OK" if self.config_entry.options.get(DEV_DBG):
_LOGGER.info("Dev log: %s", anonymize(data))
response = response if response else "OK"
return aiohttp.web.Response(body=f"{response}", status=200) return aiohttp.web.Response(body=f"{response}", status=200)

View File

@ -20,6 +20,17 @@ def update_options(
hass.config_entries.async_update_entry(entry, options=conf) hass.config_entries.async_update_entry(entry, options=conf)
def anonymize(data):
"""Anoynimize recieved data."""
anonym = {}
for k in data:
if k not in ("ID", "PASSWORD"):
anonym[k] = data[k]
return anonym
def remap_items(entities): def remap_items(entities):
"""Remap items in query.""" """Remap items in query."""
items = {} items = {}