Skip to content

Tuya - Air Condioner support - PR9#2458

Open
Terdious wants to merge 96 commits intoGladysAssistant:masterfrom
Terdious:tuya-air-conditioner-support
Open

Tuya - Air Condioner support - PR9#2458
Terdious wants to merge 96 commits intoGladysAssistant:masterfrom
Terdious:tuya-air-conditioner-support

Conversation

@Terdious
Copy link
Copy Markdown
Contributor

@Terdious Terdious commented Feb 23, 2026

Pull Request check-list

To ensure your Pull Request can be accepted as fast as possible, make sure to review and check all of these items:

  • If your changes affect the code, did you write the tests?
  • Are tests passing? (npm test on both front/server)
  • Is the linter passing? (npm run eslint on both front/server)
  • Did you run prettier? (npm run prettier on both front/server)
  • If you are adding a new feature/service, did you run the integration comparator? (npm run compare-translations on front)
  • Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community (forum) for testing before merging.
  • If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
  • If you are adding a new features/services which needs explanation, did you modify the user documentation? See the GitHub repo and the website.
  • Did you add fake requests data for the demo mode (front/src/config/demo.js) so that the demo website is working without a backend? (if needed) See https://demo.gladysassistant.com.

NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.

Description of change

Summary

  • Add support for Tuya air-conditioner devices reported in issue #2479.
  • Support both local and cloud read/write flows for AC capabilities:
    • switch
    • temp_set
    • temp_current
    • mode
    • fan_speed_enum
    • horizontal
    • vertical
  • Add dedicated AC fixture coverage and align cloud strategy/mapping tests.

Details

  • Front (prod):
    • add dedicated device feature components for AC fan speed and AC swing controls
    • integrate AC features into the room device feature rendering flow
    • update AC mode component behavior to align with the new mapping support
  • Translations:
    • add/adjust AC labels in English, French, and German
  • Server (prod):
    • add a dedicated air-conditioner Tuya device type
    • add explicit cloud mapping for AC capabilities
    • add explicit local mapping for AC DPS capabilities
    • register AC device type in Tuya mapping index
    • extend Tuya device read/write mappings for AC features
    • extend constants for AC-related supported feature values
    • simplify tuya.cloudStrategy by removing unreachable/dead branches while preserving behavior
  • Server tests:
    • add a full fixture set for air-conditioner-f3goccgfj6qino4c
    • add/extend fixture-driven tests for convert/local mapping/poll/setValue
    • add missing AC write mapping regression (AIR_CONDITIONING.BINARY)
    • add cloud strategy regression coverage for shadow-only supported codes

Why this matters

  • AC devices expose a broader and different capability model than previously supported Tuya devices.
  • Explicit cloud/local mappings keep behavior predictable and easier to maintain across device families.
  • Fixture-driven coverage ensures onboarding remains stable for future Tuya device additions.

Scope

Compared to tuya-pilot-thermostat-support:

  • Front (prod)

    • +147 lines / -45 lines
  • Translations

    • +93 lines / -6 lines
  • Server (prod)

    • +311 lines / -11 lines
  • Server Tests

    • +778 lines / -0 lines
  • No package changes.

  • Total

    • 27 files changed
    • +1329 lines / -62 lines

Summary by CodeRabbit

  • New Features

    • More air‑conditioning controls: fan‑speed, eco, drying, cleaning, aux‑heat, light, sleep, health.
    • Local network discovery and polling for Tuya devices.
    • GitHub issue workflow to suggest unsupported/partially supported devices.
  • Improvements

    • Richer Tuya device UI: cloud/local mode, IP/protocol controls, device ranking and partial‑support indicators, better connection states.
    • Automatic temperature‑unit detection and conversion.
    • Expanded translations (EN/DE/FR) and messaging.

Terdious and others added 28 commits February 11, 2026 15:58
…er models

- Added support for air conditioning devices with new mappings and DPS configurations.
- Introduced local polling for Tuya devices to improve responsiveness.
- Enhanced device conversion logic to include additional parameters such as cloud IP and local override.
- Updated feature conversion to utilize advanced DPS mappings for air conditioning.
- Implemented new models for air conditioning and power meter, including specific feature mappings.
- Improved error handling and logging for local polling and device value setting.
- Added unit tests for new feature mappings and conversion logic.
… champ d'erreur dans le payload de l'événement WebSocket
…s et ajouter des tests pour la gestion des appareils locaux
…eurs de port et mise à jour des traductions
…re des liens vers la documentation et les options de connexion
…réation de rapports GitHub pour les appareils Tuya
…l disconnect features

