Skip to content

Instantly share code, notes, and snippets.

@svyatogor
Last active May 6, 2026 21:08
Show Gist options
  • Select an option

  • Save svyatogor/7839d00303998a9fa37eb48494dd680f to your computer and use it in GitHub Desktop.

Select an option

Save svyatogor/7839d00303998a9fa37eb48494dd680f to your computer and use it in GitHub Desktop.
Convert SmartIR Broadlink commands to Tuya
@cord-otten
Copy link
Copy Markdown

Not yet. I tried some online converters without luck. I suspect the codes are not "standard" broadlink format.

@Jody1818
Copy link
Copy Markdown

I used the code and it does not add "ir_code_to_send":
should I do it menually? am I doing something wrong?
is it not a must?

@sneakysandals
Copy link
Copy Markdown

I got the script to run but have the same issue as @Jody1818 where none of the lines in the output have "ir_code_to_send"

Also all the output IR codes are wildly different from the original .json codes.

@Wobak
Copy link
Copy Markdown

Wobak commented Aug 27, 2025

I used the code and it does not add "ir_code_to_send": should I do it menually? am I doing something wrong? is it not a must?

I got the script to run but have the same issue as @Jody1818 where none of the lines in the output have "ir_code_to_send"

Also all the output IR codes are wildly different from the original .json codes.

The codes are different because they're not encoded in the same format, so it's completely normal.
The ir_code_to_send is not added because you should add it to your climate platform like this (in the configuration.yaml):

climate:
  - platform: smartir
    name: "My AC"
    device_code: 8888
    controller_data: "zigbee2mqtt/UFO-R11 Test/set/ir_code_to_send"

In that case the payload needed just needs to be the IR code.

@matthuisman
Copy link
Copy Markdown

For issue with invalid int, its because some temps dont have a command in the source file:
eg:
https://raw.githubusercontent.com/smartHomeHub/SmartIR/refs/heads/master/codes/climate/1281.json

        "static": {
          "16": "",
          "17": "JgAGAWk0DA0NDQ4mDQ4NJg4MDQ0NDg0mDiYNDg0MDQ0OJg4nDA4NDQ0MDg0NDQwODQ0NDA4NDQ0NDQ0NDQwOJw0NDQ0NDgwNDQ0ODA0NDScNDQ4MDQ0NDg0mDiYNJw0oDCgNJw0mDicMDg0NDScNDQwODQ0NDA4NDQ0NDQ0NDScNJw0NDQ4MDQ0NDgwNDQ0ODSYODQwNDQ4NDA0NDg0MDQ0ODQwNDg0mDicMDg0NDQwODQ0NDA4NDQ0MDg0NDQ0NDQ0NDA4NDQ0NDQ0NDQ4MDQ0NDgwNDQ0ODA0NDQ4MDQ0NDg0MDQ0ODQwNDQ4NDA0NDiYODQ0MDSgNDA4nDCgNDA4NDQ0MKA0ADQU=",

these should simply be skipped.
I suggest the script is updated to do that.
eg.
if isinstance(value, str):
becomes
if isinstance(value, str) and value:

@vincenzoca69
Copy link
Copy Markdown

I tried the conversion but with the tuya sensors the conversion files don't work. Does anyone have any ideas?

@tomer2526
Copy link
Copy Markdown

tomer2526 commented Mar 16, 2026

I have made a website that performs the conversion directly in your browser!
Here is a link: Broadlink → Raw MQTT Converter
You can even convert the other way around now
Here is a link to the site's Git: https://github.com/tomer2526/Convert-Broadlink-Codes-to-Row-MQTT-Format

@sergiobaiao
Copy link
Copy Markdown

sergiobaiao commented May 6, 2026

if you want to implement this also, it converts from Globalcache's format (sendir...) to Raw MQTT:

`

<title>GC to Z2M IR Converter</title> <style> body { font-family: sans-serif; max-width: 800px; margin: 20px auto; padding: 0 20px; line-height: 1.6; background: #f4f4f9; } textarea { width: 100%; height: 150px; margin-bottom: 10px; padding: 10px; border: 1px solid #ccc; border-radius: 4px; } button { background: #007bff; color: white; border: none; padding: 10px 20px; border-radius: 4px; cursor: pointer; font-size: 16px; } button:hover { background: #0056b3; } .result-item { background: white; padding: 15px; margin-top: 10px; border-radius: 4px; border-left: 5px solid #007bff; box-shadow: 0 2px 4px rgba(0,0,0,0.1); } code { background: #eee; padding: 2px 5px; word-break: break-all; } h2 { color: #333; } </style>

Global Caché to Zigbee2MQTT Raw

Paste one or more commands (one per line):

<textarea id="input" placeholder="sendir,1:1,1,38000,1,1,341,170,21,63..."></textarea> Convert All
<div id="results"></div>

<script>
    function convert() {
        const input = document.getElementById('input').value;
        const lines = input.split('\n').filter(line => line.trim() !== "");
        const resultsDiv = document.getElementById('results');
        resultsDiv.innerHTML = "";

        lines.forEach((line, index) => {
            const parts = line.split(',');
            if (parts.length < 7) return;

            const freq = parseInt(parts[3]);
            const rawValues = parts.slice(6).map(Number);
            
            // Convert GC pulses to Microseconds
            const durations = rawValues.map(val => Math.round((val / freq) * 1000000));

            // Encode to Base64 (using 16-bit Little Endian as per Tuya Z2M standards)
            const uint16Array = new Uint16Array(durations);
            const base64 = btoa(String.fromCharCode.apply(null, new Uint8Array(uint16Array.buffer)));

            const div = document.createElement('div');
            div.className = 'result-item';
            div.innerHTML = `<strong>Command ${index + 1}:</strong><br><code>${base64}</code>`;
            resultsDiv.appendChild(div);
        });
    }
</script>
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment