Skip to content
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

[New device support]: 5 gang (tuya?) based switch #14369

Closed
Tuttle13 opened this issue Oct 6, 2022 · 11 comments
Closed

[New device support]: 5 gang (tuya?) based switch #14369

Tuttle13 opened this issue Oct 6, 2022 · 11 comments
Labels
new device support New device support request

Comments

@Tuttle13
Copy link

Tuttle13 commented Oct 6, 2022

Link

https://agmelectrical.com.au/home-automation-wifi-intercoms-smart-switches-and-power-points/sparkelec-touch-zigbee-wifi-switches-and-power-points/5-gang-smart-zigbee-touch-glass-wall-switch-off-white-sparkelec-sws5tz-white.html

Database entry

Model TS0601 IEEE: 0xa4c13883f126fce2 (0xC543) by _TZE200_jwsjbxjs

Comments

Hi, I can’t work out what to do either the data I have discovered on this device. It’s showing as “unsupported” even though it’s model is stated as a TS0601.
From my hours googling, I can’t find any previous support for this or any similar 5 gang switch.
I took screenshots of the data produced after creating a logger, first with the 5 switches off, then each of them all turned on, one by one. But I can’t recognise any real patters (maybe the DP value goes to 1-5?).
Have I missed a trick, or have I genuinely got a new and unsupported device?

I’m at a standstill and just have zero idea what to do next. Any help with making this device accessible in HA would be most appreciated! Thanks

External converter

No response

Supported color modes

No response

Color temperature range

No response
Taken with switches off:
Screenshot_20221005-224356_Home Assistant
Screenshot_20221005-224632_Home Assistant
Taken as I turned on each of the 5 switches:
Screenshot_20221005-225135_Home Assistant
Screenshot_20221005-225139_Home Assistant

@Tuttle13 Tuttle13 added the new device support New device support request label Oct 6, 2022
@Tuttle13 Tuttle13 changed the title [New device support]: [New device support]: 5 gang (tuya?) based switch Oct 6, 2022
@Koenkk
Copy link
Owner

Koenkk commented Oct 6, 2022

You have to reverse engineer the datapoints of the different gangs. First update to z2m 1.28.0 and then use the following converter: https://gist.github.com/Koenkk/159904dbc760446e39091c4b14f10a9a

  • save this as file next to configuration.yaml as ext_converter.js
  • add it to configuration.yaml:
external_converters:
  - ext_converter.js
  • start z2m

Now toggle the switch (z2m frontend -> device -> exposes tab). With the current converter I expect that gang 1 gets triggered. So dp 1 = gang 1. To find the next gang change [1, 'state', tuya.valueConverter.onOff], to [2, 'state', tuya.valueConverter.onOff], and try again. If it doesn't work keep incrementing the number until a gang responds. I expect that the seconds gang is somewhere below dp 10

@Tuttle13
Copy link
Author

Tuttle13 commented Oct 8, 2022

That worked a treat! Tried all 5 individually, and all 5 values triggered the 5 separate lights (both triggered on and off).
My next obvious question (I'm sure you saw coming), is how to I combine all 5 of these, and "enable" the device and have all 5 switches available to work with in HA?
(not sure if it will be an issue, but I'm still getting red popup messages saying "datapoint_21/22/23 not defined for _TZE_200_jwsjbxjs with..." periodically while this is running?)
Thanks again! I thought I was going to have to give up on the whole 5 switch gang.

@Koenkk
Copy link
Owner

Koenkk commented Oct 8, 2022

@Tuttle13 what are the datapoints for all the swithces?

I'm not sure what the other datapoints mean, to find out check https://www.zigbee2mqtt.io/advanced/support-new-devices/03_find_tuya_data_points.html#requirements-and-caveats

@Tuttle13
Copy link
Author

Tuttle13 commented Oct 8, 2022

So I need to do the process as described in your link with the Tuya app?

What I did was as you suggested, I changed the data point from "1", to "2", then to "3", "4","5", and each time I ran that js in HA, it successfully triggered each of the 5 different lights on and off when clicking on/off in expose. Do I need more data than that?
I was hoping the fact I can now "control" (via expose on/off) each of the 5 lights individually would be enough to get it "active"? (happy to do the Tuya app process if still needed - although I don't have a specific Tuya Gateway, just a conbee 2 stick?)

Edit: I can now add this single light switch (currently light no.5) to say my dashboard as a controllable switch - perfect! This allows me to automate etc. But just to reiterate what I’m hoping to do, I hope to have all 5 switches tied to this device. Otherwise, I presume I could create 5 of these .js files, one for each individual switch and add them this way?

Edit: not sure if it helps, but when I set the switch for "5" on in expose, this is the log info I first get:

Received MQTT message on 'zigbee2mqtt/0xa4c13883f126fce2/set' with data '{"state":"ON"}'
Zigbee2MQTT:debug 2022-10-08 20:11:01: Publishing 'set' 'state' to '0xa4c13883f126fce2'
Zigbee2MQTT:info  2022-10-08 20:11:01: MQTT publish: topic 'zigbee2mqtt/0xa4c13883f126fce2', payload '{"linkquality":255,"state":"ON"}'
Zigbee2MQTT:debug 2022-10-08 20:11:01: Received Zigbee message from '0xa4c13883f126fce2', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[1],"type":"Buffer"},"datatype":1,"dp":5}],"seq":31232}' from endpoint 1 with groupID null

And when I switched it off, I got:

