Add device_utils.py
authorScott Gasch <[email protected]>
Tue, 2 Nov 2021 03:05:34 +0000 (20:05 -0700)
committerScott Gasch <[email protected]>
Tue, 2 Nov 2021 03:05:34 +0000 (20:05 -0700)
smart_home/device_utils.py [new file with mode: 0644]

diff --git a/smart_home/device_utils.py b/smart_home/device_utils.py
new file mode 100644 (file)
index 0000000..f79c734
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+import logging
+from typing import Any
+
+import smart_home.cameras as cameras
+import smart_home.chromecasts as chromecasts
+import smart_home.lights as lights
+import smart_home.outlets as outlets
+
+logger = logging.getLogger(__name__)
+
+
+def is_camera(device: Any) -> bool:
+    return isinstance(device, cameras.BaseCamera)
+
+
+def is_chromecast(device: Any) -> bool:
+    return isinstance(device, chromecasts.BaseChromecast)
+
+
+def is_light(device: Any) -> bool:
+    return isinstance(device, lights.BaseLight)
+
+
+def is_outlet(device: Any) -> bool:
+    return isinstance(device, outlets.BaseOutlet)