Skip to content

Fix for TADO X NoSerial and Authentification error #121

@Bartalbert

Description

@Bartalbert

I am not very familiar with working on Github but want to share the solution that worked for me. After trying a couple of times and getting the NoSerial en Authetification failure messages, this worked for me.

Sorry if it does meet the official requirements for sharing :) Script is made with the assistants of Gemini.

`#!/bin/bash
# ==============================================================================
# Tado X / Device Flow Fix Installer for Home Assistant
# 
# ISSUE:  Tado X users experience infinite authentication loops or crashes 
#         due to missing 'shortSerialNo' in Matter devices.
# SOLUTION: Installs the 'tado-oauth-deviceflow' branch, forces a version 
#           override to prevent Core conflicts, and patches the coordinator.
#
# CREDITS: 
# - Original work by @erwindouna
# - Branch maintenance by @karlbeecken
# - Installer script & patch logic optimized by "Bart's HA Partner" & Bart
# ==============================================================================

set -e

# Configuration
CONFIG_DIR="/config"
CUSTOM_DIR="$CONFIG_DIR/custom_components/tado"
TEMP_DIR="$CONFIG_DIR/temp_tado_download"
# Using KarlBeecken's fork which contains the working Device Flow branch
ZIP_URL="https://github.com/karlbeecken/ha-core/archive/refs/heads/tado-oauth-deviceflow.zip"

echo "🚀 STARTED: Tado X Fix Installer..."

# 1. CLEANUP OLD INSTALLATIONS
# We remove previous attempts to ensure no file conflicts occur.
echo "🧹 Step 1: Cleaning up old installations..."
if [ -d "$CUSTOM_DIR" ]; then
    rm -rf "$CUSTOM_DIR"
    echo "   - Removed existing custom_components/tado"
fi
rm -rf "$TEMP_DIR"

# 2. DOWNLOAD SOURCE
echo "⬇️  Step 2: Downloading patched source code..."
mkdir -p "$TEMP_DIR"
wget -O "$TEMP_DIR/source.zip" "$ZIP_URL" > /dev/null 2>&1
echo "   - Download complete."

# 3. EXTRACT & INSTALL
echo "📦 Step 3: Extracting and installing..."
unzip -q "$TEMP_DIR/source.zip" -d "$TEMP_DIR"

# Locate the correct folder structure inside the zip
SOURCE_FILES=$(find "$TEMP_DIR" -type d -path "*/components/tado" | head -n 1)

if [ -z "$SOURCE_FILES" ]; then
    echo "❌ ERROR: Could not find 'tado' component in the downloaded zip."
    exit 1
fi

mkdir -p "$CONFIG_DIR/custom_components"
cp -r "$SOURCE_FILES" "$CONFIG_DIR/custom_components/"
echo "   - Files placed in /config/custom_components/tado"

# 4. FORCE VERSION OVERRIDE (CRITICAL)
# We set version to 9.9.9 to force Home Assistant to use this Custom Component
# instead of the built-in Core integration (which might have a newer build date but broken code).
echo "📝 Step 4: Forcing version override (v9.9.9)..."
MANIFEST="$CUSTOM_DIR/manifest.json"
python3 -c "
import json
import os

manifest_path = '$MANIFEST'
if os.path.exists(manifest_path):
    with open(manifest_path, 'r') as f:
        data = json.load(f)
    
    data['version'] = '9.9.9'
    
    with open(manifest_path, 'w') as f:
        json.dump(data, f, indent=2)
    print('   - Manifest version updated to 9.9.9')
else:
    print('   ❌ ERROR: manifest.json not found!')
"

# 5. APPLY 'SHORT SERIAL' CRASH PATCH
# Tado X (Matter) devices do not return a shortSerialNo, causing a crash in the original code.
# This Python script injects a safe .get() method.
echo "🧠 Step 5: Patching coordinator.py for Tado X compatibility..."
COORD_FILE="$CUSTOM_DIR/coordinator.py"

python3 -c "
import re
import os

path = '$COORD_FILE'
if os.path.exists(path):
    with open(path, 'r') as f:
        content = f.read()

    # Regex to find device['shortSerialNo'] or device[\"shortSerialNo\"]
    pattern = r'device\[([\"\047])shortSerialNo\1\]'
    replacement = 'device.get(\"shortSerialNo\", \"unknown\")'

    if re.search(pattern, content):
        new_content = re.sub(pattern, replacement, content)
        with open(path, 'w') as f:
            f.write(new_content)
        print('   ✅ PATCH APPLIED: Fixed shortSerialNo crash.')
    elif 'device.get' in content and 'shortSerialNo' in content:
        print('   ℹ️  ALREADY PATCHED: File looks good.')
    else:
        print('   ⚠️  WARNING: Could not find the code pattern to patch. Check manually.')
else:
    print('   ❌ ERROR: coordinator.py not found!')
"

# 6. FINAL CLEANUP
echo "🧹 Step 6: Removing temporary files..."
rm -rf "$TEMP_DIR"
# Remove compiled python files to force re-compilation
find "$CUSTOM_DIR" -name "*.pyc" -delete

echo "======================================================="
echo "✅ INSTALLATION COMPLETE!"
echo "======================================================="
echo "NEXT STEPS:"
echo "1. If you have a broken Tado integration, DELETE it now."
echo "2. Restart Home Assistant completely: 'ha core restart'"
echo "3. Add the Tado integration again via Settings."
echo "======================================================="`

Tado X Fix for Home Assistant (OAuth & Crash Loop)

This script installs a patched version of the Tado integration to support Tado X devices (Matter/Thread) in Home Assistant.

⚠️ The Problem

Users with Tado X devices often encounter:

  1. Authentication Loop: You log in, it says "Success", but immediately asks to reconfigure.
  2. Crash: Error logs showing KeyError: 'shortSerialNo', causing the setup to fail.

This happens because the current Home Assistant Core integration does not yet support the new "Device Flow" authentication required for Tado X, and Tado X devices do not report a shortSerialNo like older devices did.

✅ The Solution

This installer script performs the following actions:

  1. Downloads the tado-oauth-deviceflow branch (forked from @karlbeecken).
  2. Installs it as a custom_component.
  3. Forces version 9.9.9 in manifest.json to ensure Home Assistant loads this version over the built-in one.
  4. Patches coordinator.py to prevent crashes when a serial number is missing (returns 'unknown' instead of crashing).

🚀 How to Install

Prerequisites

  • You need access to the Home Assistant Terminal (e.g., via the "Advanced SSH & Web Terminal" add-on).

Installation Steps

  1. Open your Home Assistant Terminal.
  2. Run the following command to download and execute the installer:
wget -O tado_installer.sh [https://raw.githubusercontent.com/JOUW_GITHUB_NAAM/REPO_NAAM/main/install_tado_fix.sh](https://raw.githubusercontent.com/JOUW_GITHUB_NAAM/REPO_NAAM/main/install_tado_fix.sh)
chmod +x tado_installer.sh
./tado_installer.sh


>(Note: Replace the URL above with your actual GitHub Raw URL after uploading)

Restart Home Assistant (ha core restart).

Go to Settings > Devices & Services.

If an old/broken Tado integration exists: Delete it.

Click Add Integration > Tado.

Follow the login steps (you will be redirected to tado.com).

🧹 How to Remove (When official fix is released)
Once Home Assistant officially updates the Tado integration (likely in version 2025.x):

Delete the folder /config/custom_components/tado.

Restart Home Assistant.

Credits
Logic based on the work of @erwindouna & @karlbeecken.

Installer script & patch logic consolidated by Bart & "Bart's HA Partner".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions