Exemplo n.º 1
0
    def get_device_name(self, device_id) -> Optional[str]:
        """Find the device name for the provided ID."""
        if device_id is None:
            return None

        item = search_dict(match_value=int(device_id),
                           key='id',
                           search_list=self._hub_config.devices)
        return item.get('name') if item else None
Exemplo n.º 2
0
    def get_activity_name(self, activity_id) -> Optional[str]:
        """Find the activity name for the provided ID."""
        if activity_id is None:
            return None

        item = search_dict(match_value=int(activity_id),
                           key='id',
                           search_list=self._hub_config.activities)
        return item.get('name') if item else None
Exemplo n.º 3
0
    def get_device_id(self, device_name) -> Optional[int]:
        """Find the device ID for the provided device name."""
        if device_name is None:
            return None

        item = search_dict(match_value=device_name.lower(),
                           key='name_lowercase',
                           search_list=self._hub_config.devices)
        return item.get('id') if item else None
Exemplo n.º 4
0
    def get_activity_id(self, activity_name) -> Optional[int]:
        """Find the activity ID for the provided activity name."""
        if activity_name is None:
            return None

        item = search_dict(match_value=activity_name.lower(),
                           key='name_lowercase',
                           search_list=self._hub_config.activities)
        return item.get('id') if item else None