Beispiel #1
0
def _activity_from_dict(activity_dict):
    action = activity_dict.get("action")

    if action in ACTIVITY_ACTIONS_DOORBELL_DING:
        return DoorbellDingActivity(activity_dict)
    if action in ACTIVITY_ACTIONS_DOORBELL_MOTION:
        return DoorbellMotionActivity(activity_dict)
    if action in ACTIVITY_ACTIONS_DOORBELL_VIEW:
        return DoorbellViewActivity(activity_dict)
    if action in ACTIVITY_ACTIONS_LOCK_OPERATION:
        return LockOperationActivity(activity_dict)
    if action in ACTIVITY_ACTIONS_DOOR_OPERATION:
        return DoorOperationActivity(activity_dict)
    return None
Beispiel #2
0
    def get_house_activities(self, access_token, house_id, limit=8):
        response = self._call_api(
            "get",
            API_GET_HOUSE_ACTIVITIES_URL.format(house_id=house_id),
            access_token=access_token,
            params={
                "limit": limit,
            })

        activities = []
        for activity_json in response.json():
            action = activity_json.get("action")

            if action in ["doorbell_call_missed", "doorbell_call_hangup"]:
                activities.append(DoorbellDingActivity(activity_json))
            elif action == "doorbell_motion_detected":
                activities.append(DoorbellMotionActivity(activity_json))
            elif action == "doorbell_call_initiated":
                activities.append(DoorbellViewActivity(activity_json))
            elif action in ["lock", "unlock"]:
                activities.append(LockOperationActivity(activity_json))

        return activities