Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(
self,
base_url: str,
subscription_registry: Optional["AbstractSubscriptionRegistry"] = None,
):
"""Init Vera controller at the given URL.
base_url: Vera API URL, eg http://vera:3480.
"""
self.base_url = base_url
self.devices: List[VeraDevice] = []
self.scenes: List[VeraScene] = []
self.temperature_units = "C"
self.version = None
self.model = None
self.serial_number = None
self.device_services_map: Dict[int, List[dict]] = {}
self.subscription_registry = subscription_registry or SubscriptionRegistry()
self.subscription_registry.set_controller(self)
self.categories: Dict[int, str] = {}
self.device_id_map: Dict[int, VeraDevice] = {}
def get_simple_devices_info(self) -> None:
"""Get basic device info from Vera."""
j = self.data_request({"id": "sdata"}).json()
self.scenes = []
items = j.get("scenes")
for item in items:
self.scenes.append(VeraScene(item, self))
if j.get("temperature"):
self.temperature_units = j.get("temperature")
self.categories = {}
cats = j.get("categories")
for cat in cats:
self.categories[cat.get("id")] = cat.get("name")
self.device_id_map = {}
devs = j.get("devices")
for dev in devs:
dev["categoryName"] = self.categories.get(dev.get("category"))
self.device_id_map[dev.get("id")] = dev