Telegram and ptz error
Hello. First i am sorry if my reporting is low quality but i have never done anything like this before.
But i have been trying to get this Telegram PTZ & Notifications component to work. With help of chatgpt i have been able to get rid of most problems but now i have ran in dead end. I am running Viseron - 3.1.1 - f6a79b5 in docker on x86 system, camera that i am currently using is webcam connected to raspberry pi in local network. So it doesnt have any kind of PTZ functions.
Here is logs and configuration file if they are in any help figuring out what i do wrong.
Thanks in advance.
PostgreSQL Server has started!
2025-05-06 05:24:16.836 [INFO ] [viseron.core] - -------------------------------------------
2025-05-06 05:24:16.837 [INFO ] [viseron.core] - Initializing Viseron 3.1.1
2025-05-06 05:24:16.843 [INFO ] [viseron.components] - Setting up component logger
2025-05-06 05:24:16.844 [INFO ] [viseron.components] - Setup of component logger took 0.0 seconds
2025-05-06 05:24:16.844 [INFO ] [viseron.components] - Setting up component data_stream
2025-05-06 05:24:16.846 [INFO ] [viseron.components] - Setup of component data_stream took 0.0 seconds
2025-05-06 05:24:16.846 [INFO ] [viseron.components] - Setting up component webserver
2025-05-06 05:24:16.849 [INFO ] [viseron.components] - Setup of component webserver took 0.0 seconds
2025-05-06 05:24:16.849 [INFO ] [viseron.components] - Setting up component storage
2025-05-06 05:24:16.920 [INFO ] [alembic.runtime.migration] - Context impl PostgresqlImpl.
2025-05-06 05:24:16.921 [INFO ] [alembic.runtime.migration] - Will assume transactional DDL.
2025-05-06 05:24:16.941 [INFO ] [viseron.components] - Setup of component storage took 0.1 seconds
2025-05-06 05:24:16.941 [INFO ] [viseron.components] - Setting up component telegram
2025-05-06 05:24:16.942 [INFO ] [viseron.components] - Setting up component nvr
2025-05-06 05:24:16.942 [INFO ] [viseron.components] - Setting up component mog2
2025-05-06 05:24:16.943 [INFO ] [viseron.components] - Setting up component darknet
2025-05-06 05:24:16.943 [INFO ] [viseron.components] - Setup of component nvr took 0.0 seconds
2025-05-06 05:24:16.943 [INFO ] [viseron.components] - Setting up component ffmpeg
2025-05-06 05:24:16.949 [INFO ] [viseron.components] - Setup of component mog2 took 0.0 seconds
2025-05-06 05:24:16.950 [INFO ] [viseron.components] - Setup of component ffmpeg took 0.0 seconds
2025-05-06 05:24:17.179 [ERROR ] [viseron.components] - Uncaught exception setting up component telegram: 'ptz'
Traceback (most recent call last):
File "/src/viseron/components/__init__.py", line 169, in setup_component
result = component_module.setup(self._vis, config)
File "/src/viseron/components/telegram/__init__.py", line 116, in setup
if not config[CONFIG_PTZ_COMPONENT]:
KeyError: 'ptz'
2025-05-06 05:24:17.179 [ERROR ] [viseron.components] - Setup of component telegram failed
2025-05-06 05:24:17.179 [ERROR ] [viseron.components] - Failed setup of component telegram
webserver:
auth:
telegram:
telegram_bot_token: REDACTED
telegram_chat_ids:
- REDACTED
telegram_user_ids:
- REDACTED
send_detection_thumbnail: true
send_detection_video: true
send_detection_message: true
cameras:
camera_1:
ffmpeg:
camera:
camera_1:
name: paskapallo
host: REDACTED
port: 80
path: /webcam2/?action=stream
stream_format: mjpeg
fps: 30
recorder:
codec: h264
create_event_clip: true
darknet:
object_detector:
cameras:
camera_1:
fps: 1
scan_on_motion_only: true
labels:
- label: person
confidence: 0.50
trigger_event_recording: true
- label: car
confidence: 0.50
trigger_event_recording: true
mog2:
motion_detector:
cameras:
camera_1:
fps: 1
storage:
recorder:
tiers:
- path: /
events:
max_age:
days: 14
nvr:
camera_1:
logger:
default_level: info
logs:
viseron.components.ffmpeg: debug
viseron.components.edgetpu: debug
viseron.components.telegram: debug
cameras:
camera_one: debug
You need to setup the ptz integration as well.
Not the most elegant error code you are receiving, will try to improve that
How do i do that? I have hard time to find documentation on seting up ptz. Only mentions on ptz I find are in ONVIF PTZ control and Telegram PTZ & Notifications
It's this component: https://viseron.netlify.app/components-explorer/components/ptz
But I see now that that is not going to work, the Telegram component requires to setup ptz but since your camera doesn't have that the setup of ptz will fail.
These components are quite new still and wasn't provided by me so I don't know them very well yet.
@smelis Do you have time to look at this. Seems Telegram cannot be used without PTZ
Oh ok thanks for super fast answers!
Yeah it looks like that's a bug. The check shouldn't have been
if not config[CONFIG_PTZ_COMPONENT]:
but
if not CONFIG_PTZ_COMPONENT in config:
Have you tried setting up an empty ptz component? I'm not sure if that will just have it fail somewhere else or get you a step closer, but it's an easy thing to try.
If I add empty ptz component it gives me basicly same end results errors in ptz and errors in Telegram component. Well same end result with Telegram component and more errors with ptz
2025-05-06 22:31:51.988 [ERROR ] [viseron.components] - Error validating config for component ptz: required key not provided @ data['ptz']['cameras']. Got None
Traceback (most recent call last):
File "/src/viseron/components/__init__.py", line 131, in validate_component_config
return component_module.CONFIG_SCHEMA(self._config)
File "/usr/local/lib/python3.10/dist-packages/voluptuous/schema_builder.py", line 281, in __call__
return self._compiled([], data)
File "/usr/local/lib/python3.10/dist-packages/voluptuous/schema_builder.py", line 625, in validate_dict
return base_validate(path, data.items(), out)
File "/usr/local/lib/python3.10/dist-packages/voluptuous/schema_builder.py", line 458, in validate_mapping
raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: required key not provided @ data['ptz']['cameras']
2025-05-06 22:31:51.990 [ERROR ] [viseron.components] - Setup of component ptz failed
2025-05-06 22:31:51.990 [ERROR ] [viseron.components] - Failed setup of component ptz
2025-05-06 22:31:52.050 [INFO ] [viseron.components.telegram] - No PTZ component. Won't start Telegram PTZ Controller.
2025-05-06 22:31:52.143 [ERROR ] [viseron.components] - Uncaught exception setting up component telegram: local variable 'telegram_ptz' referenced before assignment
Traceback (most recent call last):
File "/src/viseron/components/__init__.py", line 169, in setup_component
result = component_module.setup(self._vis, config)
File "/src/viseron/components/telegram/__init__.py", line 125, in setup
if telegram_ptz:
UnboundLocalError: local variable 'telegram_ptz' referenced before assignment
2025-05-06 22:31:52.144 [ERROR ] [viseron.components] - Setup of component telegram failed
2025-05-06 22:31:52.144 [ERROR ] [viseron.components] - Failed setup of component telegram
Ok, yeah, the ptz requires at least a 'cameras' property, but as far as I can tell it should work without any camera's defined in it. So, you could try:
ptz:
cameras:
And see if that works.
If it doesn't work, you could try defining your camera and see if that works:
ptz:
cameras:
camera_1:
onvif_username: <username> # required
onvif_password: <password> # required
This spec details what properties are required and which not: https://viseron.netlify.app/components-explorer/components/ptz
With this later configure it seems like working atleast it loads Telegram component and PTZ component without errors. And now only error i get is this. That i think is more error on that it cannot connect ONVIFCamera.
Sadly i at the moment i cannot test if it works properly. On second thought is there a manual way to triger detections or events on Viseron?
Thanks for great help!
2025-05-07 00:09:19.341 [ERROR ] [root] - Uncaught thread exception in thread data_stream.callback.<bound method PTZ._camera_registered of <viseron.components.ptz.PTZ object at 0x73021cb0e3b0>>
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/src/viseron/components/ptz/__init__.py", line 165, in _camera_registered
onvif_camera = ONVIFCamera(
File "/usr/local/lib/python3.10/dist-packages/onvif/client.py", line 216, in __init__
self.update_xaddrs()
File "/usr/local/lib/python3.10/dist-packages/onvif/client.py", line 223, in update_xaddrs
self.devicemgmt = self.create_devicemgmt_service()
File "/usr/local/lib/python3.10/dist-packages/onvif/client.py", line 333, in create_devicemgmt_service
return self.create_onvif_service('devicemgmt', from_template)
File "/usr/local/lib/python3.10/dist-packages/onvif/client.py", line 312, in create_onvif_service
xaddr, wsdl_file, binding_name = self.get_definition(name, portType)
File "/usr/local/lib/python3.10/dist-packages/onvif/client.py", line 292, in get_definition
raise ONVIFError('No such file: %s' % wsdlpath)
onvif.exceptions.ONVIFError: Unknown error: No such file: /usr/local/lib/python3.10/dist-packages/wsdl/devicemgmt.wsdl
Which config made it work? This one:
ptz:
cameras:
or this one:
ptz:
cameras:
camera_1:
onvif_username: <username> # required
onvif_password: <password> # required
I'd expect it could crash the way it does with the second one, but not the first one.
ptz:
cameras:
camera_1:
onvif_username: <username> # required
onvif_password: <password> # required
This one works.
Can anyone provide insight on the PTZ preset configs? The example shows values of x: and y:, but the spec shows pan: and tilt:. I'm not certain which is valid
I think it's pan and tilt, not x and y. On 3.1.2 I'm getting the error:
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/src/viseron/components/ptz/__init__.py", line 165, in _camera_registered
onvif_camera = ONVIFCamera(
File "/usr/local/lib/python3.10/dist-packages/onvif/client.py", line 216, in __init__
self.update_xaddrs()
File "/usr/local/lib/python3.10/dist-packages/onvif/client.py", line 223, in update_xaddrs
self.devicemgmt = self.create_devicemgmt_service()
File "/usr/local/lib/python3.10/dist-packages/onvif/client.py", line 333, in create_devicemgmt_service
return self.create_onvif_service('devicemgmt', from_template)
File "/usr/local/lib/python3.10/dist-packages/onvif/client.py", line 312, in create_onvif_service
xaddr, wsdl_file, binding_name = self.get_definition(name, portType)
File "/usr/local/lib/python3.10/dist-packages/onvif/client.py", line 292, in get_definition
raise ONVIFError('No such file: %s' % wsdlpath)
onvif.exceptions.ONVIFError: Unknown error: No such file: /usr/local/lib/python3.10/dist-packages/wsdl/devicemgmt.wsdl
I do see there was a commit that addressed that, so I'll try dev
Hello.
I have been trying to get this Telegram PTZ & Notifications component to work. I am running Viseron v.3.2.3 in docker on Ubuntu 24.04 x64 system. Camera, darknet, mog2, nvr, compreface are work correctly. But Telegram PTZ & Notifications is not start up.
YML: ptz: cameras: camera_1: onvif_username: oooooooooo onvif_password: bbbbbbbbbb
telegram: telegram_bot_token: xxxxxxxxxxxxxxxxxxxxx telegram_chat_ids: - yyyyyyyyyy telegram_user_ids: - yyyyyyyyyy detection_label: person send_detection_thumbnail: true send_detection_video: true send_detection_message: true cameras: camera_1: camera_2:
LOG: 2025-09-03 17:35:36.142 [INFO ] [viseron.core] - Initializing Viseron 3.2.3 2025-09-03 17:35:36.163 [INFO ] [viseron.components] - Setting up component logger 2025-09-03 17:35:36.166 [INFO ] [viseron.components] - Setup of component logger took 0.0 seconds 2025-09-03 17:35:36.166 [INFO ] [viseron.components] - Setting up component data_stream 2025-09-03 17:35:36.168 [INFO ] [viseron.components] - Setup of component data_stream took 0.0 seconds 2025-09-03 17:35:36.168 [INFO ] [viseron.components] - Setting up component webserver 2025-09-03 17:35:36.172 [INFO ] [viseron.components] - Setup of component webserver took 0.0 seconds 2025-09-03 17:35:36.172 [INFO ] [viseron.components] - Setting up component storage 2025-09-03 17:35:36.188 [INFO ] [alembic.runtime.migration] - Context impl PostgresqlImpl. 2025-09-03 17:35:36.188 [INFO ] [alembic.runtime.migration] - Will assume transactional DDL. 2025-09-03 17:35:36.223 [INFO ] [viseron.components] - Setup of component storage took 0.0 seconds 2025-09-03 17:35:36.224 [INFO ] [viseron.components] - Setting up component compreface 2025-09-03 17:35:36.224 [INFO ] [viseron.components] - Setting up component ffmpeg 2025-09-03 17:35:36.224 [INFO ] [viseron.components] - Setting up component darknet 2025-09-03 17:35:36.225 [INFO ] [viseron.components] - Setting up component ptz 2025-09-03 17:35:36.225 [INFO ] [viseron.components] - Setting up component nostorage 2025-09-03 17:35:36.226 [INFO ] [viseron.components] - Setting up component telegram 2025-09-03 17:35:36.235 [INFO ] [viseron.components] - Setting up component mog2 2025-09-03 17:35:36.235 [INFO ] [viseron.components] - Setting up component oldstorage 2025-09-03 17:35:36.236 [INFO ] [viseron.components] - Setting up component nvr 2025-09-03 17:35:36.257 [INFO ] [viseron.components] - Setup of component nvr took 0.0 seconds 2025-09-03 17:35:36.262 [INFO ] [viseron.components] - Setup of component ffmpeg took 0.0 seconds 2025-09-03 17:35:36.278 [INFO ] [viseron.components] - Setup of component mog2 took 0.0 seconds 2025-09-03 17:35:36.745 [ERROR ] [viseron.components] - Uncaught exception setting up component telegram: 'ptz' Traceback (most recent call last): File "/src/viseron/components/init.py", line 169, in setup_component result = component_module.setup(self._vis, config) File "/src/viseron/components/telegram/init.py", line 119, in setup telegram_ptz = TelegramPTZ(vis, component_config) File "/src/viseron/components/telegram/init.py", line 284, in init self._ptz: PTZ = self._vis.data[CONFIG_PTZ_COMPONENT] KeyError: 'ptz'
2025-09-03 17:35:36.746 [ERROR ] [viseron.components] - Setup of component telegram failed 2025-09-03 17:35:36.746 [ERROR ] [viseron.components] - Failed setup of component telegram 2025-09-03 17:35:36.804 [DEBUG ] [viseron.components.ptz] - Device management file path: $/usr/local/lib/python3.10/site-packages/wsdl 2025-09-03 17:35:36.804 [INFO ] [viseron.components] - Setup of component ptz took 0.2 seconds 2025-09-03 17:35:37.150 [INFO ] [viseron.components] - Setup of component darknet took 0.9 seconds
What i do wrong?
Will take a look over the weekend and see if I can figure out what's going on.
Judging by the logs, it appears that the telegram component sets up before ptz has completed. There is currently no mechanism for components to wait on other components
I suggest this change:
diff --git a/viseron/components/telegram/__init__.py b/viseron/components/telegram/__init__.py
index d1981520..f7d879b1 100644
--- a/viseron/components/telegram/__init__.py
+++ b/viseron/components/telegram/__init__.py
@@ -113,8 +113,9 @@ def setup(vis: Viseron, config) -> bool:
"""Set up the ptz component."""
component_config = config[COMPONENT]
- if not config[CONFIG_PTZ_COMPONENT]:
+ if not config.get(CONFIG_PTZ_COMPONENT):
LOGGER.info("No PTZ component. Won't start Telegram PTZ Controller.")
+ telegram_ptz = None
else:
telegram_ptz = TelegramPTZ(vis, component_config)
Thread(target=telegram_ptz.run_async).start()
Seems to fix this issue for me. It still does not send me any notifications though 😁 But at least seems to initialize successfully.
Ah, I forgot to set create_event_clip in my config:
ffmpeg:
camera:
camera_1:
recorder:
create_event_clip: true
With this patch and this setting it works.