prasad-edlabadka / homebridge-tuya-ir

Allows homebridge to control Tuya Smart IR based devices
Apache License 2.0
51 stars 22 forks source link

Nice work but any chance we can add custom commands? #38

Closed scrolls-mckenzie closed 2 years ago

scrolls-mckenzie commented 2 years ago

Hello, Thanks very much for building this plugin. IR remotes are definitely a grey area for home automation and can absolutely see why you specify a small amount of appliances as there are too many to support.

I have been looking at some devices that are not supported and wanted to ask if there would be any options to add custom commands. Using the Tuya IoT platform, I was able to register the IR blaster and custom commands that I had set up in the Tuya Smart Life app. In doing so was also able to run through the diagnostics console and identify the remotes that I am using from custom commands. Now I have a list of the actual commands that are being run via my custom remotes.

For instance, my older xbox can be controlled via the IR blaster, however in your app, the only control I have is on and off. As i have been able to map the commands being sent and used in the Tuya IoT platform, can custom buttons be added to action these commands?

Appreciate any feedback you may have as this may be a cheeky way to extend the supported devices without having to code every option out there.

Thanks

prasad-edlabadka commented 2 years ago

Hello,

I wish HomeKit supported all the devices. Apple HomeKit doesn't have all the devices that IR will support. There isn't an Xbox controller device type in HomeKit. Moreover, it doesn't support custom devices. So we all have to live with what apple provides.

scrolls-mckenzie commented 2 years ago

Hello,

Agreed that the XBOX controller is not a default one in homekit. What i have seen though, in the tuya iot platform, is that the custom remotes are showing that they are using commands that are from generic devices. Essentially it looks like there is some crossover on the commands across devices so that the Tuya IoT platfrom is showing the following for an xbox command (i've omitted a couple of ID's)

{
  "result": {
    "brand_id": 0,
    "category_id": 999,
    "duplicate_power": true,
    "key_list": [
      {
        "key": "1642569103207",
        "key_id": 2,
        "key_name": "mode",
        "standard_key": false
      },
      {
        "key": "1642569153592",
        "key_id": 3,
        "key_name": "temperature_up",
        "standard_key": false
      },
      {
        "key": "1642574516965",
        "key_id": 5,
        "key_name": "wind_speed",
        "standard_key": false
      },
      {
        "key": "1642576257589",
        "key_id": 6,
        "key_name": "ud_wind_mode_swing",
        "standard_key": false
      }
    ],
    "remote_index": #####,
    "single_air": false
  },
  "success": true,
  "t": #####
}

These don't appear to be specific xbox commands but more generic ones so that's why I was wondering if this could be supported. It seems that all devices that re custom commands in Tyua use the device id 0. It would be my responsibility to map the correct brand id and key ids to the commands but the support in homekit could possibly be a supported device type. I had read in earlier posts that there is some support issue with what actually works and doess not. For instance my Samsung TV is supported in Tuya IoT but it is not supported in the homebride and your plugin as it still only exposed on/off functions whereas the Tuya IoT platform shows all buttons, commands and brand specific items

Thanks

prasad-edlabadka commented 2 years ago

With homebridge you can ofcouse map any IR code to any HomeKit device. However, it can't be made generic for everyone. Imagine Xbox showing up as a Fan in HomeKit.

In this case feel free to fork the code and customise the mapping that works for you.