smartHomeHub / SmartIR

Integration for Home Assistant to control climate, TV and fan devices via IR/RF controllers (Broadlink, Xiaomi, MQTT, LOOKin, ESPHome)
MIT License
2.08k stars 1.01k forks source link

Trying to use Tuya IR devices with SmartIT #1314

Open Wingman2 opened 2 months ago

Wingman2 commented 2 months ago

Hi I was able to use IR devices from Tuya using local Tuya.

Devices like: https://www.zigbee2mqtt.io/devices/ZS06.html I have the Wifi only. so no mqtt

I am able to send and record IR commands in 2 different models. I could setup a basic UI to send IR commands with no problem. Using Local Tuya 2024.9.0 @xZetsubou

I am trying to integrate SmartIR because of the nice UI.

Here is where problems begin.

When trying to send using SmartIR I get this errors in the logs. The values to send look ok.

Error executing service: <ServiceCall remote.send_command (c:01J7E4VNCSQAP3D4KMNVE9KYG1): entity_id=['remote.smart_ir'], command=['b64:GhEaESYCXQYmAiYCJgJdBiYCXQYmAiYCJgImAiYCXQYmAiYCJgImAiYCXQYmAiYCJgImAiYCXQYmAl0GJgImAiYCXQYmAl0GJgImAjDyXQYmAl0GJgJdBiYCXQYmAl0GJgJdBiYCJgImAl0GJgImAiYCJgImAiYCJgImAiYCJgImAiYCJgImAiYCJgImAiYCJgJdBiYCJgImAiYCJgImAiYCJgImAl0GJgJdBiYCXQYmAiYCJgJdBiYCXQYmAl0GJgJdBiYCZRQaERoRJgJdBiYCJgImAl0GJgJdBiYCJgImAiYCJgJdBiYCJgImAiYCJgJdBiYCJgImAiYCJgJdBiYCXQYmAiYCJgJdBiYCXQYmAiYCJgJdBiYCXQYmAl0GJgJdBiYCXQYmAl0GJgImAiYCXQYmAiYCJgImAiYCJgImAiYCJgImAiYCJgImAiYCJgImAiYCJgImAl0GJgImAiYCJgImAiYCJgImAiYCXQYmAl0GJgJdBiYCJgImAl0GJgJdBiYCXQYmAl0GJgIwdQ=='], delay_secs=0.5, num_repeats=1, hold_secs=0.0>

homeassistant.exceptions.ServiceValidationError: Missing required fields

Sending this works in the Actions tab for developers Local Tuya looks like it uses device ID

action: remote.send_command target: device_id: 71fa5ada67cd3dde3c8bb5884c7be8db data: command: Apagar !!!Here it uses the "command" to point to the IR code. num_repeats: 1 delay_secs: 0.4 hold_secs: 0 device: Aire_Zoe !Here it point to the device.

This codes are saved in localtuya_remotes_codes in a different way.

{ "version": 1, "minor_version": 1, "key": "localtuya_remotes_codes", "data": { "ebe3e460ee7566fb97vut1": { <------- IR device ID "Aire_Oficina": { <------- device ID name for TV, HVAC or "bedroom tv" "Encender": "8SB3EDIC/wUyAucBMgLnATIC5wEyAv8FMgLnATIC5wEyAucBMgLnATIC5wEyAucBMgLnATIC5wEyAv8FMgLnATIC5wEyAv8FMgLnATIC/wUyAv8FMgLnATIC5wEyAv8FMgLnATIC5wEyAucBMgLnATIC/wUyAjB1", "Modo_Calefaccion": "0SB3EDIC/gUyAvABMgLwATIC8AHwAf4FMgLwATIC8AEyAvABMgLwATIC8AEyAvABMgLwATIC/gUyAv4FMgLwATIC8AHwAf4FMgLwATIC/gUyAv4FMgLwATIC8AEyAvABMgLwATIC8AEyAv4FMgL+BTIC/gUyAjB1",

My problem is making smartIR to send this IR commands.

I did try to copy the IR codes in a device json but I can´t get it to send it.

Home Assistant

Core 2024.9.1 Supervisor 2024.08.0 Operating System 13.1 Frontend 20240906.0

SmartIR 1.17.9 @smartHomeHub

SmartIR configuration smartir:

climate:

Sensors are working with no problem.

Sample code Code 1070 with custom codes. { "manufacturer":"LG", "supportedModels":[ "PC09SQ NSJ" ], "commandsEncoding":"Base64", "supportedController":"Broadlink", "minTemperature":17, "maxTemperature":30, "precision":1, "device":"Aire_Zoe", "operationModes":[ "cool", "heat", "dry", "fan_only", "auto" ], "fanModes":[ "auto", "low", "mid", "high" ], "commands":{ "off":"Apagar", "cool":{ "auto":{ "17":"FxEXEScCWgYnAicCJwJaBicCWgYnAicCJwInAicCWgYnAicCJwInAicCWgYnAicCJwInAicCWgYnAloGJwInAicCWgYnAloGJwInAicCWgYnAloGJwJaBicCWgYnAloGJwJaBicCJwInAloGJwInAicCJwInAicCJwInAicCJwInAicCJwInAicCJwInAicCJwInAicCJwInAicCJwInAicCJwInAloGJwJaBicCWgYnAloGJwJaBicCWgYnAloGJwJaBicCZBQXERcRJwJaBicCJwInAloGJwJaBicCJwInAicCJwJaBicCJwInAicCJwJaBicCJwInAicCJwJaBicCWgYnAicCJwJaBicCWgYnAicCJwJaBicCWgYnAloGJwJaBicCWgYnAloGJwInAicCWgYnAicCJwInAicCJwInAicCJwInAicCJwInAicCJwInAicCJwInAicCJwInAicCJwInAicCJwInAicCWgYnAloGJwJaBicCWgYnAloGJwJaBicCWgYnAloGJwIwdQ==", "18":"GhEaESYCXQYmAiYCJgJdBiYCXQYmAiYCJgImAiYCXQYmAiYCJgImAiYCXQYmAiYCJgImAiYCXQYmAl0GJgImAiYCXQYmAl0GJgImAjDyXQYmAl0GJgJdBiYCXQYmAl0GJgJdBiYCJgImAl0GJgImAiYCJgImAiYCJgImAiYCJgImAiYCJgImAiYCJgImAiYCJgJdBiYCJgImAiYCJgImAiYCJgImAl0GJgJdBiYCXQYmAiYCJgJdBiYCXQYmAl0GJgJdBiYCZRQaERoRJgJdBiYCJgImAl0GJgJdBiYCJgImAiYCJgJdBiYCJgImAiYCJgJdBiYCJgImAiYCJgJdBiYCXQYmAiYCJgJdBiYCXQYmAiYCJgJdBiYCXQYmAl0GJgJdBiYCXQYmAl0GJgImAiYCXQYmAiYCJgImAiYCJgImAiYCJgImAiYCJgImAiYCJgImAiYCJgImAl0GJgImAiYCJgImAiYCJgImAiYCXQYmAl0GJgJdBiYCJgImAl0GJgJdBiYCXQYmAl0GJgIwdQ==", "19":"DxEPESgCVwYoAigCKAJXBigCVwYoAigCKAIoAigCVwYoAigCKAIoAigCVwYoAigCKAIoAigCVwYoAlcGKAIoAigCVwYoAigCKAJXBigCVwYoAlcGKAJXBigCKAIoAlcGKAJXBigCVwYoAigCKAIoAigCKAIoAigCKAJXBigCKAIoAigCKAJXBigCVwYoAlcGKAIoAigCKAIoAigCKAIoAigCKAIoAigCKAIoAigCKAIoAlcGKAJXBigCVwYoAlcGKAJXBigCghQPEQ8RKAJXBigCKAIoAlcGKAJXBigCKAIoAigCKAJXBigCKAIoAigCKAJXBigCKAIoAigCKAJXBigCVwYoAigCKAJXBigCKAIoAlcGKAJXBigCVwYoAlcGKAIoAigCVwYoAlcGKAJXBigCKAIoAigCKAIoAigCKAIoAlcGKAIoAigCKAIoAlcGKAJXBigCVwYoAigCKAIoAigCKAIoAigCKAIoAigCKAIoAigCKAIoAigCVwYoAlcGKAJXBigCVwYoAlcGKAIwdQ==", "20":"JgBAAGgAAUQQNBESEBIQEhA0EBIPEw8TDxMPEw8TDxMPEhASEBIQEhASEDQPEw80EBIQMxESEDQQNBASEDUPEhAADQUAAAAAAAAAAA==", "21":"JgBAAGkAAUQQNBATDxIQEw80EBIQEhASEBIQEhASEBIPEw8TDxMPEw8TDzQQNA8TDxMPNBASEDUPNQ8SEDUPNBAADQUAAAAAAAAAAA==", "22":"JgBAAGkAAUQQNBASEBIQEhA0DxMPEw8SERIPEw8TDxIQEw8TDxIQEhASEDQQNA81EBIQNBASEDQQNBA0DxMPEw8ADQUAAAAAAAAAAA==", "23":"JgBAAGoAAUMQNBESEBIQEREzERERERERERERERASEBIQEhASEBEREREzEREQEhASEBERMxESEDMRMxEzEhARMxAADQUAAAAAAAAAAA==", "24":"JgBAAGoAAUMQNBIREBIQEhAzERIQEhAREREREREREBIRERASEBIQEREzERERERA0EBERMxEREjMQMxEzETMREBIADQUAAAAAAAAAAA==", "25":"JgBAAGsAAUESMhMQEhASEBIyEhARERERERASEBIQEhASEBEREREQEhEzEREQNBIQEhASMhERETISMhIzETISMhIADQUAAAAAAAAAAA==", "26":"JgBAAG4AAUMSMhEREREREREyEhERERERERASEBEREREREREREREPExEyEhARMxA0EBISMhEREjIQEg8TEREREREADQUAAAAAAAAAAA==", "27":"JgBAAGwAAUQSMhASERMOEw81DxMPEhASEBIQEg8TDxMPEw8SEBIQEhA1DzUPEhASERIPNQ8TDzQQEhASEBIPNQ8ADQUAAAAAAAAAAA==",



I was trying to find a way to see if I can add the missing field in some way. So I can continue experimenting. 

Thanks!.
Wingman2 commented 2 months ago

Following this changes https://github.com/smartHomeHub/SmartIR/commit/1167e8f36c0ae4ab1c4512f243c59b4f5a4e1a01

I was able to add the device. Just hard coded the device name and it works

in controller.py


class TuyaController(AbstractController):
    """Controls a Tuya device."""

    def check_encoding(self, encoding):
        """Check if the encoding is supported by the controller."""
        if encoding not in TUYA_COMMANDS_ENCODING:
            raise Exception("The encoding is not supported "
                            "by the Tuya controller.")

    async def send(self, command):
        """Send a command."""
        service_data = {
            ATTR_ENTITY_ID: self._controller_data,
            'command':  command,
            'delay_secs': self._delay,
            **"device": "Aire_Zoe"**    <---- hard coded.
        }

        await self.hass.services.async_call(
            'remote', 'send_command', service_data)

New config file json { "manufacturer":"LG", "supportedModels":[ "PC09SQ NSJ" ], "commandsEncoding":"Tuya", "supportedController":"Tuya", "minTemperature":17, "maxTemperature":25, "precision":1, "device":"Aire_Zoe", "operationModes":[ "cool", "heat", "dry", "fan_only", "auto" ], "fanModes":[ "auto", "low", "mid", "high" ], "commands":{ "off":"Apagar", "cool":{ "auto":{ "17":"Cool_Auto_17", "18":"Cool_Auto_18", "19":"Cool_Auto_19", "20":"Cool_Auto_20", "21":"Cool_Auto_21", "22":"Cool_Auto_22", "23":"Cool_Auto_23", "24":"Cool_Auto_24", "25":"Cool_Auto_25" },

in tuya remtes codes file It saves the codes like


 "Aire_Zoe": {
        "Apagar": "TBEmERMCeAYTAjICFAJ4BhMCeAYVAjACFAIzAhICeAYUAjICFQIxAhMCeAYTAjICMwITAjICWQYTAngGEwI1AhECeAYzAhMCMgJaBjECWQYUAncGFQJ3BhMCMgIUAncGFgJ2BhMCeAYTAjICFAIyAhUCMQIyAhUCMQJYBhQCMwITAjECMwJZBjICWgYyAlgGFAIyAjICFgIwAhMCNQIQAjMCFAIyAjICEwIzAhMCMgIUAncGFgJ2BhMCWQYyAlsGMQJYBjMCgRQ1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UCJQIlAiUCXQYlAiUCJQIlAiUCXQYlAl0GJQIlAiUCXQYlAl0GJQIlAiUCXQYlAl0GJQJdBiUCXQYlAl0GJQJdBiUCJQIlAl0GJQIlAiUCJQIlAiUCJQIlAiUCJQIlAiUCJQIlAiUCXQYlAiUCJQIlAiUCJQIlAiUCJQIlAiUCJQIlAl0GJQIlAiUCXQYlAl0GJQJdBiUCXQYlAl0GJQJdBiUCgRQPEQ8RJQJdBiUCJQIlAl0GJQJdBiUCJQIlAiUCJQJdBiUCJQIlAiUCJQJdBiUCJQIlAiUCJQJdBiUCXQYlAiUCJQJdBiUCXQYlAiUCJQJdBiUCXQYlAl0GJQJdBiUCXQYlAl0GJQIlAiUCXQYlAiUCJQIlAiUCJQIlAiUCJQIlAiUCJQIlAiUCJQJdBiUCJQIlAiUCJQIlAiUCJQIlAiUCJQIlAiUCXQYlAiUCJQJdBiUCXQYlAl0GJQJdBiUCXQYlAl0GJQIwdQ==",
        "Cool_Auto_25": "GBEYEScCWgYnAicCJwJaBicCWgYnAicCJwInAicCWgYnAicCJwInAicCWgYnAicCJwInAicCWgYnAloGJwInAicCWgYnAloGJwInAicCWgYnAloGJwJaBicCWgYnAloGJwJaBicCJwInAloGJwInAicCJwInAicCJwInAicCJwInAicCJwJaBicCWgYnAicCJwInAicCJwInAicCJwInAicCJwInAicCJwInAicCWgYnAloGJwJaBicCWgYnAloGJwJaBicCZRQYERgRJwJaBicCJwInAloGJwJaBicCJwInAicCJwJaBicCJwInAicCJwJaBicCJwInAicCJwJaBicCWgYnAicCJwJaBicCWgYnAicCJwJaBicCWgYnAloGJwJaBicCWgYnAloGJwInAicCWgYnAicCJwInAicCJwInAicCJwInAicCJwInAloGJwJaBicCJwInAicCJwInAicCJwInAicCJwInAicCJwInAicCJwJaBicCWgYnAloGJwJaBicCWgYnAloGJwIwdQ=="
      }