-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add support for Nova Digital NFZB-2 #12658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
trzenaro
wants to merge
1
commit into
Koenkk:master
Choose a base branch
from
trzenaro:agent/add-nova-digital-nfzb-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+37
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import * as reporting from "../lib/reporting"; | ||
| import * as tuya from "../lib/tuya"; | ||
| import type {DefinitionWithExtend} from "../lib/types"; | ||
|
|
||
| export const definitions: DefinitionWithExtend[] = [ | ||
| { | ||
| fingerprint: tuya.fingerprint("TS0002", ["_TZ3210_5ksufhqi"]), | ||
| model: "NFZB-2", | ||
| vendor: "Nova Digital", | ||
| description: "2-Gang switch with backlight, countdown and inching", | ||
| extend: [ | ||
| tuya.modernExtend.tuyaBase(), | ||
| tuya.modernExtend.tuyaOnOff({ | ||
| powerOutageMemory: true, | ||
| backlightModeOffOn: true, | ||
| indicatorMode: true, | ||
| onOffCountdown: true, | ||
| inchingSwitch: true, | ||
| endpoints: ["l1", "l2"], | ||
| }), | ||
| tuya.clusters.addTuyaCommonPrivateCluster(), | ||
| ], | ||
| endpoint: () => { | ||
| return {l1: 1, l2: 2}; | ||
| }, | ||
| meta: {multiEndpoint: true}, | ||
| configure: async (device, coordinatorEndpoint) => { | ||
| await tuya.configureMagicPacket(device, coordinatorEndpoint); | ||
| await reporting.bind(device.getEndpoint(1), coordinatorEndpoint, ["genOnOff"]); | ||
| await reporting.bind(device.getEndpoint(2), coordinatorEndpoint, ["genOnOff"]); | ||
| await reporting.onOff(device.getEndpoint(1)); | ||
| await reporting.onOff(device.getEndpoint(2)); | ||
| }, | ||
| }, | ||
| ]; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this to the already existing
TS0002definition intuya.tsUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @Koenkk . I initially created a separate definition because this device behaves differently from the other devices handled by the generic
TS0002definition:onOffreporting for both endpoints.switchTypeandpowerOnBehavior2returnUNSUPPORTED_ATTRIBUTE.powerOutageMemoryimplementation instead.I considered adding the following mutually exclusive conditions to the existing
tuyaOnOffextend:However,
tuyaOnOffcurrently handles these options through anif / else ifbranch. Since the predicate function itself is truthy, thepowerOutageMemorybranch is always selected while building the definition, and thepowerOnBehavior2converters are not registered for the existing models.This is why I originally used a separate definition: to avoid adding several manufacturer-specific conditions to the generic definition and, more importantly, to avoid changing the behavior of existing TS0002 devices.
I have prepared the following integrated implementation for the existing
TS0002definition. It conditionally disables the unsupported options, exposespower_outage_memoryonly for_TZ3210_5ksufhqi, restricts the legacy converter to thepower_outage_memorykey, and configures on/off reporting only for this manufacturer:What approach would you prefer here: keeping the dedicated definition, or integrating these exceptions into the existing
TS0002definition? Could you also please check whether the integrated implementation above is correct? I am not very familiar with adding model-specific behavior to shared definitions without affecting the existing models.