Skip to main content

Accessing webcams via REST API

Project description

Web Cam Access via HTTP REST-API

A Python3 library that unified acess to various web cams with integrated HTTP servers. The intended use is for connecting cameras with built-in REST servers to the home-assistant platform.

Installation

libhttpcam

pip3 install libhttpcam

or as update:

pip3 install --upgrade libhttpcam 

Usage

Use createCam to create a camera instance.

from libhttpcam import createCam

model = 'foscam'
ip = '10.0.0.30'
cam, port = createCam('foscam', ip)  # use model's default port

Next, you might want to set credentials for the camera:

user = 'me'
password = 'youllneverguess'
cam.set_credentials(user, password)

Support

Currently, only Foscam and Wansview cameras are supported.

  • Foscam C1
  • Wansview K2
  • Wansview Q3S (X Series)

API

  • createCam(brand:str, ip:str, port:int=None) -> (HttpCam, int)
    creates a HttpCam instance for the supplied brand, ip address, and port. If port is omitted, the camera brand's default port will be used.

returns the camera instance and the port used as a tuple

Device Properties

  • brand()
    returns the camera instance's brand

  • model()
    returns the camera instance's model Note: for Wansview cameras this call returns 'unknown'

  • host()
    returns the camera instance's ip address

  • port()
    returns the camera instance's port

Device Configuration

  • set_credentials(user='', password='')
    sets the credentials used to access the camera.

  • set_sensitivities(motion=0, audio=0)

Sets the sensitivities for motion detection and audio detection. Both take values between 0 (off) and 100 (sensitive).

  • async_reboot() -> Response
    reboots the camera.

  • async_set_system_time() -> Response
    sets the current local time on the camera. This is used for overlays in the snapshots and feeds.

  • async_set_irled(status: Status) -> Response
    sets the status of the active infrared light on the camera. Valid settings are Status.ON', Status.OFF, and Status.AUTO`

  • async_set_night_mode(status: Status) -> Response
    sets the status of the passive infrered sensor. Valid settings are Status.ON', Status.OFF, and Status.AUTO`

  • async_set_ftp_config(server, port, user, passwd) -> Response
    configures the ftp client to allow snapshots and recordings to be stored on a server via FTP.

  • async_set_audio_volumes(audio_in=50, audio_out=50) -> Response
    configures audio volumes for the camera:

  • audio_in: microphone volume

  • audio_out: speaker and alert volume

Device Queries

  • async_get_model() -> str
    queries and returns the brand's model number as a string

  • async_get_night_mode() -> IRmode
    queries and returns the sensor night mode setting:

    • bool result.LED
    • bool result.Sensor
  • async_get_alarm_trigger() -> Trigger
    queries and returns the alarm trigger setting:

    • bool result.motion
    • bool result.audio
  • async_get_alarm_action() -> Action

    queries and returns the alarm action setting:

    • bool result.audio - sound the siren
    • bool result.ftp_snap - store snapshots to FTP server
    • bool result.ftp_rec - store recordings to FTP server
  • async_get_alarm_triggered() -> bool
    queries and returns True if an alram was detected.
    Currently not implemented, returns False

  • async_get_ftp_config()
    queries and returns the current FTP configuration

Device Actions

  • async_snap_picture()
    snaps a picture and returns the byte array

  • async_mjpeg_stream(request)
    requests and returns a motion JPEG stream

  • async_set_alarm(trigger: Trigger, action: Action) -> Response
    Arms or disarms the camera by7 setting the trigger and action settings

  • async_ptz_preset(preset_pos:int)
    moves the camera to the specified preprogrammed position if PTX is available

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libhttpcam-0.1.4.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libhttpcam-0.1.4-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file libhttpcam-0.1.4.tar.gz.

File metadata

  • Download URL: libhttpcam-0.1.4.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for libhttpcam-0.1.4.tar.gz
Algorithm Hash digest
SHA256 d7b2e63d9c8c43935211c5fff3e359d1ed32469954a13ff65fb9e263306f203b
MD5 41a14832338386f99451b6b8d77bd4ab
BLAKE2b-256 9481bb8532083149bc8b21bb4f65bbeaca49fc5d1298f022377850dd120a5d61

See more details on using hashes here.

File details

Details for the file libhttpcam-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: libhttpcam-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for libhttpcam-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 487e75757d045ec29129ae11f2ffb2db853952b9d7d47dcba99bb578951dea64
MD5 6f66b3b3ad0b87c93a5860e819fe3263
BLAKE2b-256 2bb4c73c16d269ca570b3b03b942410fbb72cca847bd07277bd4130d77a75b17

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page