rrooggiieerr / homeassistant-benqprojector

Home Assistant integration for BenQ projectors over the serial (and network?) interface.
Apache License 2.0
22 stars 1 forks source link

Projector 'OFF' status is not detected correctly. Will not turn on through dashboard. #2

Closed c1em3ntchua closed 1 year ago

c1em3ntchua commented 1 year ago

Hey @rrooggiieerr, I realised the integration doesn't seem to be detecting the power status of my projector correctly.

My projector has been detected as 'on' even though it was off most of the time. At 6.09pm, I used the BenQ Projector Media Player card to turn off the projector. The projector turns off successfully, but the History states it's being turned on instead. image

I am unable to turn on the projector after that through the media player card.

rrooggiieerr commented 1 year ago

Could you enable logging for this integration and the benqprojector library in HA and see if there are any error messages?

I'm especially interested in the response of the #pow=?* command as I'm expecting it to return off, but if it returns something else like standby or whatever then it's not detected as being off.

Add these lines to your configuration.yaml to enable logging:

logger:
  # default: info
  logs:
    custom_components.benqprojector: debug
    benqprojector: debug
c1em3ntchua commented 1 year ago

Hi @rrooggiieerr, log file is attached.

home-assistant.log

c1em3ntchua commented 1 year ago

I just realised that my projector replies with a Block item when a *pow=?# is sent. Strange because it never did this before.

rrooggiieerr commented 1 year ago

Ok, remember the command echo that your device didn't seem to give back and why the benqprojector library first didn't work for your model?

I then implemented a method to detect if a command echo was expected for a given model.

In your logfile I see some interesting behaviour:

2022-12-06 19:35:01.489 DEBUG (MainThread) [benqprojector.benqprojector] command *modelname=?#
2022-12-06 19:35:01.562 DEBUG (MainThread) [benqprojector.benqprojector] Response: *modelname=x3000i#
2022-12-06 19:35:01.562 DEBUG (MainThread) [benqprojector.benqprojector] No command echo received
2022-12-06 19:35:01.562 DEBUG (MainThread) [benqprojector.benqprojector] Raw response: '*modelname=x3000i#'
2022-12-06 19:35:01.563 DEBUG (MainThread) [benqprojector.benqprojector] Processed response: x3000i

Here you see that no command echo is received.

Later you see no command echo when the power status is requested, all good:

2022-12-06 19:35:01.569 DEBUG (MainThread) [benqprojector.benqprojector] command *pow=?#
2022-12-06 19:35:01.640 DEBUG (MainThread) [benqprojector.benqprojector] Response: *pow=on#
2022-12-06 19:35:01.640 DEBUG (MainThread) [benqprojector.benqprojector] Raw response: '*pow=on#'
2022-12-06 19:35:01.641 DEBUG (MainThread) [benqprojector.benqprojector] Processed response: on

Later you see the Block item you mention and then the projector starts giving back command echos

2022-12-06 19:36:34.875 DEBUG (MainThread) [benqprojector.benqprojector] command *pow=?#
2022-12-06 19:36:34.947 DEBUG (MainThread) [benqprojector.benqprojector] Response: *block item#
2022-12-06 19:36:34.948 INFO (MainThread) [benqprojector.benqprojector] Command *pow=?# blocked item
2022-12-06 19:36:34.948 ERROR (MainThread) [benqprojector.benqprojector] Unknown power status: None
2022-12-06 19:36:39.879 DEBUG (MainThread) [benqprojector.benqprojector] command *pow=?#
2022-12-06 19:36:39.896 DEBUG (MainThread) [benqprojector.benqprojector] Response: *pow=?#
2022-12-06 19:36:39.896 DEBUG (MainThread) [benqprojector.benqprojector] Raw response: '*pow=?#'
2022-12-06 19:36:39.897 DEBUG (MainThread) [benqprojector.benqprojector] Processed response: ?
2022-12-06 19:36:39.897 ERROR (MainThread) [benqprojector.benqprojector] Unknown power status: ?

