Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IR Button Support #1597

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add IR Button Support #1597

wants to merge 2 commits into from

Conversation

ynsgnr
Copy link

@ynsgnr ynsgnr commented Dec 26, 2023

Add code implemented in #1223 by @murilopereirame

Unfortunately that PR is inactive for almost a year and requested changes haven't been made yet, so I have created this PR with the requested changes (separating IR and HVAC changes and adding Base 64 code support)

Tested it and it works offline with a Tuya Wifi Smart IR Controller

You can get the base64 code from Tuya Cloud as described here

From the previous PR:

IR Control

After some research and a long analysis of the way that Tuya comunicates with generic IR Controls, I've found jasonacox/tinytuya#74 at TinyTuya repo that lead me to that integration.

Some parts of code, like the convertions of signal was taken from there.

For now it is a very basic implementation using the Button entity, as Tuya doesn't provide informations about the registered buttons, is necessary that the user configure the device Key by Key into HASS using the Pronto Code of corresponding Key.

The signal sent by Tuya uses de DP_ID 201, as the device doesn't have a default status, was necessary create a bypass for status checking, so HASS doesn't consider the device unavaliable and to this works propertely, the user needs to input manual DPs for each Key that it's have.

Ex:
The user wants to configure 5 keys, it has to add 5 DPs numbers, as 1 to 5, so the Config Flow can provide the option for add new entities into device for the user.

Another limitation is that ALL keys mus use the DP 201, so I've added a new field to user defines de DP for blast the signal, ignoring provided DPs in first config screen.

For a better implementation, would be nice to reuse the DP to add new entities; Expand the compatibility of IR Controls, identifying the control version, as described into TinyTuya topic; Group all keys of a gadget, today all keys be part of the device.

Some Issues/Requests related to IR Control:
#670 #882 #557
Resume

  • Support for IR Controls
  • Reuse DPs
  • Group keys by gadget
  • Expand compatibility

@ynsgnr
Copy link
Author

ynsgnr commented Dec 28, 2023

@rospogrigio can you take a look at this please

@NJPYY
Copy link

NJPYY commented Jan 5, 2024

How do I get base64, you might be using a wrong url

@ynsgnr
Copy link
Author

ynsgnr commented Jan 5, 2024

How do I get base64, you might be using a wrong url

Updated the link

@lindsaymarkward
Copy link

Thanks for this. Can you please explain or point me to instructions on the best way to use this version instead of the current release found by HACS?

@Andrianjohany
Copy link

Thanks, this PR works worked well.. I made a huge mistake by accepting the HACS update a couple of days ago. Now all of my IR commands are down and have to make them again 😞

Can you please explain or point me to instructions [...]

Here are the detailed steps if it's not too late for you @lindsaymarkward (or for anyone who is looking for it).
⚠️ Do not use the latest base if the PR is left too far behind.

sudo apt update 
sudo apt install git
git config pull.rebase false
git config --global user.email "my@domain.tld"
git config --global user.name "me"
git clone https://github.com/rospogrigio/localtuya.git
git remote add btn https://github.com/ynsgnr/localtuya.git
git branch btnmerge
git switch btnmerge
git pull btn master
git switch master
git merge btnmerge

Once the merge done, upload the files using Home Assistant Visual Code integration (or scp or whatever) and overwrite the custom_component/localtuya files, then reboot HA.

Still hope for PR merge 🤞

@jabari-12
Copy link

jabari-12 commented Apr 1, 2024

How to configure DP please, I configured a few buttons but none of them are available
图片

@Andrianjohany
Copy link

The tuya key1 from tuya iot cloud debugging platform is the expected local tuya button code (b64).

Try to manually learn the button code as a custom remote button (instead of using the suggested one)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants