rrooggiieerr / benqprojector.py Goto Github PK
View Code? Open in Web Editor NEWPython library to control BenQ projectors over the serial (and network?) interface
License: Apache License 2.0
Python library to control BenQ projectors over the serial (and network?) interface
License: Apache License 2.0
Thanks for the great work. Is it possible to add support for the Benq TH585 projector?
Examine output:
root@nas:~/benqprojector.py-main/benqprojector/configs# python3 -m benqprojector telnet 192.168.2.59 8000 examine
Device on 192.168.2.59:8000 available
Model: th585
Supported commands: 3d appmod asp ballastfwversion baud bc bgain blank boffset bri color? con ct directpower gamma ggain goffset highaltitude lampm led ltim mcufwversion menuposition modelname mute pow pp qas rgain roffset scalerfwversion sharp sour sysfwversion tint? vkeystone vol
Supported video sources: hdmi hdmi2 rgb
Supported picture modes: bright livingroom game cine football user1 user2 threed?
Supported color temperatures: warm normal cool native
Supported aspect ratios: 4:3 16:9 16:10 auto real
Supported projector positions: ft re rc fc
Supported lamp modes: lnor eco seco seco2
Supported 3d modes: off? auto? tb fs? fp? sbs da? iv
Supported menu positions: center tl tr br bl
Projector configuration JSON:
{
"commands": [
"3d",
"appmod",
"asp",
"ballastfwversion",
"baud",
"bc",
"bgain",
"blank",
"boffset",
"bri",
"color",
"con",
"ct",
"directpower",
"gamma",
"ggain",
"goffset",
"highaltitude",
"lampm",
"led",
"ltim",
"mcufwversion",
"menuposition",
"modelname",
"mute",
"pow",
"pp",
"qas",
"rgain",
"roffset",
"scalerfwversion",
"sharp",
"sour",
"sysfwversion",
"tint",
"vkeystone",
"vol"
],
"video_sources": [
"hdmi",
"hdmi2",
"rgb"
],
"audio_sources": [],
"picture_modes": [
"bright",
"livingroom",
"game",
"cine",
"football",
"user1",
"user2",
"threed"
],
"color_temperatures": [
"warm",
"normal",
"cool",
"native"
],
"aspect_ratios": [
"4:3",
"16:9",
"16:10",
"auto",
"real"
],
"projector_positions": [
"ft",
"re",
"rc",
"fc"
],
"lamp_modes": [
"lnor",
"eco",
"seco",
"seco2"
],
"3d_modes": [
"off",
"auto",
"tb",
"fs",
"fp",
"sbs",
"da",
"iv"
],
"menu_positions": [
"center",
"tl",
"tr",
"br",
"bl"
]
}
Supported commands are also available in the manual, page 50-53: https://esupportdownload.benq.com/esupport/PROJECTOR/UserManual/TH585/TH585_UM_EN_210913184144.pdf
I've submitted pull request #10 to get this projector functional with this library in home assistant, but I'm running into an inconsistent issue where the integration starts failing after some time (becomes unavailable / fails to set up after restart), and when I manually check projector I find that it has started blocking all commands:
$ telnet projector-esp-link.lan
Trying 192.168.1.96...
Connected to projector-esp-link.lan.
Escape character is '^]'.
>
*pow=?#
*pow=?#
*Block item#
^]
telnet> close
Connection closed.
Once in this state the projector needs to be turned on with the remote / IR blaster to start working again (power cycling didn't even seem to help - only turning it on fixed it), but I'm not yet positive what is triggering this - the power commands should work while the projector is off, and I haven't encountered this issue previously when I've manually controlled the projector over serial (though that could just be because I rarely did so and just got lucky when I did).
I'm wondering if you might have seen this issue before or have any thoughts as to what to try to resolve / further diagnose it?
Some possibilities I've wondered about are if the connection is being interrupted in the middle of a command could the projector get into a bad state? I'm using socat to create a virtual tty that connects to a Wemos D1 Mini over WiFi attached to a RS232 to TTL converter plugged into the serial port, so there are definitely some extra potential points of failure there compared to a direct serial connection that I've used in the past, and I did notice some timeouts when running the 'examine' command... Another thought is could benqprojector be querying a command that had a different meaning or was bugged on the W1070 and puts it into a bad state?
I recognise that this may just end up being a BenQ firmware bug and there might not be anything you can do to help, and won't feel bad if you just close the ticket as not your problem, but any insights you may have would be appreciated.
With python3 -m benqprojector /dev/virtualcom0 9600 examine --debug
, the lamp time cannot be processed, maybe because of the space before the number or the missing #
after? For the latter see also #6
2023-01-15 06:41:58,107 DEBUG command *ltim=?#
2023-01-15 06:41:58,157 DEBUG Response:
2023-01-15 06:41:58,158 DEBUG Empty line
2023-01-15 06:41:58,208 DEBUG Response:
2023-01-15 06:41:58,208 DEBUG Empty line
2023-01-15 06:41:58,259 DEBUG Response: *ltim=?#
2023-01-15 06:41:58,259 DEBUG Command successfully send
2023-01-15 06:41:58,260 DEBUG Response:
2023-01-15 06:41:58,260 DEBUG Empty line
2023-01-15 06:41:58,311 DEBUG Response: *ltim= 1383
2023-01-15 06:41:58,311 DEBUG LC Response: *ltim= 1383
2023-01-15 06:41:58,311 DEBUG Raw response: '*ltim= 1383'
2023-01-15 06:41:58,312 ERROR Unexpected response format, response: *ltim= 1383
See also rrooggiieerr/homeassistant-benqprojector#4 (comment)
aj@gerrard:$ python3 -m benqprojector /dev/ttyS0 9600 status$ python3 -m benqprojector /dev/ttyS0 9600 examine
Unexpected response format, response: illegal format
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/aj/.local/lib/python3.10/site-packages/benqprojector/main.py", line 35, in
if not projector.connect():
File "/home/aj/.local/lib/python3.10/site-packages/benqprojector/benqprojector.py", line 169, in connect
model = self._send_command("modelname")
File "/home/aj/.local/lib/python3.10/site-packages/benqprojector/benqprojector.py", line 367, in _send_command
raise InvallidResponseError(command, action, response)
benqprojector.benqprojector.InvallidResponseError: ('modelname', '?', 'illegal format')
aj@gerrard:
Unexpected response format, response: illegal format
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/aj/.local/lib/python3.10/site-packages/benqprojector/main.py", line 35, in
if not projector.connect():
File "/home/aj/.local/lib/python3.10/site-packages/benqprojector/benqprojector.py", line 169, in connect
model = self._send_command("modelname")
File "/home/aj/.local/lib/python3.10/site-packages/benqprojector/benqprojector.py", line 367, in _send_command
raise InvallidResponseError(command, action, response)
benqprojector.benqprojector.InvallidResponseError: ('modelname', '?', 'illegal format')
In line 117 in benqprojector.py
the regex seems too harsh for my W1100.
=
, for instance \r*auto#\r
, \r*zoomi#\r
, \r*zoomo#\r
, \r*up#\r
, \r*down#\r
, \r*left#\r
, \r*right#\r
, \r*enter#\r
.=
, for instance the answers for all the above.#
, for instance the answer for \r*ltim=?#\r
, see #5I'm not sure, whether this regex is only used on detecting command echos or also on responses?
Hi - tried to examine and got that:
root@Wyse:/home/badger# python3 -m benqprojector serial /dev/ttyUSB0 9600 examine Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.7/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.7/runpy.py", line 109, in _get_module_details
import(pkg_name)
File "/usr/local/lib/python3.7/dist-packages/benqprojector/init.py", line 10, in
from benqprojector.benqprojector import (
File "/usr/local/lib/python3.7/dist-packages/benqprojector/benqprojector.py", line 393
elif (response := self._read_response()) == "":
^
SyntaxError: invalid syntax
root@Wyse:/home/badger#
python3 -m benqprojector serial /dev/ttyUSB0 115200 examine
Command macaddr=? not supported
Device on /dev/ttyUSB0 available
Model: mw519
Supported commands: 3d appmod asp audiosour baud bc blank bri color? con ct directpower freeze highaltitude ins lampm lpsaver ltim modelname mute pow pp qas sharp sour standbymnt vol
Supported video sources: hdmi rgb rgb2 svid vid
Supported audio sources: off rgb rgb2 vid hdmi
Supported picture modes: dynamic preset srgb cine user1 user2
Supported color temperatures: warm normal cool
Supported aspect ratios: 4:3 16:9 16:10 auto real
Supported projector positions: ft re rc fc
Supported lamp modes: lnor eco seco
Supported 3d modes: off auto tb fs fp sbs da iv
Projector configuration JSON:
{
"commands": [
"3d",
"appmod",
"asp",
"audiosour",
"baud",
"bc",
"blank",
"bri",
"color",
"con",
"ct",
"directpower",
"freeze",
"highaltitude",
"ins",
"lampm",
"lpsaver",
"ltim",
"modelname",
"mute",
"pow",
"pp",
"qas",
"sharp",
"sour",
"standbymnt",
"vol"
],
"video_sources": [
"hdmi",
"rgb",
"rgb2",
"svid",
"vid"
],
"audio_sources": [
"off",
"rgb",
"rgb2",
"vid",
"hdmi"
],
"picture_modes": [
"dynamic",
"preset",
"srgb",
"cine",
"user1",
"user2"
],
"color_temperatures": [
"warm",
"normal",
"cool"
],
"aspect_ratios": [
"4:3",
"16:9",
"16:10",
"auto",
"real"
],
"projector_positions": [
"ft",
"re",
"rc",
"fc"
],
"lamp_modes": [
"lnor",
"eco",
"seco"
],
"3d_modes": [
"off",
"auto",
"tb",
"fs",
"fp",
"sbs",
"da",
"iv"
],
"menu_positions": []
}
Some commands don't provide reading, they can only be written.
Example: \r*menu=?#\r
on Benq W1100 doesn't work, but \r*menu=on#\r
and \r*menu=off#\r
do very well.
For them, the function examine
doesn't work correctly, it reports false negative:
2023-01-15 06:41:59,485 DEBUG command *menu=?#
2023-01-15 06:41:59,536 DEBUG Response:
2023-01-15 06:41:59,536 DEBUG Empty line
2023-01-15 06:41:59,586 DEBUG Response:
2023-01-15 06:41:59,587 DEBUG Empty line
2023-01-15 06:41:59,638 DEBUG Response: *menu=?#
2023-01-15 06:41:59,638 DEBUG Command successfully send
2023-01-15 06:41:59,638 DEBUG Response:
2023-01-15 06:41:59,639 DEBUG Empty line
2023-01-15 06:41:59,690 DEBUG Response: Unsupported item
2023-01-15 06:41:59,690 DEBUG LC Response: unsupported item
2023-01-15 06:41:59,690 DEBUG Raw response: 'unsupported item'
2023-01-15 06:41:59,691 ERROR Unexpected response format, response: unsupported item
This is an awesome and works like a charm - thanks for putting this together. Would it be possible to add support for the TK800M projector?
python3 -m benqprojector telnet 192.168.69.38 6638 examine
Device on 192.168.69.38:6638 available
Model: tk800m
Supported commands: 3d appmod asp bc bgain blank boffset bri color con ct directpower gamma? ggain goffset highaltitude lampm ltim menuposition modelname mute pow pp qas rgain roffset sharp sour tint vkeystone vol
Supported video sources: hdmi hdmi2 rgb
Supported picture modes: bright cine? football? user1? user2? isfday? isfnight?
Supported color temperatures: warm normal cool native
Supported aspect ratios: 4:3 16:9 auto real
Supported projector positions: ft re rc fc
Supported lamp modes: lnor eco seco
Supported 3d modes: off auto tb fs fp sbs da? iv?
Supported menu positions: center tl tr br bl
Projector configuration JSON:
{
"commands": [
"3d",
"appmod",
"asp",
"bc",
"bgain",
"blank",
"boffset",
"bri",
"color",
"con",
"ct",
"directpower",
"gamma",
"ggain",
"goffset",
"highaltitude",
"lampm",
"ltim",
"menuposition",
"modelname",
"mute",
"pow",
"pp",
"qas",
"rgain",
"roffset",
"sharp",
"sour",
"tint",
"vkeystone",
"vol"
],
"video_sources": [
"hdmi",
"hdmi2",
"rgb"
],
"audio_sources": [],
"picture_modes": [
"bright",
"cine",
"football",
"user1",
"user2",
"isfday",
"isfnight"
],
"color_temperatures": [
"warm",
"normal",
"cool",
"native"
],
"aspect_ratios": [
"4:3",
"16:9",
"auto",
"real"
],
"projector_positions": [
"ft",
"re",
"rc",
"fc"
],
"lamp_modes": [
"lnor",
"eco",
"seco"
],
"3d_modes": [
"off",
"auto",
"tb",
"fs",
"fp",
"sbs",
"da",
"iv"
],
"menu_positions": [
"center",
"tl",
"tr",
"br",
"bl"
]
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.