-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add support for TuYa Smart Switch with backlight ( 2, 3, 4, 6 gang configurations) #5935
Conversation
Added Terncy CL001 support
Fixed linting issues
added support for tuya G3 smart 4 gang switch with 2 scene controller
Changed model name
fix typo
Adds support for tuya 4gang + 2 scene switch with backlight. Power on behavior is still WIP. master_switch requires Koenkk/zigbee2mqtt#18157 to work
fixed linting errors
src/devices/tuya.ts
Outdated
tuya.exposes.countdown().withEndpoint('l4'), | ||
tuya.exposes.countdown().withEndpoint('l5'), | ||
tuya.exposes.countdown().withEndpoint('l6'), | ||
tuya.exposes.switch().withEndpoint('master_switch'), |
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.
What happens if you remove tuya.exposes.switch().withEndpoint('master_switch'),
here and change [13, 'state_master', tuya.valueConverter.onOff],
to [13, 'state', tuya.valueConverter.onOff],
, does this work?
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.
Removing tuya.exposes.switch().withEndpoint('master_switch'),
no longer exposes the master switch in the frontend.
However, publishing {"state": "ON"} and {"state": "OFF"} does the trick.
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.
Sorry, I meant changing tuya.exposes.switch().withEndpoint('master_switch')
to tuya.exposes.switch()
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.
Changing to tuya.exposes.switch()
works as properly.
But I can't seem to add an discription with tuya.exposes.switch().withDescription('All Switches'),
Moved _TZE200_wunufsil to an individual device with switch countdown timer, power on behavior, backlight control, and master switch functions.
Changed model name to reflect 2 gang control
_TZE200_0j5jma9b : fixed description fixed master switch _TZE200_wunufsil: removed extra endpoints
Added TS0601_3gang switch with backlight
Fixed duplicate _TZE200_vhy3iakz (new code supports countdown, backlight mode, and main switch) and changed some formatting
fix duplicates and format
Changed _TZE200_k6jhsr0q to support additional features
I've updated the code to support 1,2,3,4,6 gang smart switches with backlight (have tested it with my switches). |
src/devices/tuya.ts
Outdated
{ | ||
zigbeeModel: ['TS0601_4_gang'], | ||
fingerprint: [{modelID: 'TS0601', manufacturerName: '_TZE200_k6jhsr0q'}], | ||
model: 'Tuya 4 Gang Smart Switch with Backlight', |
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.
For all added definitions, can you add the actual model number here? (which is listed on the product site/device itself)
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.
I see you made some updates, please remove zigbeeModel: ['ZS-TYG3-SM-41Z'],
and use it as model
(e.g. model: 'ZS-TYG3-SM-41Z',
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.
Updated
Note to self; after this merge Koenkk/zigbee2mqtt.io#2114 |
Update device names per request
Updated model names
src/devices/tuya.ts
Outdated
[9, 'countdown_l3', tuya.valueConverter.countdown], | ||
[10, 'countdown_l4', tuya.valueConverter.countdown], | ||
[13, 'state', tuya.valueConverter.onOff], | ||
[14, 'power_on_behavior', tuya.valueConverterBasic.lookup({'off': tuya.enum(0), 'on': tuya.enum(1), 'memory': tuya.enum(2)})], |
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.
One more thing;
Can you try: [14, 'power_on_behavior', tuya.valueConverter.powerOnBehavior],
here and instead of e.power_on_behavior(['off', 'on', 'memory']).withAccess(ea.STATE_SET),
use e.power_on_behavior()
and see if that works?
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.
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.
Get is not supported for datapoints, use tuya.exposes.backlightModeOffOn().setAccess(ea.STATE_SET)
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.
Get is not supported for datapoints, use
tuya.exposes.backlightModeOffOn().setAccess(ea.STATE_SET)
Following error is thrown when I try to use tuya.exposes.backlightModeOffOn().setAccess(ea.STATE_SET)
node:assert:399
throw err;
^
AssertionError [ERR_ASSERTION]: Does not have any features
at Binary.setAccess (E:\zigbee2mqtt\zigbee2mqtt\node_modules\zigbee-herdsman-converters\src\lib\exposes.ts:62:15)
at E:\zigbee2mqtt\zigbee2mqtt\data\extension\externally-loaded.js:27:43
at Script.runInContext (node:vm:141:12)
at Script.runInNewContext (node:vm:146:17)
at Object.runInNewContext (node:vm:300:38)
at loadModuleFromText (E:\zigbee2mqtt\zigbee2mqtt\lib\util\utils.ts:151:8)
at loadModuleFromFile (E:\zigbee2mqtt\zigbee2mqtt\lib\util\utils.ts:158:12)
at Object.getExternalConvertersDefinitions (E:\zigbee2mqtt\zigbee2mqtt\lib\util\utils.ts:168:25)
at getExternalConvertersDefinitions.next (<anonymous>)
at new ExternalConverters (E:\zigbee2mqtt\zigbee2mqtt\lib\extension\externalConverters.ts:12:20)
I belive this is caused by Binary class constructor does not have features initialized, however I don't know how to use my local copy of zigbee-herdsman-converters to test out this theory.
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.
Whoops, it should be tuya.exposes.backlightModeOffOn().withAccess(ea.STATE_SET)
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.
I can confirm it works.
There is one issue with my implementation, the refresh for backlight_mode throws out the following error:
error 2023-07-06 18:00:32: No converter available for 'get' 'backlight_mode' ()
Upon futher testing, e.power_on_behavior()
and [14, 'power_on_behavior', tuya.valueConverter.powerOnBehavior]
does not work
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.
Whoops, it should be
tuya.exposes.backlightModeOffOn().withAccess(ea.STATE_SET)
This works
Changed
Fixed power on behavior Fixed backlightModeOffOn get
thanks! |
Power on behavior is still work in progress.
tuya.exposes.switch().withEndpoint('master_switch'),
requires #18157 to work.