Skip to content

Camera Module

The camera module provides support for controlling video door entry systems and cameras through OpenWebNet (WHO = 7).

Classes

pyown.items.camera.Camera

Camera(
    client: BaseClient,
    where: Where | str,
    *,
    who: Who | str | None = None,
)

Bases: BaseItem

Camera items are used to control video door entry systems and cameras.

The camera system uses WHO = 7 (VIDEO_DOOR_ENTRY) and supports various commands for video control, zoom, and image adjustments.

Note: The actual video streaming is handled via HTTP/HTTPS protocol and is not part of this OpenWebNet implementation. After activating a camera with receive_video(), the image can be retrieved via: http://gateway-ip/telecamera.php?CAM_PASSWD=password

client: The client to use to communicate with the server.
where: The location of the item.
who: The type of item.

receive_video async

receive_video()

Activates the camera to receive video.

After this command, the video stream can be accessed via HTTP/HTTPS at the gateway's telecamera.php endpoint.

free_resources async

free_resources()

Frees audio and video resources.

This command releases the video channel and audio/video resources. Note: This command does not use a WHERE parameter.

zoom_in async

zoom_in()

Zooms in the camera view.

zoom_out async

zoom_out()

Zooms out the camera view.

increase_x_coordinate async

increase_x_coordinate()

Increases X coordinate of the central part of the image to be zoomed.

decrease_x_coordinate async

decrease_x_coordinate()

Decreases X coordinate of the central part of the image to be zoomed.

increase_y_coordinate async

increase_y_coordinate()

Increases Y coordinate of the central part of the image to be zoomed.

decrease_y_coordinate async

decrease_y_coordinate()

Decreases Y coordinate of the central part of the image to be zoomed.

increase_luminosity async

increase_luminosity()

Increases the luminosity of the camera image.

decrease_luminosity async

decrease_luminosity()

Decreases the luminosity of the camera image.

increase_contrast async

increase_contrast()

Increases the contrast of the camera image.

decrease_contrast async

decrease_contrast()

Decreases the contrast of the camera image.

increase_color async

increase_color()

Increases the color saturation of the camera image.

decrease_color async

decrease_color()

Decreases the color saturation of the camera image.

increase_quality async

increase_quality()

Increases the quality of the camera image.

decrease_quality async

decrease_quality()

Decreases the quality of the camera image.

display_dial async

display_dial(x: int, y: int)

Displays a specific dial position.

Parameters:

Name Type Description Default
x int

The X dial number (1-4).

required
y int

The Y dial number (1-4).

required

Raises:

Type Description
ValueError

If x or y are not in the range 1-4.

on_status_change classmethod

on_status_change(
    callback: Callable[
        [Self, WhatCamera, BaseMessage],
        Coroutine[None, None, None],
    ],
)

Registers a callback to be called when the status of the camera changes.

Parameters:

Name Type Description Default
callback Callable[[Self, WhatCamera, BaseMessage], Coroutine[None, None, None]]

The callback to call. It will receive as arguments the item, the WhatCamera value, and the message.

required

pyown.items.camera.WhatCamera

WhatCamera(string: str | int = '', *args, **kwargs)

Bases: What, StrEnum

This enum contains the possible commands and states for a camera.

Attributes:

Name Type Description
RECEIVE_VIDEO

Receive video from camera.

FREE_RESOURCES

Free audio/video resources.

ZOOM_IN

Zoom in.

ZOOM_OUT

Zoom out.

INCREASE_X

Increases X coordinate of the central part of the image to be zoomed.

DECREASE_X

Decreases X coordinate of the central part of the image to be zoomed.

INCREASE_Y

Increases Y coordinate of the central part of the image to be zoomed.

DECREASE_Y

Decreases Y coordinate of the central part of the image to be zoomed.

INCREASE_LUMINOSITY

Increases luminosity.

DECREASE_LUMINOSITY

Decreases luminosity.

INCREASE_CONTRAST

Increases contrast.

DECREASE_CONTRAST

Decreases contrast.

INCREASE_COLOR

Increases color.

DECREASE_COLOR

Decreases color.

INCREASE_QUALITY

Increases image quality.

