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

Configuration of new 8ch switch #6545

Merged
merged 14 commits into from
Dec 8, 2023
Merged

Configuration of new 8ch switch #6545

merged 14 commits into from
Dec 8, 2023

Conversation

bszczepanik
Copy link
Contributor

I would like to add configuration for this new 8ch switch https://www.alibaba.com/product-detail/Tuya-smart-wifi-zigbee-Bluetooth-4CH_1600834099744.html

Look similar like TS0601_switch_8 but this one has different manufacturerName and last two Tuya data points.

@bszczepanik
Copy link
Contributor Author

I found na issue with switch multiply switches. Seperate request messages is sending in same time. Device send readback as switches are in expected possitions. But they aren't. I think the workaround is to set delay between request messages. How can I do this?

@Koenkk
Copy link
Owner

Koenkk commented Nov 23, 2023

Could you provide the debug log when sending multiple commands at once and it doesn't work? Currently we don't support this artificial delay.

See https://www.zigbee2mqtt.io/guide/usage/debug.html on how to enable debug logging.

@Koenkk
Copy link
Owner

Koenkk commented Nov 23, 2023

Note to self; after this merge Koenkk/zigbee2mqtt.io#2348

@bszczepanik
Copy link
Contributor Author

bszczepanik commented Nov 24, 2023

That is debug log, when channel 7 stucked:

Debug 2023-11-24 12:20:13 Publishing 'set' 'state' to 'Underfloor heating switch'
Info 2023-11-24 12:20:13 MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":61,"state_l1":"ON","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"OFF","state_l7":"OFF","state_l8":"OFF"}'
Debug 2023-11-24 12:20:13 Received MQTT message on 'zigbee2mqtt/Underfloor heating switch/l6/set' with data 'ON'
Debug 2023-11-24 12:20:13 Publishing 'set' 'state' to 'Underfloor heating switch'
Debug 2023-11-24 12:20:13 Received MQTT message on 'zigbee2mqtt/Underfloor heating switch/l7/set' with data 'ON'
Debug 2023-11-24 12:20:13 Publishing 'set' 'state' to 'Underfloor heating switch'
Info 2023-11-24 12:20:13 MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":61,"state_l1":"ON","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"ON","state_l7":"OFF","state_l8":"OFF"}'
Debug 2023-11-24 12:20:13 Received Zigbee message from 'Underfloor heating switch', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[1],"type":"Buffer"},"datatype":1,"dp":1}],"seq":18432}' from endpoint 1 with groupID 0
Info 2023-11-24 12:20:13 MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":72,"state_l1":"ON","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"ON","state_l7":"OFF","state_l8":"OFF"}'
Info 2023-11-24 12:20:13 MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":72,"state_l1":"ON","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"ON","state_l7":"ON","state_l8":"OFF"}'
Debug 2023-11-24 12:20:13 Received Zigbee message from 'Underfloor heating switch', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[1],"type":"Buffer"},"datatype":1,"dp":6}],"seq":18688}' from endpoint 1 with groupID 0
Info 2023-11-24 12:20:13 MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":76,"state_l1":"ON","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"ON","state_l7":"ON","state_l8":"OFF"}'
Debug 2023-11-24 12:20:13 Received Zigbee message from 'Underfloor heating switch', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[1],"type":"Buffer"},"datatype":1,"dp":7}],"seq":18944}' from endpoint 1 with groupID 0
Info 2023-11-24 12:20:13 MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":76,"state_l1":"ON","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"ON","state_l7":"ON","state_l8":"OFF"}'
Debug 2023-11-24 12:20:18 Received MQTT message on 'zigbee2mqtt/Underfloor heating switch/l1/set' with data 'OFF'
Debug 2023-11-24 12:20:18 Publishing 'set' 'state' to 'Underfloor heating switch'
Info 2023-11-24 12:20:18 MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":76,"state_l1":"OFF","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"ON","state_l7":"ON","state_l8":"OFF"}'
Debug 2023-11-24 12:20:18 Received MQTT message on 'zigbee2mqtt/Underfloor heating switch/l6/set' with data 'OFF'
Debug 2023-11-24 12:20:18 Publishing 'set' 'state' to 'Underfloor heating switch'
Debug 2023-11-24 12:20:18 Received MQTT message on 'zigbee2mqtt/Underfloor heating switch/l7/set' with data 'OFF'
Debug 2023-11-24 12:20:18 Publishing 'set' 'state' to 'Underfloor heating switch'
Debug 2023-11-24 12:20:18 Received Zigbee message from 'Underfloor heating switch', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0],"type":"Buffer"},"datatype":1,"dp":1}],"seq":19200}' from endpoint 1 with groupID 0
Info 2023-11-24 12:20:18 MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":65,"state_l1":"OFF","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"ON","state_l7":"ON","state_l8":"OFF"}'
Info 2023-11-24 12:20:18 MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":65,"state_l1":"OFF","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"OFF","state_l7":"ON","state_l8":"OFF"}'
Info 2023-11-24 12:20:18 MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":65,"state_l1":"OFF","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"OFF","state_l7":"OFF","state_l8":"OFF"}'
Debug 2023-11-24 12:20:18 Received Zigbee message from 'Underfloor heating switch', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0],"type":"Buffer"},"datatype":1,"dp":6}],"seq":19456}' from endpoint 1 with groupID 0
Info 2023-11-24 12:20:18 MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":65,"state_l1":"OFF","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"OFF","state_l7":"OFF","state_l8":"OFF"}'

