Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .homeychangelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -394,5 +394,8 @@
},
"0.3.2": {
"en": "Added support for additional Tuya Zigbee devices and improved reliability for remotes, sensors, switches, dimmers, sirens, FingerBot and rain/presence sensors. Fixed TH05Z battery readings and clarified device compatibility information."
},
"0.4.1": {
"en": "Added pairing profiles for additional switches and sensors. Improved single-button and rotary remote controls, smart-plug power-on settings, and thermostat logging."
}
}
2 changes: 1 addition & 1 deletion .homeycompose/app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "com.tuya.zigbee",
"version": "0.4.0",
"version": "0.4.1",
"compatibility": ">=5.0.0",
"platforms": [
"local"
Expand Down
5 changes: 3 additions & 2 deletions MAINTAINING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ Homey's publish validation checks the generated manifest and publish assets. Sta
- `main`: actual Homey **Live 0.3.3**, published source `130854f`.
- `dev`: actual Homey **Test 0.3.4**, published source `21b60ce`.
- `develop-0.4`: frozen **0.4.0 next Test candidate**, not yet published.
- `develop-0.4.1`: all new post-freeze development; it still inherits 0.4.0
metadata until the first coordinated 0.4.1 version/changelog update.
- `develop-0.4.1`: **0.4.1 development**, starting with the isolated #1026
single-button correction. Version/lock/Compose/manifest/changelog are aligned.
See [the active 0.4.1 preflight](docs/0.4.1_RELEASE_PREFLIGHT.md).
- `refactor/type-based-drivers`: separate experimental architecture.

See [current branch policy, Store evidence and cleanup audit](docs/BRANCHES.md).
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"_comment": "This file is generated. Please edit .homeycompose/app.json instead.",
"id": "com.tuya.zigbee",
"version": "0.4.0",
"version": "0.4.1",
"compatibility": ">=5.0.0",
"platforms": [
"local"
Expand Down
2 changes: 1 addition & 1 deletion docs/0.4.1_BACKLOG.csv
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ issue,title,state_after_review,canonical_issue,family,planning_group,next_action
1043,Device Request - [PC remote switch] - [_TZE204_6fk3gewc] / [TS0601],open,,Remotes/buttons,Later intake / detailed review needed,"Review exact identity, endpoint/DP contract and current behavior before assigning implementation scope; no readiness conclusion from this inventory alone.",,,https://github.com/JohanBendz/com.tuya.zigbee/issues/1043
1041,TS0207 standard IAS water-leak family: verify battery profiles,open,,Other/intake,Implemented / Test verification,"Review exact identity, endpoint/DP contract and current behavior before assigning implementation scope; mentioned identity already occurs in code, which is not proof of acceptance.",flood_sensor;flood_sensor_2,flood_sensor;flood_sensor_2;flood_sensor_unverified_battery,https://github.com/JohanBendz/com.tuya.zigbee/issues/1041
1035,TS0004 four-output OnOff — two implemented 0.4 identities + two interview-pending requests,open,,Other/intake,Implemented / Test verification,"Review exact identity, endpoint/DP contract and current behavior before assigning implementation scope; mentioned identity already occurs in code, which is not proof of acceptance.",,switch_4_gang_ts0004,https://github.com/JohanBendz/com.tuya.zigbee/issues/1035
1026,Bug report - device _TZ3000_ja5osu5g does not work with smart_remote_1_button_2,open,,Remotes/buttons,0.4.1 first queue,Current parser turns captured single-click follow-up without action byte into longPress; add exact command/length guards and preserve ZCL dispatch without global debounce.,smart_remote_1_button_2,smart_remote_1_button_2,https://github.com/JohanBendz/com.tuya.zigbee/issues/1026
1026,Bug report - device _TZ3000_ja5osu5g does not work with smart_remote_1_button_2,open,,Remotes/buttons,Implemented / Test verification,"0.4.1 code complete with nine behavioral tests: known Tuya FD actions only, preserve ZCL dispatch; actual gesture/Flow acceptance pending. Battery enhancement is not included.",smart_remote_1_button_2,smart_remote_1_button_2,https://github.com/JohanBendz/com.tuya.zigbee/issues/1026
1021,Device Request - [EZ-GU10=C] - [eWeLink] / [CK-BL702-AL-01(7009_Z102LG03-1)],open,,Lighting/dimmers,Later scoped engineering,"Review exact identity, endpoint/DP contract and current behavior before assigning implementation scope; no readiness conclusion from this inventory alone.",,,https://github.com/JohanBendz/com.tuya.zigbee/issues/1021
1018,Device Request - [ZigBee Smart Siren] - [TS0601] / [_TZE204_t1blo2bj],open,,Alarms,Later intake / detailed review needed,"Review exact identity, endpoint/DP contract and current behavior before assigning implementation scope; mentioned identity already occurs in code, which is not proof of acceptance.",siren,siren,https://github.com/JohanBendz/com.tuya.zigbee/issues/1018
1016,Device Request - 2 Gang Zigbee Push button/Normal Switch Module - _TZ3000_m8f3z8ju / TS000F,open,,Remotes/buttons,Later intake / detailed review needed,"Review exact identity, endpoint/DP contract and current behavior before assigning implementation scope; no readiness conclusion from this inventory alone.",,,https://github.com/JohanBendz/com.tuya.zigbee/issues/1016
Expand Down
89 changes: 89 additions & 0 deletions docs/0.4.1_RELEASE_PREFLIGHT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# 0.4.1 development preflight

Started 2026-10-25 from `develop-0.4.1` planning commit
`26034ed9b3116c1ef7c05e66814a2644304651e2`.
This is the active development checklist, not a Store publication claim.
The current Store lanes remain main = 0.3.3 Live and dev = 0.3.4 Test.
Frozen 0.4.0 remains separately on develop-0.4. No work from this batch is
carried into those three branches.

## First implementation batch: #1026

Only `drivers/smart_remote_1_button_2/device.js` changes device behavior.
It retains the exact `_TZ3000_ja5osu5g / TS004F` matcher, Homey driver ID,
capability list, settings and `smart_remote_1_button_2` Flow actions.

- Accept only endpoint-1 cluster-6 cluster-specific Tuya action command 0xFD,
with a valid three-byte non-manufacturer ZCL header and one action byte.
- Map 0/1/2 to the existing oneClick/twoClicks/longPress values. Reject unknown
actions and malformed/truncated/unverified frame forms as gestures.
- Support native Buffer and serialized Buffer input without mutating it.
- Preserve the captured ZCL dispatcher, receiver, metadata, return value and
error behavior for all other traffic, including the standard OnOff command
that follows each captured gesture. Consume a recognized gesture only once.
- Reinitialization must not stack wrappers; device deletion restores the
original dispatcher only while this device's wrapper is still installed,
and still invokes the SDK's listener/interval cleanup.
- No timer debounce, alternate-frame counter, new capability, battery
implementation, manufacturer additions or shared-cluster changes.

The original #1026 captures are the concrete regression input. The new
`test/single-button-1026.test.js` exercises the actual driver with Homey/Zigbee
stubs: captured single/double/hold pairs for both Buffer representations,
invalid/unknown packets, ordinary ZCL traffic, rapid legitimate presses,
sequence wrap, hook lifecycle and failure propagation. The old source failed
eight of the nine tests; all nine pass after correction. This is automated
evidence only.

## Metadata and compatibility

Version **0.4.1** agrees across package.json, package-lock.json and its root
package, Homey Compose, generated app.json and the new Homey changelog entry.
Root app.json is generated by Homey CLI, not manually maintained. Dependencies
stay unchanged. The changelog remains user-facing and channel-neutral and
summarizes inherited changes since actual 0.3.3 Live as well as this correction.

No profile is added: 154 drivers, including the inherited nineteen new 0.4.0
profiles and their 33 separately tracked identities. The original
`docs/0.4.0_PHYSICAL_ACCEPTANCE.md` remains the inherited inventory. Its
historical release snapshot does not declare this 0.4.1 candidate published.
Subsequent new-device batches need their own 0.4.1 inventory extension and
candidate-specific checks; do not rewrite immutable 0.3.1 fixtures.

All 135 existing manifest/Flow/capability contracts and the 20 sensitive runtime
blobs remain under their existing compatibility checks and reviewed exceptions.
The single-button file is outside the protected light/shared-source set. No
exception is added to bypass a guard for this change.

## Required verification on the exact final SHA

1. Clean dependency install and Homey 4.5.0 Compose build.
2. Generated manifest and supported-device index reproducible/committed.
3. Full repository suite including the nine new #1026 behavioral cases and
immutable compatibility/protected-runtime checks.
4. Homey validation at publish level, generated manifest recheck, whitespace.
5. Exact source diff: only the single-button runtime, its behavioral tests,
coordinated version/changelog/preflight metadata and tracking docs change.
6. GitHub CI on the PR head and the eventual develop-0.4.1 head.

Record final SHA and actual CI results in the implementation PR and tracker
#1469 after validation. Green CI is not a physical result or publication.

## Physical acceptance through public Test

Keep #1026 OPEN. Once this version is actually available through Test, record
exact app version/commit, Homey model/firmware and manufacturer/model. Existing
pairings should not need replacement because no pairing/Flow contract changed.

- One single click produces exactly one oneClick and no false hold/double.
- One double click produces exactly one twoClicks.
- A physical hold produces one longPress as actually emitted by the unit.
- Standard follow-up frames do not trigger a second Flow.
- Repeated legitimate clicks still work without a new time lockout.
- Existing saved Flows still filter by the same action strings.
- Restart/rejoin and unrelated standard report handling remain normal.

The request's optional battery display remains unimplemented and must not be
described as delivered. Hardware feedback happens in Test, not as a prerequisite
to opening Test. Any newly demonstrated published-version regression receives
a separate patch decision; this batch does not publish or update main/dev.
27 changes: 15 additions & 12 deletions docs/0.4.1_ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ commitment, a claim of implemented support or permission to publish.
- Frozen next-Test 0.4.0 remains on `develop-0.4` at `03fee06`.
- This review starts from `develop-0.4.1` at exactly
`34f296216125812ef7f4a724635660ad70833592` (tree identical to frozen 0.4.0).
Its metadata is still inherited 0.4.0. Bump package, both lock roots, Compose,
generated manifest, changelog and candidate-specific checks together when
preparing the first actual 0.4.1 implementation batch.
The first implementation batch now aligns package, both lock roots, Compose,
generated manifest, changelog and candidate-specific checks at **0.4.1**.
#1026 is implemented with nine behavioral tests; physical gesture acceptance
remains pending. See [the active 0.4.1 preflight](0.4.1_RELEASE_PREFLIGHT.md).
- Fifteen already-merged temporary/source branches have been removed since the
migration. Ten branches remain: the four active branches above plus SDK3,
SDK3-test, master, sdk-3, refactor/type-based-drivers and the old-dev archive.
Expand Down Expand Up @@ -44,12 +45,12 @@ this inventory.

| Planning group | Inventory rows |
| --- | ---: |
| 0.4.1 first queue | 8 |
| 0.4.1 first queue | 7 |
| 0.4.1 follow-up candidates | 9 |
| Consolidated source | 4 |
| Coordination | 1 |
| Evidence or identity hold | 15 |
| Implemented / Test verification | 25 |
| Implemented / Test verification | 26 |
| Later intake / detailed review needed | 145 |
| Later scoped engineering | 73 |
| Scope clarification | 2 |
Expand All @@ -62,7 +63,7 @@ reviewed batches and let public Test supply real physical results.

| Order | Work / canonical tracking | Evidence and bounded first implementation |
| --- | --- | --- |
| 1 | Existing one-button remote [#1026](https://github.com/JohanBendz/com.tuya.zigbee/issues/1026) | Current parser treats any frame without action byte 0/1 as longPress. Replaying the historical captured single-click plus follow-up frames into the unchanged method produces oneClick AND longPress. Add narrow command/length validation and preserve normal ZCL dispatch. Do not use a global time debounce or change other remotes. |
| 1 (code complete, hardware pending) | Existing one-button remote [#1026](https://github.com/JohanBendz/com.tuya.zigbee/issues/1026) | Current parser treats any frame without action byte 0/1 as longPress. Replaying the historical captured single-click plus follow-up frames into the unchanged method produces oneClick AND longPress. Add narrow command/length validation and preserve normal ZCL dispatch. Do not use a global time debounce or change other remotes. |
| 2 | FingerBot repeated presses [#1438](https://github.com/JohanBendz/com.tuya.zigbee/issues/1438) | Current runtime still repeatedly sends setOn and drops requests inside its suppression window. Original exact j4pdtz9v hardware report shows alternating real On/Off and a queue worked in a private change. Reproduce against current code, then scope click-mode alternation/queue to the exact proven identity. Preserve other manufacturers and switch/program modes. Keep #869 settings acceptance separate. |
| 3 | Existing TY0201 pairing [#1015](https://github.com/JohanBendz/com.tuya.zigbee/issues/1015) | _TZ3000_bjawzodf / TY0201 already matches lcdtemphumidsensor. New 0.3.3 physical report: one repaired unit reports temperature/RH/battery, four equivalent units still fail to add. Investigate pairing/init timing, capture the failing phase and use current Homey/app versions. Do not append the already-present identity or claim a root cause yet. |
| 4 | Exact switches + device-wide EP1 settings [#991](https://github.com/JohanBendz/com.tuya.zigbee/issues/991), [#1366](https://github.com/JohanBendz/com.tuya.zigbee/issues/1366), [#795](https://github.com/JohanBendz/com.tuya.zigbee/issues/795) | New i9w5mehz TS0002 (#1526) and gbshwgag TS0001 (#1527) have full interviews and private-app physical power-cut evidence. v4l4b0lp TS0003 is ALREADY paired by the frozen 0.4 profile; only optional settings are new scope for that row. 0x8002 restore is device-wide through EP1, even where secondary endpoint writes misleadingly succeed; 0x5000 backlight and 0x8001 indicator are distinct. Reuse opt-in patterns, no startup writes or assumptions for unrelated variants. |
Expand Down Expand Up @@ -193,10 +194,12 @@ source as duplicate. Full interviews/photos and private-app measurements stay
in the originals. Updated #1474's current-status header and PR #1535's source
review; no device acceptance issue was closed as completed.

Recommended next implementation: start with the deterministic #1026 frame-guard
correction, then the bounded FingerBot #1438 reproduction/queue strategy. The
two proven switch identities are the next feature slice when their source
evidence has been reconciled with our exact driver contracts. Prepare the coordinated 0.4.1 version transition
and adapt only candidate-specific inventories. Existing device/Flow contracts,
source fixtures and protected runtime guards stay intact. Physical validation
The first implementation batch now covers the deterministic #1026 frame guard
and preservation of ZCL dispatch, with aligned 0.4.1 metadata. Actual single/
double/hold/Flow testing is still pending. Next implementation candidate is the
bounded FingerBot #1438 reproduction/queue strategy; the two proven switch
identities follow after reconciling their source evidence with our exact driver
contracts. Adapt only candidate-specific inventories for subsequent batches.
Existing device/Flow contracts, source fixtures and protected runtime guards
stay intact. Physical validation
of new code happens in public Test, not as an artificial entry gate.
2 changes: 1 addition & 1 deletion docs/BRANCHES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ and older GitHub comments remain historical evidence.
| `main` | Homey App Store Live | 0.3.3, source `130854f4c6d1b5a3537e956d941eb2e3caec9a9a` |
| `dev` | Homey App Store Test | 0.3.4, source `21b60ce07d91421aeba08357960c8fc910d87593` |
| `develop-0.4` | Frozen next Test candidate; not published | 0.4.0, pre-migration source `3e5695667cab9d6a3296d58909b90a8dc0376e93` |
| `develop-0.4.1` | New development after the 0.4.0 feature freeze | Pre-migration source `08d85dd59177826ff35436b9802f305f372e9bc7`; inherited 0.4.0 metadata until a coordinated 0.4.1 version bump |
| `develop-0.4.1` | New development after the 0.4.0 feature freeze | 0.4.1 development; first code batch #1026. [Active preflight](0.4.1_RELEASE_PREFLIGHT.md). Pre-migration source remains historical evidence at `08d85dd59177826ff35436b9802f305f372e9bc7` |

Observed directly on the official Store pages on 2026-10-25:
- Live: https://homey.app/en-us/app/com.tuya.zigbee/Tuya-Zigbee/ shows 0.3.3.
Expand Down
74 changes: 52 additions & 22 deletions drivers/smart_remote_1_button_2/device.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,68 @@
"use strict";
'use strict';

const { ZigBeeDevice } = require("homey-zigbeedriver");
const { debug, CLUSTER } = require('zigbee-clusters');
const { ZigBeeDevice } = require('homey-zigbeedriver');

const actions = ['oneClick', 'twoClicks', 'longPress'];

function getButtonAction(frame) {
const data = Buffer.isBuffer(frame)
? frame
: frame?.type === 'Buffer' && Array.isArray(frame.data) ? frame.data : null;

// #1026 captures contain a standard three-byte ZCL header and one action
// byte. The following OnOff command is a separate frame, not another gesture.
if (!data || data.length !== 4) return null;
for (let i = 0; i < data.length; i++) {
if (!Number.isInteger(data[i]) || data[i] < 0 || data[i] > 255) return null;
}
// Cluster-specific, no manufacturer header, Tuya action command 0xFD.
if ((data[0] & 0x07) !== 0x01 || data[2] !== 0xfd) return null;
return actions[data[3]] || null;
}

class smart_remote_1b_2 extends ZigBeeDevice {
async onNodeInit({ zclNode }) {
async onNodeInit() {
const node = await this.homey.zigbee.getNode(this);
node.handleFrame = (endpointId, clusterId, frame, meta) => {
if (clusterId === 6) {
this.log(
"endpointId:",
endpointId,
", clusterId:",
clusterId,
", frame:",
frame,
", meta:",
meta
);
this.buttonCommandParser(frame);
this._restoreFrameHandler();
const originalHandleFrame = node.handleFrame;

this._frameNode = node;
this._originalHandleFrame = originalHandleFrame;
this._frameHandler = (endpointId, clusterId, frame, meta) => {
if (endpointId === 1 && clusterId === 6) {
const handled = this.buttonCommandParser(frame);
if (handled !== null) return handled;
}
// Keep normal ZCL dispatch for reports, standard follow-ups and all
// unrelated traffic. Never replace the SDK's handler for those frames.
if (typeof originalHandleFrame === 'function') {
return originalHandleFrame.call(node, endpointId, clusterId, frame, meta);
}
};

node.handleFrame = this._frameHandler;
}

buttonCommandParser(frame) {
var action = frame.data[3] === 0 ? 'oneClick' : frame.data[3] === 1 ? 'twoClicks' : 'longPress';
return this.driver.buttonTrigger.trigger(this, {}, { action: `${action}` })
const action = getButtonAction(frame);
if (action === null) return null;
return this.driver.buttonTrigger.trigger(this, {}, { action })
.then(() => this.log(`Triggered 1 button Smart Remote, action=${action}`))
.catch((err) => this.error("Error triggering 1 button Smart Remote", err));
.catch(err => this.error('Error triggering 1 button Smart Remote', err));
}

_restoreFrameHandler() {
if (this._frameNode && this._frameNode.handleFrame === this._frameHandler) {
this._frameNode.handleFrame = this._originalHandleFrame;
}
this._frameNode = null;
this._originalHandleFrame = null;
this._frameHandler = null;
}

onDeleted() {
this.log("1 button Smart Remote Controller has been removed");
this._restoreFrameHandler();
this.log('1 button Smart Remote Controller has been removed');
return super.onDeleted();
}
}

Expand Down
Loading
Loading