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.
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.
display_dial
async
¶
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
¶
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. |
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 004001: Camera 014002: 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 videofree_resources(): Free audio and video resources
Zoom Controls¶
zoom_in(): Zoom in the camera viewzoom_out(): Zoom out the camera viewincrease_x_coordinate(): Move zoom center rightdecrease_x_coordinate(): Move zoom center leftincrease_y_coordinate(): Move zoom center downdecrease_y_coordinate(): Move zoom center up
Image Adjustments¶
increase_luminosity(): Increase brightnessdecrease_luminosity(): Decrease brightnessincrease_contrast(): Increase contrastdecrease_contrast(): Decrease contrastincrease_color(): Increase color saturationdecrease_color(): Decrease color saturationincrease_quality(): Increase image qualitydecrease_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}")