And that when I put 100 ms delay in Home Assistant, that's way everything worked:

Debug 2023-11-24 12:22:25Publishing 'set' 'state' to 'Underfloor heating switch'
Info 2023-11-24 12:22:25MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":76,"state_l1":"ON","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"OFF","state_l7":"OFF","state_l8":"OFF"}'
Debug 2023-11-24 12:22:26Received Zigbee message from 'Underfloor heating switch', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[1],"type":"Buffer"},"datatype":1,"dp":1}],"seq":19712}' from endpoint 1 with groupID 0
Info 2023-11-24 12:22:26MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":69,"state_l1":"ON","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"OFF","state_l7":"OFF","state_l8":"OFF"}'
Debug 2023-11-24 12:22:26Received MQTT message on 'zigbee2mqtt/Underfloor heating switch/l6/set' with data 'ON'
Debug 2023-11-24 12:22:26Publishing 'set' 'state' to 'Underfloor heating switch'
Info 2023-11-24 12:22:26MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":69,"state_l1":"ON","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"ON","state_l7":"OFF","state_l8":"OFF"}'
Debug 2023-11-24 12:22:26Received MQTT message on 'zigbee2mqtt/Underfloor heating switch/l7/set' with data 'ON'
Debug 2023-11-24 12:22:26Publishing 'set' 'state' to 'Underfloor heating switch'
Debug 2023-11-24 12:22:26Received Zigbee message from 'Underfloor heating switch', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[1],"type":"Buffer"},"datatype":1,"dp":6}],"seq":19968}' from endpoint 1 with groupID 0
Info 2023-11-24 12:22:26MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":72,"state_l1":"ON","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"ON","state_l7":"OFF","state_l8":"OFF"}'
Info 2023-11-24 12:22:26MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":72,"state_l1":"ON","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"ON","state_l7":"ON","state_l8":"OFF"}'
Debug 2023-11-24 12:22:26Received Zigbee message from 'Underfloor heating switch', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[1],"type":"Buffer"},"datatype":1,"dp":7}],"seq":20224}' from endpoint 1 with groupID 0
Info 2023-11-24 12:22:26MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":69,"state_l1":"ON","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"ON","state_l7":"ON","state_l8":"OFF"}'
Debug 2023-11-24 12:22:31Received MQTT message on 'zigbee2mqtt/Underfloor heating switch/l1/set' with data 'OFF'
Debug 2023-11-24 12:22:31Publishing 'set' 'state' to 'Underfloor heating switch'
Info 2023-11-24 12:22:31MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":69,"state_l1":"OFF","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"ON","state_l7":"ON","state_l8":"OFF"}'
Debug 2023-11-24 12:22:31Received Zigbee message from 'Underfloor heating switch', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0],"type":"Buffer"},"datatype":1,"dp":1}],"seq":20480}' from endpoint 1 with groupID 0
Info 2023-11-24 12:22:31MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":72,"state_l1":"OFF","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"ON","state_l7":"ON","state_l8":"OFF"}'
Debug 2023-11-24 12:22:31Received MQTT message on 'zigbee2mqtt/Underfloor heating switch/l6/set' with data 'OFF'
Debug 2023-11-24 12:22:31Publishing 'set' 'state' to 'Underfloor heating switch'
Info 2023-11-24 12:22:31MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":72,"state_l1":"OFF","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"OFF","state_l7":"ON","state_l8":"OFF"}'
Debug 2023-11-24 12:22:31Received MQTT message on 'zigbee2mqtt/Underfloor heating switch/l7/set' with data 'OFF'
Debug 2023-11-24 12:22:31Publishing 'set' 'state' to 'Underfloor heating switch'
Debug 2023-11-24 12:22:31Received Zigbee message from 'Underfloor heating switch', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0],"type":"Buffer"},"datatype":1,"dp":6}],"seq":20736}' from endpoint 1 with groupID 0
Info 2023-11-24 12:22:31MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":72,"state_l1":"OFF","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"OFF","state_l7":"ON","state_l8":"OFF"}'
Info 2023-11-24 12:22:31MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":72,"state_l1":"OFF","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"OFF","state_l7":"OFF","state_l8":"OFF"}'
Debug 2023-11-24 12:22:31Received Zigbee message from 'Underfloor heating switch', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0],"type":"Buffer"},"datatype":1,"dp":7}],"seq":20992}' from endpoint 1 with groupID 0
Info 2023-11-24 12:22:31MQTT publish: topic 'zigbee2mqtt/Underfloor heating switch', payload '{"linkquality":76,"state_l1":"OFF","state_l2":"OFF","state_l3":"OFF","state_l4":"OFF","state_l5":"OFF","state_l6":"OFF","state_l7":"OFF","state_l8":"OFF"}'

