Skip to content

About

local handling for Tuya devices

Resources

Security policy

Stars

17 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

LocalTuya 2.0

LocalTuya 2.0 — The Next Generation of Local Tuya Control
Maintained by BildaSystem.cz

HACS Custom Release Stars License

Why? • Features • Install • Roadmap • Docs

🇬🇧 English | 🇨🇿 Čeština


🤔 Why LocalTuya 2.0?

The original LocalTuya was a game-changer for Tuya device owners. But development stalled, bugs piled up, and Home Assistant kept evolving. We stepped in to keep LocalTuya alive.

The Problem

Pain Point What Happened
🐛 HA 2024/2025 breaking changes Crashes, deprecation warnings, broken config flows
🔧 Protocol 3.5 devices Not supported, newer devices didn't work
😤 Changing device IP/key Click through ALL entities one by one
📦 No device templates Configure 15 DPs manually for every bulb
🔐 Complex cloud setup Need developer account, API keys, etc.

Our Solution

LocalTuya 2.0 fixes all of this and more. We're committed to keeping local Tuya control alive and thriving.

💡 Philosophy: Your smart home should work locally, without cloud dependencies. That's why LocalTuya exists, and that's why we maintain it.


✨ Features

🔐 QR Code Authentication (v7.4+)

No Tuya developer account needed! Just scan a QR code:

  • Open Smart Life app → Me → Settings → User Code
  • Enter the code in LocalTuya 2.0
  • Scan QR with app → Done!
  • All your devices and local_keys are fetched automatically

🆕 Protocol 3.5 Support (v7.0+)

Full support for the latest Tuya protocol:

  • GCM encryption for secure communication
  • 6699 packet prefix handling
  • Proper heartbeat with retry logic
  • Works with newest Tuya devices

🏷️ Entity Naming Prefix (v7.8+)

Keep your entities organized in large installations:

  • Set a prefix per device (e.g., "Living Room", "Bedroom #1")
  • All entities get prefixed automatically
  • Example: Living Room Temperature instead of just Temperature
  • Perfect for multiple devices of the same type

📊 Advanced Sensor Features (v7.6+)

  • Scaling factor - multiply raw values (e.g., 0.1 for temperature)
  • Device class - proper icons and units in HA
  • Enum support (v7.8+) - translate raw values to friendly names
    • Raw: 0, 1, 2 → Display: Off, Heating, Cooling

📚 Device Library (v7.0+)

Pre-configured templates for common devices:

  • Auto-detection by product_id
  • One-click setup - no manual DP configuration
  • Community templates - growing library

Currently supported:

  • 🌡️ Inkbird ITC-308-WIFI - Temperature controller (heating/cooling)
  • 💡 Smart Mini Bulb RGB+CCT (Protocol 3.5)
  • ⭐ Smart Star Projector
  • 🌬️ Tesla Air Purifier Mini
  • 💧 Tesla Dehumidifier XL
  • 🔌 Tesla Power Strip PS300
  • 🌬️ BlitzWolf Air Cleaner
  • 🐾 Nedis Pet Feeder - Auto feeder with portions
  • 🐾 Pet Feeder DU3L - Advanced pet feeder
  • ⚡ KWS-302WF Energy Meter
  • 🔌 Circuit Breaker 63A
  • 🪟 Roleta M313EIRWT
  • ...and more coming!

💡 Have a device? Open an issue with your device info and we'll add a template!

🚀 Quick Edit

Change host, local_key, or protocol without reconfiguring entities:

Settings → Devices → LocalTuya 2.0 → Configure
→ Select device → Quick edit
→ Done in 10 seconds!

☁️ Cloud Key Sync

Fetch all local_keys with one click:

  • No manual copy-paste from Tuya IoT
  • Shows which keys changed
  • Smart sync - only updates modified keys

🔄 Parallel Installation

Run alongside original LocalTuya:

  • Different domain (localtuya_bildass)
  • Test before migrating
  • Zero conflicts

🌍 All Tuya Regions (v7.3.19+)

  • EU - Central Europe
  • EU West - Western Europe
  • US - Western America
  • US East - Eastern America
  • CN - China
  • IN - India
  • SG - Singapore (new!)

📦 Installation

HACS (Recommended)

  1. Open HACS → Integrations
  2. Click ⋮ → Custom repositories
  3. Add: https://github.com/Bildass/localtuya
  4. Category: Integration
  5. Find LocalTuya 2.0 → Download
  6. Restart Home Assistant

Manual

cd /config/custom_components
git clone https://github.com/Bildass/localtuya.git temp
mv temp/custom_components/localtuya_bildass .
rm -rf temp
# Restart Home Assistant

