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
@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