MisterWil / abodepy

A thin Python wrapper for the Abode alarm API
MIT License
49 stars 17 forks source link

Requesting camera snapshot broken for older Abode cameras #60

Closed shred86 closed 4 years ago

shred86 commented 4 years ago

This was brought up in an issue over on the Home Assistant repo: https://github.com/home-assistant/home-assistant/issues/29895

There was a previous issue where requesting a camera snapshot for Iota (and possibly the "newer" circular Abode streaming cameras) was broken. The solution was changing the last word for CAMS_ID_CAPTURE_URL in constants.py from snapshot to capture. It appears the older streaming camera still uses snapshot thus breaking this functionality when using the older streaming camera.

I only have the Iota streaming camera but I'll need someone to provide the JSON data for the older (square) 720p streaming camera and newer (round) 1080p streaming camera. We need a way to check the type of camera when the capture method is being called in cameras.py.

Edit: I think I have a simple and more robust fix for this in cameras.py. Currently, the url variable in the capture method is being defined by:

url = str.replace(CONST.CAMS_ID_CAPTURE_URL, '$DEVID$', self.device_id)

Instead, we can change this to:

url = CONST.BASE_URL + self._json_state["control_url_snapshot"]

The JSON data for the Iota camera has a key called control_url_snapshot which specifics the URL for the snapshot feature which we can use. Two obvious benefits:

  1. This will pull the correct "control url" for whichever camera is being used. This assumes all Abode cameras have the key control_url_snapshot in their JSON data. I need someone to confirm this for the older 720p camera and newer 1080p camera (standalone cameras).

  2. If Abode ever updates the control URL, it won't break this capture method.

shred86 commented 4 years ago

JSON data for the Iota camera:

    {
        "id": "XF:<redacted>",
        "type_tag": "device_type.ipcam",
        "type": "IP Cam",
        "name": "Living Room Camera",
        "area": "1",
        "zone": "1",
        "sort_order": "",
        "is_window": "",
        "bypass": "0",
        "schar_24hr": "1",
        "sresp_24hr": "5",
        "sresp_mode_0": "0",
        "sresp_entry_0": "0",
        "sresp_exit_0": "0",
        "group_name": "Streaming Camera",
        "group_id": "397974",
        "default_group_id": "1",
        "sort_id": "10000",
        "sresp_mode_1": "0",
        "sresp_entry_1": "0",
        "sresp_exit_1": "0",
        "sresp_mode_2": "0",
        "sresp_entry_2": "0",
        "sresp_exit_2": "0",
        "sresp_mode_3": "0",
        "uuid": "<redacted>",
        "sresp_entry_3": "0",
        "sresp_exit_3": "0",
        "sresp_mode_4": "0",
        "sresp_entry_4": "0",
        "sresp_exit_4": "0",
        "version": "1.0.2.22G_6.8E_homekit_2.0.9_s2 ABODE oz",
        "origin": "abode",
        "has_subscription": null,
        "onboard": "1",
        "s2_grnt_keys": "",
        "s2_dsk": "",
        "s2_propty": "",
        "s2_keys_valid": "",
        "zwave_secure_protocol": "",
        "control_url": "api\/v1\/cams\/XF:<redacted>\/record",
        "deep_link": null,
        "status_color": "#5cb85c",
        "faults": {
            "low_battery": 0,
            "tempered": 0,
            "supervision": 0,
            "out_of_order": 0,
            "no_response": 0,
            "jammed": 0,
            "zwave_fault": 0
        },
        "status": "Online",
        "status_display": "Online",
        "statuses": [],
        "status_ex": "",
        "actions": [
            {
                "label": "Capture Video",
                "value": "a=1&z=1&req=vid;"
            },
            {
                "label": "Turn off Live Video",
                "value": "a=1&z=1&privacy=on;"
            },
            {
                "label": "Turn on Live Video",
                "value": "a=1&z=1&privacy=off;"
            }
        ],
        "status_icons": [],
        "icon": "assets\/icons\/streaming-camaera-new.svg",
        "control_url_snapshot": "api\/v1\/cams\/XF:<redacted>\/capture",
        "ptt_supported": true,
        "is_new_camera": 1,
        "stream_quality": 3,
        "camera_mac": "<redacted>",
        "privacy": "1",
        "enable_audio": "1",
        "alarm_video": "25",
        "pre_alarm_video": "5",
        "mic_volume": "75",
        "speaker_volume": "75",
        "mic_default_volume": 40,
        "speaker_default_volume": 46,
        "bandwidth": {
            "slider_labels": [
                {
                    "name": "High",
                    "value": 3
                },
                {
                    "name": "Medium",
                    "value": 2
                },
                {
                    "name": "Low",
                    "value": 1
                }
            ],
            "min": 1,
            "max": 3,
            "step": 1
        },
        "volume": {
            "min": 0,
            "max": 100,
            "step": 1
        },
        "video_flip": "0",
        "hframe": "1080P"
    },
