42 lines
871 B
Python
42 lines
871 B
Python
"""Utils for SWS12500."""
|
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .const import REMAP_ITEMS
|
|
|
|
|
|
def update_options(
|
|
hass: HomeAssistant, entry: ConfigEntry, update_key, update_value
|
|
) -> None:
|
|
"""Update config.options entry."""
|
|
conf = {}
|
|
|
|
for k in entry.options:
|
|
conf[k] = entry.options[k]
|
|
|
|
conf[update_key] = update_value
|
|
|
|
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):
|
|
"""Remap items in query."""
|
|
items = {}
|
|
for item in entities:
|
|
if item in REMAP_ITEMS:
|
|
items[REMAP_ITEMS[item]] = entities[item]
|
|
|
|
return items
|