🗺️ Roadmap

We're actively developing LocalTuya 2.0. Here's what's coming:

🔜 Coming Soon

Feature Status Description
Water Heater Platform 📋 Planned Support for smart kettles, water heaters
More Device Templates 🔄 Ongoing Community-contributed device configs
Entity Customization 💭 Idea More options for entity appearance

✅ Recently Shipped

Version Feature
v7.8.0 🏷️ Entity naming prefix + 📊 Sensor enum support
v7.7.0 🌡️ Inkbird ITC-308-WIFI template
v7.6.0 Number entity scaling, device class, units
v7.5.0 Config flow refactoring (modular architecture)
v7.4.0 🔐 QR Code Authentication - no developer account needed!
v7.3.20 Fixed template name display in options flow
v7.0.0 Complete pytuya rewrite + Protocol 3.5

💡 Future Ideas

  • Matter bridge - expose LocalTuya devices to Matter
  • Device diagnostics - built-in network analyzer
  • Firmware version detection - track device updates
  • Scenes support - Tuya scene activation

📣 Have a feature request? Open an issue or start a discussion!


📖 Documentation

Quick Start

  1. Install via HACS (see above)
  2. Add Integration: Settings → Devices & Services → Add → LocalTuya 2.0
  3. Configure Cloud API (optional but recommended):
  4. Add Devices: Cloud Sync auto-fills device info!

Supported Platforms

Platform Examples
switch Smart plugs, relays, power strips
light Bulbs, LED strips, dimmers
cover Blinds, curtains, garage doors
fan Ceiling fans, air purifiers
climate Thermostats, AC controllers
vacuum Robot vacuums
sensor Temperature, humidity, power monitoring
binary_sensor Motion, door/window, leak
number Brightness, speed setpoints
select Modes, presets

Supported Protocols

Protocol Encryption Status
3.1 AES-ECB ✅ Supported
3.2 AES-ECB ✅ Supported
3.3 AES-ECB ✅ Supported
3.4 AES-GCM ✅ Supported
3.5 AES-GCM ✅ Full Support

Debugging

# configuration.yaml
logger:
  default: warning
  logs:
    custom_components.localtuya_bildass: debug
    custom_components.localtuya_bildass.pytuya: debug

🔄 Migration from Original LocalTuya

Good news: You can run both versions simultaneously!

Quick Steps

  1. Install LocalTuya 2.0 via HACS
  2. Export existing config (local_keys are precious!)
  3. Add devices to LocalTuya 2.0
  4. Test everything
  5. Remove original when satisfied

Entity Name Changes

Original LocalTuya 2.0
switch.localtuya_xxx switch.localtuya_bildass_xxx
light.localtuya_xxx light.localtuya_bildass_xxx

Update references in: Automations, Scripts, Dashboards, Templates

📚 Full migration guide: See Migration Guide section below.


📋 Changelog

v7.8.x - Advanced Features

  • v7.8.0 - Sensor enum device_class support, Entity naming prefix

v7.7.x - Device Templates

  • v7.7.0 - Inkbird ITC-308-WIFI temperature controller template

v7.6.x - Number Entity Improvements

  • v7.6.0 - Number entity scaling, device class, unit of measurement support

v7.5.x - Architecture

  • v7.5.0 - Config flow refactoring - split into 6 modular files (mixins)

v7.4.x - QR Authentication

  • v7.4.0 - 🔐 QR Code Authentication - no developer account needed!

v7.3.x - Stability & UX

  • v7.3.20 - Fix template name display in options flow
  • v7.3.19 - Add all Tuya regions (SG, EU West, US East) with friendly names
  • v7.3.18 - Heartbeat optimization, optimistic UI updates
  • v7.3.17 - Remove rate limiting (caused delays)
  • v7.3.16 - Smart Mini Bulb template, product_id detection fix

v7.0.x - Protocol 3.5 Revolution

  • v7.0.0 - Complete pytuya rewrite, Protocol 3.5 support, Device Library

v6.x - Config Flow Overhaul

  • v6.0.0 - Quick Edit, Entity List, Cloud Sync, Async API
📜 Older versions...

v5.x

  • v5.5.0 - Removed broken QR auth, simplified flow
  • v5.4.0 - Parallel installation, domain change
  • v5.3.1 - HA 2025.x compatibility

🆚 Comparison

Feature Original LocalTuya LocalTuya 2.0
Protocol 3.5 ❌ ✅
QR Code Auth ❌ ✅ No dev account!
Device templates ❌ ✅
Quick Edit ❌ ✅
Cloud Key Sync ❌ ✅
Entity prefix ❌ ✅
Sensor enum ❌ ✅
HA 2024/2025 ⚠️ Issues ✅
Parallel install ❌ ✅
Active development ❌ Stalled ✅ Active

