bezmi / jvc_projector

Python library to control JVC projectors
MIT License
16 stars 10 forks source link

How to add commands to hass_custom_components #9

Closed Mr-Lucas closed 2 years ago

Mr-Lucas commented 2 years ago

Hello,

I have the custom integration successfully added to HASS and configured the remote in the home assistant configuration.yaml, with my projector's ip address. This all works fine, I used the services tool, in the developer tools to turn on the projecter and change the profile to cinema. Super cool, and thank you for building this.

I'm now trying to add commands for switching between the Custom Mask settings (I have a scope screen and would like to mask the top and bottom of the screen when zoomed out, I'd like to turn off the mask when zoomed in for non scope content.)

I found these "IP codes" on AVS: (https://www.avsforum.com/threads/official-jvc-20ltd-rs640-x990-x9900-rs540-x790-x7900-owners-thread.2923938/post-60433741)

[Mask Off: 0x21, 0x89, 0x01, 0x49, 0x53, 0x4D, 0x41, 0x32, 0x0A Mask Custom1: 0x21, 0x89, 0x01, 0x49, 0x53, 0x4D, 0x41, 0x30, 0x0A Mask Custom2: 0x21, 0x89, 0x01, 0x49, 0x53, 0x4D, 0x41, 0x31, 0x0A Mask Custom3: 0x21, 0x89, 0x01, 0x49, 0x53, 0x4D, 0x41, 0x33, 0x0A]

I realize you provided instructions on how to add commands, and I think I understand how to do that. However, I don't know WHERE and in what file to add those commands when using the hass_custom_components integration. The file located in the non HASS repo at https://github.com/bezmi/jvc_projector/blob/master/jvc_projector/__init__.py has lines like:

class Commands(Enum):

power commands

power_on = b"\x21\x89\x01\x50\x57\x31\x0A"

I tried adding the following lines to /config/custom_components/jvcprojector/init.py and restarting home assistant, but then the projector remote does not show up in home assistant anymore, so obviously I'm doing something wrong.

class Commands(Enum):

mask commands

mask_off = b"\x21\x89\x01\x49\x53\x4D\x41\x32\x0A"
mask_custom1 = b"\x21\x89\x01\x49\x53\x4D\x41\x30\x0A"
mask_custom2 = b"\x21\x89\x01\x49\x53\x4D\x41\x31\x0A"
mask_custom3 = b"\x21\x89\x01\x49\x53\x4D\x41\x33\x0A"

Could you please provide me a little guidance on how and where to add these additional commands for use in home assistant?

Thanks in advance!

bezmi commented 2 years ago

It's best to test the commands in this module from a windows/Mac/Linux PC outside of homeassistant. If you can do this for me and confirm if they work, I can push an update to both the module and the homeassistant component.

I've copied the mask commands you provided into a standalone python file and attached it to this comment. Here are the instructions to test the functionality.

  1. Make sure you have python installed on your device
  2. Download and extract the attached zip file
  3. Open jvc_projector_mask_test.py in IDLE (the python interpreter).
  4. Hit F5 to run the file, it should take you to the python command line.
  5. Now you just need to type some stuff that will let you test the new commands. Only type the stuff in front of the >>>, the rest are just helpful comments. Hit the return key after every line.
# replace the IP address with your projector's IP
>>> host = "192.168.1.12"
>>> projector = JVCProjector(host)

# if the projector is off, power on
>>> projector.power_on()
# wait until the projector is fully turned on

# check status
>>> projector.is_on()
# should return True

#send a mask command
>>> projector.command("mask_custom1")
# did it work?

>>> projector.command("mask_off")
# did it work?

# now try the other commands

mask_commands_test.zip

Mr-Lucas commented 2 years ago

bezmi - Sorry for the delay in replying.

First the mask commands work great!

Second, I edited the py file you sent and include a few more commands that I could really use for my home theater. Would it be possible to add them too? They have all been tested using the method you describe in step 5, and work as intended. Here are the commands (including the mask commands.)

# mask commands
mask_off = b"\x21\x89\x01\x49\x53\x4D\x41\x32\x0A"
mask_custom1 = b"\x21\x89\x01\x49\x53\x4D\x41\x30\x0A"
mask_custom2 = b"\x21\x89\x01\x49\x53\x4D\x41\x31\x0A"
mask_custom3 = b"\x21\x89\x01\x49\x53\x4D\x41\x33\x0A"

#lamp commands
high_lamp = b"\x21\x89\x01\x50\x4D\x4C\x50\x31\x0A"
low_lamp = b"\x21\x89\x01\x50\x4D\x4C\x50\x30\x0A"

#menu controls
menu = b"\x21\x89\x01\x52\x43\x37\x33\x32\x45\x0A"
down = b"\x21\x89\x01\x52\x43\x37\x33\x30\x32\x0A"
left = b"\x21\x89\x01\x52\x43\x37\x33\x33\x36\x0A"
right = b"\x21\x89\x01\x52\x43\x37\x33\x33\x34\x0A"
up = b"\x21\x89\x01\x52\x43\x37\x33\x30\x31\x0A"
ok = b"\x21\x89\x01\x52\x43\x37\x33\x32\x46\x0A"
back = b"\x21\x89\x01\x52\x43\x37\x33\x30\x33\x0A"

#Lens Aperture commands
aperture_off = b"\x21\x89\x01\x50\x4D\x44\x49\x30\x0a"
aperture_auto1 = b"\x21\x89\x01\x50\x4D\x44\x49\x31\x0a"
aperture_auto2 = b"\x21\x89\x01\x50\x4D\x44\x49\x32\x0a"

#Anamorphic commands
anamorphic_switch_off = b"\x21\x89\x01\x49\x4E\x56\x53\x30\x0A"
anamorphic_switch_a = b"\x21\x89\x01\x49\x4E\x56\x53\x31\x0A"
anamorphic_switch_b = b"\x21\x89\x01\x49\x4E\x56\x53\x32\x0A"
anamorphic_switch_c = b"\x21\x89\x01\x49\x4E\x56\x53\x33\x0A"

Thank you sooooo much for this great integration and humoring me!

bezmi commented 2 years ago

Thanks, these look great, I'll get them added in the coming days.

Mr-Lucas commented 2 years ago

Thanks, these look great, I'll get them added in the coming days.

Awesome! Thank you.

Mr-Lucas commented 2 years ago

Hello bezmi, Not trying to nag, as I appreciate your adding my commands to your integration. But do you have an ETA for inclusion?

Thanks!

bezmi commented 2 years ago

Sorry for the delay, It's just a busy time of year. I've updated the module and the hass_custom_component so give it a go.

Mr-Lucas commented 2 years ago

Sorry to keep being a pain, but I am unable to add this integration to HA. Just in case it was something up with my HACS/HA environment, I tried to add a different 3rd party integration via HACS (the Alex Media Player) and I was able to add it to HA.

Here are the screenshots of my last attempt to add this integration, in the event it helps. I also included my version of HACS and HA. Please let me know how/if I can test further. Thanks!

image

image

image

image

image

image

image

image

image

image

image

image

bezmi commented 2 years ago

@Mr-Lucas Please follow the instructions in the README here. You need to set it up via editing the config file. There is an open issue on that repo to add the necessary stuff to allow setup through the web interface.

NOTE: I changed the repository name to bezmi/homeassistant_jvc_projector_remote just now to better follow the HACS repository naming. This shouldn't affect anything, as github redirects the old url to the new one.

bezmi commented 2 years ago

just an update, I've merged documentation, so see the README.md at the root of bezmi/homeassistant_jvc_projector_remote.

Mr-Lucas commented 2 years ago

Thanks. I was able to get it running following your directions.

But now I am having a problem. I am trying to send the projector a mask command and then a memory command. For example, if I am going to have the projector zoom to fill my scope screen, I also want to mask the unwanted content that will be zoomed off the screen. So - send custom_mask1 and then send memory2. The first command is works, but the second does not. I even put a 20 second delay in place to give the projector plenty of time to finish the first command. Here is that automation. I'm triggering the automation based on an emulated roku keypress.

alias: Projector test 2 description: '' trigger:

Thinking that perhaps your integration could not send multiple commands in the same action, I added another action to the automation, see below, but that did not work either.

alias: Projector test 2 description: '' trigger:

I finally got the 2 projector commands to process by inserting a scene activation between them (yaml below.)

alias: Projector test 2 description: '' trigger:

I can insert a Scene between the two projector actions for this scenario, but it would be more beneficial to be able to have your integration handle multiple commands in one action.

Your probably tired of me by now, but I do appreciate your help and providing this integraiton.

bezmi commented 2 years ago

@Mr-Lucas, this repository is for the python module for projector control. If you're happy with the implemented commands and they work fine, I'd like to keep this issue closed and move over to the homeassistant component for discussions about that side of things.

I'm working on a refactor of the code for the homeassistant component to bring it up to date, so if you raise this as an issue there, I'll be sure to look into it while I work on the refactor (slowly) in my spare time. Please have a look at the raw version of the README to see how to properly format YAML on github.

Your probably tired of me by now, but I do appreciate your help and providing this integraiton.

It's honestly not a problem, non-code contributions like this are very useful to improve the functionality of the code for regular users :)

Mr-Lucas commented 2 years ago

Thanks for the guidance. I'll move this discussion over to the appropriate place and try and get my YAML to format properly, to make things clearer. I do appreciate your work on this.