DECREASE_QUALITY

Decreases image quality.

DISPLAY_DIAL_11

Display DIAL 1-1.

DISPLAY_DIAL_12

Display DIAL 1-2.

DISPLAY_DIAL_13

Display DIAL 1-3.

DISPLAY_DIAL_14

Display DIAL 1-4.

DISPLAY_DIAL_21

Display DIAL 2-1.

DISPLAY_DIAL_22

Display DIAL 2-2.

DISPLAY_DIAL_23

Display DIAL 2-3.

DISPLAY_DIAL_24

Display DIAL 2-4.

DISPLAY_DIAL_31

Display DIAL 3-1.

DISPLAY_DIAL_32

Display DIAL 3-2.

DISPLAY_DIAL_33

Display DIAL 3-3.

DISPLAY_DIAL_34

Display DIAL 3-4.

DISPLAY_DIAL_41

Display DIAL 4-1.

DISPLAY_DIAL_42

Display DIAL 4-2.

DISPLAY_DIAL_43

Display DIAL 4-3.

DISPLAY_DIAL_44

Display DIAL 4-4.

string property

string: str

Returns the value of the tag

tag property

tag: str

Returns the value of the tag without its parameters or prefix

parameters property

parameters: list[str]

Returns the parameters of the tag

with_parameter

with_parameter(parameter: str | int) -> Self

Returns the tag with the specified parameter

pyown.items.camera.CameraEvents

Bases: Enum

This enum is used internally to register the callbacks to the correct event.

Attributes:

Name Type Description
RECEIVE_VIDEO

The event for when receiving video.

FREE_RESOURCES

The event for when audio/video resources are freed.

ALL

The event for all events.

Camera Addressing

Camera WHERE addresses range from 4000 to 4099:

  • 4000: Camera 00
  • 4001: Camera 01
  • 4002: Camera 02
  • ...
  • 4099: Camera 99

Video Streaming

The OpenWebNet protocol only handles camera control commands. The actual video streaming is done via HTTP/HTTPS protocol.

After activating a camera with the receive_video() command, the JPEG image can be retrieved from:

http://gateway-ip/telecamera.php?CAM_PASSWD=password

or

https://gateway-ip/telecamera.php?CAM_PASSWD=password

If no password is configured, omit the CAM_PASSWD parameter (though using a password is strongly recommended).

Example Usage

import asyncio
from pyown import Client
from pyown.items.camera import Camera

async def main():
    # Connect to the gateway
    async with Client("192.168.1.35", 20000) as client:
        # Create a camera instance for camera 00 (WHERE = 4000)
        camera = Camera(client, "4000")

        # Activate the camera to receive video
        await camera.receive_video()

        # Adjust camera settings
        await camera.zoom_in()
        await camera.increase_luminosity()
        await camera.increase_contrast()

        # Display a specific dial
        await camera.display_dial(1, 1)  # Display DIAL 1-1

        # Free resources when done
        await camera.free_resources()

asyncio.run(main())

Available Commands

Video Control

  • receive_video(): Activate the camera to receive video
  • free_resources(): Free audio and video resources

Zoom Controls

  • zoom_in(): Zoom in the camera view
  • zoom_out(): Zoom out the camera view
  • increase_x_coordinate(): Move zoom center right
  • decrease_x_coordinate(): Move zoom center left
  • increase_y_coordinate(): Move zoom center down
  • decrease_y_coordinate(): Move zoom center up

Image Adjustments

  • increase_luminosity(): Increase brightness
  • decrease_luminosity(): Decrease brightness
  • increase_contrast(): Increase contrast
  • decrease_contrast(): Decrease contrast
  • increase_color(): Increase color saturation
  • decrease_color(): Decrease color saturation
  • increase_quality(): Increase image quality
  • decrease_quality(): Decrease image quality

Display Control

  • display_dial(x, y): Display a specific dial position (x, y in range 1-4)

Event Handling

You can register callbacks to be notified when camera events occur:

from pyown.items.camera import Camera, WhatCamera

@Camera.on_status_change
async def handle_camera_event(camera: Camera, what: WhatCamera):
    print(f"Camera {camera.where} event: {what}")