🤝 Contributing

We welcome contributions!

Ways to Help

  • 🐛 Report bugs - Open an issue
  • 💡 Request features - Start a discussion
  • 📚 Add device templates - Share your working configs
  • 🌍 Translations - Help localize the integration
  • 🔧 Code - PRs welcome!

Development

git clone https://github.com/Bildass/localtuya.git
cd localtuya
# Create feature branch
git checkout -b feature/amazing-feature
# Make changes, commit, push
git push origin feature/amazing-feature
# Open PR

📞 Support & Contact


🙏 Credits

Built upon the excellent work of:

Community Contributors:

  • @galentx - Inkbird ITC-308-WIFI template, enum support & entity prefix ideas
  • Everyone who reports bugs, suggests features, and shares device configs!

LocalTuya 2.0
Keeping local Tuya control alive.

© 2024-2025 BildaSystem.cz
Fork of rospogrigio/localtuya • Licensed under GPL-3.0


📚 Full Migration Guide

From Original LocalTuya

Good news: You can run both versions simultaneously! And you don't need to re-fetch local_keys - they're already in your config!

Quick Overview

  1. Install LocalTuya 2.0 via HACS (don't remove original yet)
  2. Export your existing device data (see below)
  3. Add the integration: Settings → Devices & Services → Add → LocalTuya 2.0
  4. Re-add devices using your exported data (no Cloud API needed!)
  5. Test everything works
  6. Remove original LocalTuya when satisfied

📋 Step 1: Export Your Existing Configuration

Your existing device configurations (including precious local_key values) are stored in Home Assistant's config storage.

Option A: Python Script (Recommended for 10+ devices)

Create export_localtuya.py in /config:

#!/usr/bin/env python3
"""Export LocalTuya device configurations for migration to LocalTuya 2.0"""

import json
from pathlib import Path

config_path = Path('/config/.storage/core.config_entries')
with open(config_path, 'r') as f:
    data = json.load(f)

devices = []
for entry in data['data']['entries']:
    if entry.get('domain', '').lower() == 'localtuya':
        device_data = entry.get('data', {})
        devices.append({
            'name': entry.get('title', 'Unknown'),
            'device_id': device_data.get('device_id'),
            'local_key': device_data.get('local_key'),
            'host': device_data.get('host'),
            'protocol_version': device_data.get('protocol_version', '3.3'),
            'entities': device_data.get('entities', [])
        })

output_path = Path('/config/localtuya_export.json')
with open(output_path, 'w') as f:
    json.dump(devices, f, indent=2)

print(f"✅ Exported {len(devices)} devices to {output_path}")

Run via SSH: python3 /config/export_localtuya.py

Option B: Manual (Few devices)

  1. Open /config/.storage/core.config_entries
  2. Search for "domain": "localtuya"
  3. Copy relevant entries

📝 Step 2: Add Devices to LocalTuya 2.0

For each device:

  1. Settings → Devices & Services → LocalTuya 2.0 → Configure
  2. Add new device
  3. Enter details from export: Device ID, Host, Local Key, Protocol
  4. Configure entities using DP numbers from export
  5. Repeat

⏱️ ~2-3 minutes per device with prepared data


⚠️ Entity Name Changes

Your entity IDs will change:

Original LocalTuya 2.0
switch.localtuya_xxx switch.localtuya_bildass_xxx
light.localtuya_xxx light.localtuya_bildass_xxx

Update in: Automations, Scripts, Dashboards, Templates, Groups


💡 Tips

  • Set static IPs for Tuya devices in router
  • Keep export file as backup
  • Migrate in batches if many devices
  • Test each batch before continuing

⚡ Energy Monitoring Setup

For devices with power measurement (smart plugs, power strips):

# configuration.yaml
sensor:
  - platform: template
    sensors:
      smart_plug_voltage:
        friendly_name: "Smart Plug Voltage"
        value_template: "{{ state_attr('switch.localtuya_bildass_plug', 'voltage') }}"
        unit_of_measurement: 'V'
        device_class: voltage

      smart_plug_current:
        friendly_name: "Smart Plug Current"
        value_template: "{{ state_attr('switch.localtuya_bildass_plug', 'current') }}"
        unit_of_measurement: 'mA'
        device_class: current

      smart_plug_power:
        friendly_name: "Smart Plug Power"
        value_template: "{{ state_attr('switch.localtuya_bildass_plug', 'current_consumption') }}"
        unit_of_measurement: 'W'
        device_class: power

About

local handling for Tuya devices

Resources

Security policy

Stars

17 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages