jasonacox / tinytuya

Python API for Tuya WiFi smart devices using a direct local area network (LAN) connection or the cloud (TuyaCloud API).
MIT License
879 stars 159 forks source link

Local support for sending IR #351

Open rluvaton opened 1 year ago

rluvaton commented 1 year ago

there is a cloud API for sending learned key for IR remote: Docs

Is there an equivalent for local mode?

uzlonewolf commented 1 year ago

https://github.com/jasonacox/tinytuya/blob/master/examples/Contrib/IRRemoteControlDevice-example.py

uzlonewolf commented 1 year ago

Hi @rluvaton, were you able to get it working with the example?

rluvaton commented 1 year ago

Hey, I don't see in that example the key id 😬

uzlonewolf commented 1 year ago

Hmm, it does appear to be kinda buried at the bottom in favor of parsing it into its head+key components. A more succinct example would be:

ir = Contrib.IRRemoteControlDevice( 'abcdefghijklmnop123456', '172.28.321.475', '1234567890123abc', persist=True )

# learn a new remote
print("Press button on your remote control")
button = ir.receive_button(timeout=15)
if (button == None):
    print("Timeout, button code is not received")
    sys.exit(1)

print("Received button:", button)

for i in range(10):
    print("Simulating button press...")
    ir.send_button(button)
    sleep(1)
uzlonewolf commented 1 year ago

Hi @rluvaton, did the above example help any?

rluvaton commented 1 year ago

It's not the same, I already have learned key