So along the way the projector is switching from not returning command echos to retuning them.

c1em3ntchua commented 1 year ago

Let me test again. I just performed a factory reset on the projector and now it's replying *pow=off# when I send a *pow=?# command.

c1em3ntchua commented 1 year ago

I'm not too sure why my projector is doing that, but after the factory reset I'm able to power on the projector through HA.

rrooggiieerr commented 1 year ago

Let's see for how long that lasts. Keep me updated

c1em3ntchua commented 1 year ago

Will do. Thanks. Shall keep this issue open for now.

rrooggiieerr commented 1 year ago

Hi @c1em3ntchua, how is the integration working for you now? I had some problems myself similar to this issue and am now testing with a new version of the benqprojector library (not yet released). So if you're still having the issue know that I might have a fix.

c1em3ntchua commented 1 year ago

Hey @rrooggiieerr, looks alright so far, though I'm getting a lot of warnings on blocking calls. I did notice that a v0.0.7.1 was published so I modified my manifest.json to run on that.

rrooggiieerr commented 1 year ago

0.0.7.1 is indeed the test version I'm using

c1em3ntchua commented 1 year ago

I've noticed that the library doesn't work as reliably on the RS232 port on my Dell Wyse 5070, giving out many "Unexpected response" warnings. It works a lot better using an FTDI USB to RS232 adapter. I'm not too sure why.

I'd like to try tweaking the serial read/write logic a bit. I made an initial attempt but haven't been able to get the integration to use my version of the library.

Still trying to figure out stuff while dedicating most of my time to renovation of my new place.

rrooggiieerr commented 1 year ago

FYI, I'm using an FTDI USB to RS232 adapter myself.

I developed the library and integration on my laptop with a local HA instance. I think the problems you have are in the library. What you maybe could do is make the changes and do the testing on your regular pc/laptop and once working create a pull request which I can incorporate in a newr release of the library.

An other thing you could try is disabling some of the controls, or modify the SCAN_INTERVAL in the media_player.py, number.py, select.py, switch.py and sensor.py in the integration to a higher interval to reduce the amount of requests sent to the projector.

rrooggiieerr commented 1 year ago

@c1em3ntchua FYI, I learned something new on how to build HA integrations and am in the process of applying that to the BenQ Projector integration. New release in the upcomming week

c1em3ntchua commented 1 year ago

Looking forward to it!

rrooggiieerr commented 1 year ago

@c1em3ntchua I released a new version of the library and the integration. Give it a try

c1em3ntchua commented 1 year ago

Hey @rrooggiieerr, I briefly tested the new version last night. It does seem more stable. Also, the warnings on blocking calls seem to have disappeared! :)

rrooggiieerr commented 1 year ago

Yes, I fixed that too

c1em3ntchua commented 1 year ago

Hi @rrooggiieerr, sorry I didn't have time to test much. The integration seems stable so far other than during startup where most of the statuses are unavailable for about a minute. Could just be projector related. Those statuses do come online after that.

rrooggiieerr commented 1 year ago

Thanks for getting back to me! Sometimes I still have some problems myself where the connection between HA and the projector gets out of sync and I get lots of errors in the log. This happens only when I've got HA running for a long time (which does not happen very often with all the updates these days) and reloading the integration solves the problem. I have an idea on how to solve that problem, but because it happens only after some days it's difficult to debug. Anyways, there probably will be an other update in the upcoming weeks. Also the integration is now included in HACS, so when the user base grows more bugs will be found and hopefully resolved.

If you projector is off most entities will indeed be unavailable because they just don't work when the projector is off. Once you power on the projector those entities that are supported in your current projector mode will become enabled.

Thanks for your great feedback so far and happy holidays!

c1em3ntchua commented 1 year ago

Happy holidays to you too @rrooggiieerr!