Received MQTT message on 'zigbee2mqtt/0xa4c13883f126fce2/set' with data '{"state":"OFF"}'
Zigbee2MQTT:debug 2022-10-08 20:11:02: Publishing 'set' 'state' to '0xa4c13883f126fce2'
Zigbee2MQTT:info  2022-10-08 20:11:02: MQTT publish: topic 'zigbee2mqtt/0xa4c13883f126fce2', payload '{"linkquality":255,"state":"OFF"}'
Zigbee2MQTT:debug 2022-10-08 20:11:02: Received Zigbee message from '0xa4c13883f126fce2', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0,0,1,5],"type":"Buffer"},"datatype":2,"dp":21}],"seq":31488}' from endpoint 1 with groupID null
Zigbee2MQTT:warn  2022-10-08 20:11:02: Datapoint 21 not defined for '_TZE200_jwsjbxjs' with data {"dp":21,"datatype":2,"data":{"type":"Buffer","data":[0,0,1,5]}}
Zigbee2MQTT:debug 2022-10-08 20:11:02: Received Zigbee message from '0xa4c13883f126fce2', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0,0,9,138],"type":"Buffer"},"datatype":2,"dp":23}],"seq":31744}' from endpoint 1 with groupID null

@Koenkk
Copy link
Owner

Koenkk commented Oct 8, 2022

I changed the data point from "1", to "2", then to "3", "4","5", and each time I ran that js in HA, it successfully triggered each of the 5 different lights on and off when clicking on/off in expose.

That's all I needed to know.

Please check with the updated https://gist.github.com/Koenkk/159904dbc760446e39091c4b14f10a9a

@Tuttle13
Copy link
Author

Tuttle13 commented Oct 8, 2022

Thank you for that - though when I run that code, I'm getting errors for all 5 switches when trying any of them: "Publish set state to lights failed. error: no data point defined for 'state'?
Here's what they look like (including weird formatting in different ways):
Screenshot_20221008-234254_Home Assistant

@Tuttle13
Copy link
Author

Tuttle13 commented Oct 9, 2022

Solved: found a similar device you've previously supported and the missing ingredient was:
multiEndpoint: true,

Once I added that to first line of meta, all 5 seperate switches became functional (they were showing correct switch status, but weren't responding prior to this change)

Not sure if this is going the right way about it, but the working code I am now using is:

const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const extend = require('zigbee-herdsman-converters/lib/extend');
const ota = require('zigbee-herdsman-converters/lib/ota');
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const utils = require('zigbee-herdsman-converters/lib/utils');
const e = exposes.presets;
const ea = exposes.access;

const definition = {
    fingerprint: tuya.fingerprint('TS0601', ['_TZE200_jwsjbxjs']),
    model: 'TS0601_switch_5',
    vendor: 'TuYa',
    description: 'Zigbee 5 gang smart switch',
    fromZigbee: [tuya.fzDataPoints],
    toZigbee: [tuya.tzDataPoints],
    configure: tuya.configureMagicPacket,
    exposes: [
        e.switch().withEndpoint('l1'), 
        e.switch().withEndpoint('l2'), 
        e.switch().withEndpoint('l3'), 
        e.switch().withEndpoint('l4'), 
        e.switch().withEndpoint('l5')
    ],
    endpoint: (device) => {
        return {'l1': 1, 'l2': 1, 'l3': 1, 'l4': 1, 'l5': 1};
    },
    meta: {
        multiEndpoint: true,
        tuyaDatapoints: [
            [1, 'state_l1', tuya.valueConverter.onOff],
            [2, 'state_l2', tuya.valueConverter.onOff],
            [3, 'state_l3', tuya.valueConverter.onOff],
            [4, 'state_l4', tuya.valueConverter.onOff],
            [5, 'state_l5', tuya.valueConverter.onOff],
        ],
    },
};

module.exports = definition;

Koenkk added a commit to Koenkk/zigbee-herdsman-converters that referenced this issue Oct 9, 2022
@Koenkk
Copy link
Owner

Koenkk commented Oct 9, 2022

Well found, added the device!

Changes will be available in the dev branch in a few hours from now. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html)

@Koenkk Koenkk closed this as completed Oct 9, 2022
@Tuttle13
Copy link
Author

Tuttle13 commented Oct 9, 2022

thanks again for your assistance with this, and hopefully it helps anyone else looking at these type of plugs here is Aus (or wlsewhere)

@Tuttle13
Copy link
Author

Hi @Koenkk this has been working amazingly! The only left over issue is that I constantly get 3 DataPoint alerts, which I don’t care about, since all the switches are working.
“Datapoint 21/22/23 not defined…”

It doesn’t impact the gang switch operation, but it’s bloody annoying when using Z2M as it constantly pop’s up, and all 3 have to be cleared repeatedly.

Is there any way to disable these, or add a line to ignore these datapoints? Screenshot attached of them

thanks for your help! (again)
64ADF08C-5EF2-4BD7-8EA4-B73C3F7042FA

Koenkk added a commit to Koenkk/zigbee-herdsman-converters that referenced this issue Nov 17, 2022
@Koenkk
Copy link
Owner

Koenkk commented Nov 17, 2022

Done!

Changes will be available in the dev branch in a few hours from now. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html)

Mephistofeles pushed a commit to Mephistofeles/zigbee-herdsman-converters that referenced this issue Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new device support New device support request
Projects
None yet
Development

No branches or pull requests

2 participants