Easier and more self documenting patterns for loading/saving Persistent
[python_utils.git] / smart_home / device_utils.py
1 #!/usr/bin/env python3
2
3 # © Copyright 2021-2022, Scott Gasch
4
5 """General utility functions involving smart home devices."""
6
7 import logging
8 from typing import Any
9
10 from smart_home import cameras, chromecasts, lights, outlets
11
12 logger = logging.getLogger(__name__)
13
14
15 def is_camera(device: Any) -> bool:
16     return isinstance(device, cameras.BaseCamera)
17
18
19 def is_chromecast(device: Any) -> bool:
20     return isinstance(device, chromecasts.BaseChromecast)
21
22
23 def is_light(device: Any) -> bool:
24     return isinstance(device, lights.BaseLight)
25
26
27 def is_outlet(device: Any) -> bool:
28     return isinstance(device, outlets.BaseOutlet)