diff --git a/docs/index.html b/docs/index.html
index 5b10f3ff..a3a0c543 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -3696,7 +3696,7 @@
———-Executors———-
Load smart devices’ data from feed file.
diff --git a/jarvis/executors/files.py b/jarvis/executors/files.py
index 584ad8b0..5609601a 100644
--- a/jarvis/executors/files.py
+++ b/jarvis/executors/files.py
@@ -190,22 +190,9 @@ def put_automation(
_dumper(models.fileio.automation, sorted_data)
-def get_smart_devices() -> dict | bool | None:
+def get_smart_devices() -> dict | None:
"""Load smart devices' data from feed file."""
- # fixme: Change the logic to NOT look for False specifically
- try:
- with open(models.fileio.smart_devices) as file:
- if smart_devices := yaml.load(stream=file, Loader=yaml.FullLoader):
- return smart_devices
- else:
- logger.warning("'%s' is empty.", models.fileio.smart_devices)
- except (yaml.YAMLError, FileNotFoundError) as error:
- if isinstance(error, FileNotFoundError):
- logger.warning("%s not found.", models.fileio.smart_devices)
- return
- else:
- logger.debug(error)
- return False
+ return _loader(models.fileio.smart_devices)
def put_smart_devices(data: dict) -> None:
diff --git a/jarvis/executors/lights.py b/jarvis/executors/lights.py
index 86dd8f5b..60b7c98f 100644
--- a/jarvis/executors/lights.py
+++ b/jarvis/executors/lights.py
@@ -123,16 +123,15 @@ def lights(phrase: str) -> None:
if not internet.vpn_checker():
return
- smart_devices = files.get_smart_devices()
- if smart_devices is False:
- speaker.speak(
- text=f"I'm sorry {models.env.title}! I wasn't able to read the source information."
- )
- return
- if smart_devices and (lights_map := get_lights(data=smart_devices)):
+ if (smart_devices := files.get_smart_devices()) and (
+ lights_map := get_lights(data=smart_devices)
+ ):
logger.debug(lights_map)
else:
- logger.warning("%s is empty for lights.", models.fileio.smart_devices)
+ logger.warning(
+ "Smart devices are not configured for lights in %s",
+ models.fileio.smart_devices,
+ )
support.no_env_vars()
return
diff --git a/jarvis/executors/tv.py b/jarvis/executors/tv.py
index 06531862..4701a824 100644
--- a/jarvis/executors/tv.py
+++ b/jarvis/executors/tv.py
@@ -101,17 +101,15 @@ def television(phrase: str) -> None:
if not internet.vpn_checker():
return
- smart_devices = files.get_smart_devices()
- if smart_devices is False:
- speaker.speak(
- text=f"I'm sorry {models.env.title}! I wasn't able to read the source information."
- )
- return
- if smart_devices and (tv_mapping := get_tv(data=smart_devices)):
+ if (smart_devices := files.get_smart_devices()) and (
+ tv_mapping := get_tv(data=smart_devices)
+ ):
tv_map, key = tv_mapping
logger.debug("%s stored with key: '%s'", tv_map, key)
else:
- logger.warning("%s is empty for tv.", models.fileio.smart_devices)
+ logger.warning(
+ "Smart devices are not configured for tv in %s", models.fileio.smart_devices
+ )
support.no_env_vars()
return