@Koenkk
Copy link
Owner

Koenkk commented Nov 25, 2023

I think we can solve this by creating a new valueConverter (instead of valueConverter.onOff) which has a sleep inside.

@bszczepanik
Copy link
Contributor Author

Wouldn't this cause all requests to be delayed by the same amount of time? All requests will be sent at the same time, but delayed.

@Koenkk
Copy link
Owner

Koenkk commented Nov 25, 2023

I don't think so, they should be send sequentially

src/lib/tuya.ts Outdated
@@ -440,6 +440,13 @@ export const valueConverter = {
trueFalseEnum0: valueConverterBasic.trueFalse(new Enum(0)),
trueFalseEnum1: valueConverterBasic.trueFalse(new Enum(1)),
onOff: valueConverterBasic.lookup({'ON': true, 'OFF': false}),
onOffWithDelay: {
to: async (value: string) => {
await utils.sleep(200);
Copy link
Contributor Author

@bszczepanik bszczepanik Nov 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put delay here, but that caused that all requests are delayed and send all togheter after 200 ms. It should look like utils.sleep(transitiont * 200) but I don't know how proper declare transition

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean with transitiont?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I will change switch in Z2M for more then one entity at one time, I want to set some number like 0, 1, 2, 3 for each. I will get delay time such 0 * 200 ms, 1 * 200 ms, 2 * 200 ms and so on.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change to: async (value: string) => { to to: async (value: string, meta) => {, you can get the message with meta.message, from that you can count the number of state_ and create the timeout based on that.

@bszczepanik
Copy link
Contributor Author

That code works for me. I am not sure is it correct to put value clear function to on event function. It works but I don't know is it good way.

@Koenkk
Copy link
Owner

Koenkk commented Nov 30, 2023

Instead of using the globalStore, did you experiment with using the meta.message instead?

@bszczepanik
Copy link
Contributor Author

I checked this device once again with default onoff functions. I realived that after update Z2M and Home Assistan there is no problem with freezing channels. That configuration works correct.

@Koenkk Koenkk merged commit 3b6eb9c into Koenkk:master Dec 8, 2023
2 checks passed
@Koenkk
Copy link
Owner

Koenkk commented Dec 8, 2023

Thanks!

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.

2 participants