- Added new translations for connection status messages in German, English, and French.
- Implemented API endpoints to get Tuya connection status and to manually disconnect from the Tuya cloud.
- Updated the Tuya service to handle automatic reconnection logic and manual disconnect state.
- Enhanced the SetupTab component to reflect connection status and provide a disconnect button.
- Added tests for the new functionality, including status retrieval and manual disconnect.
- Implemented device ranking and sorting in DiscoverTab for better user experience.
- Added loading indicators and improved UI feedback during device scanning.
- Refactored local polling logic to update discovered devices with local information.
- Introduced utility functions for managing device parameters, including upserting and normalizing values.
- Enhanced local scan response handling to merge existing device parameters.
- Updated tests to cover new functionality and ensure reliability of device management.
…age, ajouter des tests pour la reconnexion automatique et la découverte des appareils
… des paramètres dans le code de configuration Tuya
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 23, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds comprehensive Tuya integration: local UDP scanning and local device polling, expanded air-conditioning feature mappings and UI components (fan speed, modes), auto-reconnect and manual-disconnect logic, new Tuya service endpoints and manager methods, richer device conversion/mapping, and extensive tests and i18n updates.

Changes

Cohort / File(s) Summary
Front — AC feature UI
front/src/components/boxs/device-in-room/DeviceRow.jsx, front/src/components/boxs/device-in-room/SupportedFeatureTypes.jsx, front/src/components/boxs/device-in-room/device-features/AirConditioningFanSpeedDeviceFeature.jsx, front/src/components/boxs/device-in-room/device-features/AirConditioningModeDeviceFeature.jsx, front/src/components/boxs/device-in-room/device-features/style.css, front/src/utils/consts.js
Adds fan-speed component, refactors AC mode UI, expands supported AIR_CONDITIONING feature types (FAN_SPEED, ECO, DRYING, CLEANING, AUX_HEAT, LIGHT, SLEEP, HEALTH), and updates icons/styles.
Front — Tuya UI & discovery
front/src/routes/integration/all/tuya/TuyaDeviceBox.jsx, front/src/routes/integration/all/tuya/discover-page/DiscoverTab.jsx, front/src/routes/integration/all/tuya/discover-page/style.css, front/src/routes/integration/all/tuya/setup-page/SetupTab.jsx, front/src/routes/integration/all/tuya/style.css
Reworks Tuya device editor and setup flows: IP masking, local/cloud toggle, protocol selection, local poll and local-scan UI, websocket-driven status, GitHub-issue flows, device ranking/sorting, and related UX changes.
Front — i18n
front/src/config/i18n/de.json, front/src/config/i18n/en.json, front/src/config/i18n/fr.json
Adds extensive Tuya translations for device metadata, local/cloud polling UI, GitHub issue helpers, and new AC feature labels (fan-speed, eco, drying, cleaning, aux-heat, light, sleep, health).
Server — API & controller
server/services/tuya/api/tuya.controller.js
Adds controller endpoints: POST /local-poll, POST /local-scan, GET /status, POST /disconnect wired to Tuya manager methods.
Server — Tuya core & lifecycle
server/services/tuya/index.js, server/services/tuya/lib/index.js, server/services/tuya/lib/tuya.init.js, server/services/tuya/lib/tuya.connect.js, server/services/tuya/lib/tuya.disconnect.js, server/services/tuya/lib/tuya.getStatus.js, server/services/tuya/lib/tuya.saveConfiguration.js
Implements auto-reconnect (quick-reconnect scheduling), manual disconnect, config-hash checks, exposes localScan/localPoll/getStatus/manualDisconnect, updates status/error emission and connection error mapping.
Server — Local scan & poll
server/services/tuya/lib/tuya.localScan.js, server/services/tuya/lib/tuya.localPoll.js, server/services/tuya/lib/tuya.localMapping.js, server/services/tuya/lib/tuya.poll.js, server/services/tuya/lib/tuya.setValue.js
Adds UDP local discovery, protocol-aware local DPS polling (tuyapi / tuyapi-newgen), DPS parsing, local write path with cloud fallback, and integration into polling/state emission.
Server — Mappings & conversion
server/services/tuya/lib/mappings/index.js, server/services/tuya/lib/mappings/cloud/*.js, server/services/tuya/lib/mappings/local/*.js, server/services/tuya/lib/device/tuya.deviceMapping.js, server/services/tuya/lib/device/tuya.convertDevice.js, server/services/tuya/lib/device/tuya.convertFeature.js, server/services/tuya/lib/device/tuya.loadDeviceDetails.js, server/services/tuya/lib/device/tuya.loadDevices.js
Introduces device-type-aware cloud/local mappings (air-conditioner, smart-socket), bidirectional mode/fan mappings, scaling/unit conversions, richer convertDevice output (params, properties, thing_model), parallel detail loading, and pagination changes.
Server — Utilities & constants
server/services/tuya/lib/utils/*.js, server/utils/constants.js
Adds DEVICE_PARAM_NAME constants, config-hash builder, normalize helpers, device-params utilities, new AC_FAN_SPEED enum and extended DEVICE_FEATURE_TYPES, and new GLADYS_VARIABLES entries.
Server — Tests & fixtures
server/test/services/tuya/**, server/test/lib/device/temperature-sensor/temperature-sensor.test.js, server/test/services/tuya/example/air-conditioner.json, server/test/services/tuya/tuya.mock.test.js
Large expansion of tests covering local scan/poll, convert/load/mapping logic, auto-reconnect, manual disconnect, controller endpoints, device-param utilities, and a new air-conditioner fixture; adds temperature-range tests.
Packages
server/services/tuya/package.json, server/package.json
Adds tuyapi and @demirdeniz/tuyapi-newgen dependencies for local protocol support; bumps duckdb from ^1.4.3 to ^1.4.4.
Device temperature validation
server/lib/device/temperature-sensor/temperature-sensor.getTemperatureInRoom.js
Filters out-of-range temperature readings (Celsius and Fahrenheit) from averaging to exclude implausible values.

Sequence Diagram(s)

sequenceDiagram
  participant UI as Client UI
  participant API as Gladys API
  participant Manager as TuyaHandler
  participant Device as Local Tuya Device
  participant GitHub as GitHub

  UI->>API: POST /api/v1/service/tuya/local-scan
  API->>Manager: localScan()
  Manager->>Device: open UDP sockets, listen
  Device-->>Manager: UDP broadcast (device info)
  Manager->>Manager: buildLocalScanResponse (merge with discoveredDevices)
  Manager-->>API: scan response
  API-->>UI: scan response

  UI->>API: POST /api/v1/service/tuya/local-poll {deviceId}
  API->>Manager: localPoll(payload)
  Manager->>Device: connect (tuyapi / newgen) and request DPS
  Device-->>Manager: DPS payload
  Manager->>Manager: updateDiscoveredDeviceAfterLocalPoll()
  Manager-->>API: poll result
  API-->>UI: poll result

  UI->>API: Create GitHub issue (partial support)
  API->>Manager: build/create issue payload
  Manager->>GitHub: query/create issue
  GitHub-->>Manager: issue result
  Manager-->>API: issue status
  API-->>UI: issue status
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~70 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • Pierre-Gilles

Poem

"🐰 Hoppity, I sniff the air tonight,
Local scans hum, fan-speeds take flight,
Modes and DPS all neatly unfurled,
Auto-reconnect keeps devices in the world,
A tiny rabbit cheers — Tuya made bright!"

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

@relativeci
Copy link
Copy Markdown

relativeci bot commented Feb 23, 2026

#3981 Bundle Size — 11.53MiB (+1.18%).

a3ae938(current) vs 8db6b0d master#3902(baseline)

Warning

Bundle contains 2 duplicate packages – View duplicate packages

Bundle metrics  Change 5 changes Regression 2 regressions
                 Current
#3981
     Baseline
#3902
Regression  Initial JS 6.51MiB(+2.03%) 6.38MiB
Regression  Initial CSS 310.24KiB(+0.02%) 310.18KiB
Change  Cache Invalidation 67.47% 0%
No change  Chunks 51 51
No change  Assets 179 179
Change  Modules 1648(+0.3%) 1643
No change  Duplicate Modules 21 21
Change  Duplicate Code 0.93%(-1.06%) 0.94%
No change  Packages 136 136
No change  Duplicate Packages 2 2
Bundle size by type  Change 2 changes Regression 2 regressions
                 Current
#3981
     Baseline
#3902
Regression  JS 8.42MiB (+1.62%) 8.28MiB
No change  IMG 2.66MiB 2.66MiB
Regression  CSS 328.09KiB (+0.02%) 328.03KiB
No change  Fonts 93.55KiB 93.55KiB
No change  Other 18.82KiB 18.82KiB
No change  HTML 13.58KiB 13.58KiB

Bundle analysis reportBranch Terdious:tuya-air-conditioner-su...Project dashboard


Generated by RelativeCIDocumentationReport issue

Terdious added 27 commits March 1, 2026 13:51
@Terdious Terdious force-pushed the tuya-air-conditioner-support branch from ed38a86 to a66f773 Compare March 5, 2026 07:12
@Terdious Terdious changed the title Tuya Air Condioner support Tuya - Air Condioner support - PR9 Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant