-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
137 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.const import CONF_INCLUDE | ||
from homeassistant.core import HomeAssistant | ||
|
||
from ..core.const import DOMAIN, DATA_CONFIG | ||
from ..core.yandex_quasar import YandexQuasar | ||
|
||
INCLUDE_KEYS = ("id", "name", "type", "room_name", "skill_id") | ||
|
||
|
||
def incluce_devices( | ||
hass: HomeAssistant, config_entry: ConfigEntry | ||
) -> list[tuple[YandexQuasar, dict, dict]]: | ||
quasar: YandexQuasar = hass.data[DOMAIN][config_entry.unique_id] | ||
config: dict = hass.data[DOMAIN][DATA_CONFIG] | ||
includes = config.get(CONF_INCLUDE, []) + config_entry.options.get(CONF_INCLUDE, []) | ||
|
||
devices = [] | ||
|
||
for conf in includes: | ||
for device in quasar.devices: | ||
if isinstance(conf, str): | ||
if conf == device["name"] or conf == device["id"]: | ||
devices.append((quasar, device, {})) | ||
break | ||
elif isinstance(conf, dict): | ||
if any(conf[k] == device.get(k) for k in INCLUDE_KEYS if k in conf): | ||
devices.append((quasar, device, conf)) | ||
break | ||
|
||
return devices |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.