troycarpenter commented 4 years ago

Here is for the current line of IP cameras referred to as the "abode Cam" (https://goabode.com/security-devices/security-cameras/abode-cam)

  {
    "id": "XF:<redacted>",
    "type_tag": "device_type.ipcam",
    "type": "IP Cam",
    "name": "Den Cam",
    "area": "1",
    "zone": "6",
    "sort_order": "",
    "is_window": "",
    "bypass": "0",
    "schar_24hr": "1",
    "sresp_24hr": "5",
    "sresp_mode_0": "0",
    "sresp_entry_0": "0",
    "sresp_exit_0": "0",
    "group_name": "Streaming Camera",
    "group_id": "525919",
    "default_group_id": "1",
    "sort_id": "2",
    "sresp_mode_1": "0",
    "sresp_entry_1": "0",
    "sresp_exit_1": "0",
    "sresp_mode_2": "0",
    "sresp_entry_2": "0",
    "sresp_exit_2": "0",
    "sresp_mode_3": "0",
    "uuid": "<redacted>",
    "sresp_entry_3": "0",
    "sresp_exit_3": "0",
    "sresp_mode_4": "0",
    "sresp_entry_4": "0",
    "sresp_exit_4": "0",
    "version": "1.0.2.22G_6.8E_homekit_2.0.9_s2",
    "origin": "abode",
    "has_subscription": null,
    "onboard": "0",
    "s2_grnt_keys": "",
    "s2_dsk": "",
    "s2_propty": "",
    "s2_keys_valid": "",
    "zwave_secure_protocol": "",
    "control_url": "api/v1/cams/XF:<redacted>/video",
    "deep_link": null,
    "status_color": "#5cb85c",
    "faults": {
      "low_battery": 0,
      "tempered": 0,
      "supervision": 0,
      "out_of_order": 0,
      "no_response": 0,
      "jammed": 0,
      "zwave_fault": 0
    },
    "status": "Online",
    "status_display": "Online",
    "statuses": [],
    "status_ex": "",
    "actions": [
      {
        "label": "Capture Video",
        "value": "a=1&z=6&req=vid;"
      },
      {
        "label": "Turn off Live Video",
        "value": "a=1&z=6&privacy=on;"
      },
      {
        "label": "Turn on Live Video",
        "value": "a=1&z=6&privacy=off;"
      }
    ],
    "status_icons": [],
    "icon": "assets/icons/streaming-camaera-new.svg",
    "control_url_snapshot": "api/v1/cams/XF:<redacted>/snapshot",
    "ptt_supported": true,
    "is_new_camera": 1,
    "stream_quality": 2,
    "camera_mac": "<redacted>",
    "privacy": "0",
    "enable_audio": "1",
    "alarm_video": "30",
    "pre_alarm_video": "5",
    "mic_volume": "50",
    "speaker_volume": "80",
    "mic_default_volume": 40,
    "speaker_default_volume": 46,
    "bandwidth": {
      "slider_labels": [
        {
          "name": "High",
          "value": 3
        },
        {
          "name": "Medium",
          "value": 2
        },
        {
          "name": "Low",
          "value": 1
        }
      ],
      "min": 1,
      "max": 3,
      "step": 1
    },
    "volume": {
      "min": 0,
      "max": 100,
      "step": 1
    },
    "video_flip": "0",
    "hframe": "1080P"
  }
MisterWil commented 4 years ago

Fixed in abodepy-0.17.0