Tuya TS0044 first action ignored

First of all, hello everyone. I’m new here. I started with HA last month. And so far I’m very happy with HA. It’s a great software and most of my problems I could solve by browsing this community forum :slight_smile:

I added some Tuya switches (TS0044, TS0042 & TS0041). They are connected with ZHA and a sonoff 3.0 dongle. Most of the time they work very well.
However if the switches are not used for some time (for example over night), the first click has no effect and is not recognized by HA. The second click then works fine.
It seems that they enter some kind of sleep mode if not used for some time.
Is there a way to prevent that from happening? If I click a button I want my light to turn on the first time I click, not the second time.

unfortunately it does not seem to be a configuration, but an implementation problem:

Hello.

I know how to fix that with Zigbee2MQTT, perhaps you can do the same in ZHA.
In Z2M you need to add external converters, that off battery reporting and add tuya magic.

Next steps is for Z2M

  1. Create file called tuya44.js (must be .js extension) in config/zigbee2mqtt folder, near configuration.yaml
  2. For TS0044 use following
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 = {
    zigbeeModel: ['TS0044'],
    fingerprint: [{manufacturerName: '_TZ3000_tk3s5tyg'}],
    model: 'TS0044',
    vendor: 'TuYa',
    description: 'Wireless switch with 4 buttons (custom)',
    whiteLabel: [{vendor: 'Lonsonho', model: 'TS0044'}, {vendor: 'Haozee', model: 'ESW-OZAA-EU'}, {vendor: 'LoraTap', model: 'SS6400ZB'}],
    fromZigbee: [fz.tuya_on_off_action, fz.battery],
    exposes: [e.battery(), e.action(['1_single', '1_double', '1_hold', '2_single', '2_double', '2_hold', '3_single', '3_double', '3_hold', '4_single', '4_double', '4_hold'])],
    toZigbee: [],
    configure: async (device, coordinatorEndpoint, logger) => {
        const endpoint = device.getEndpoint(1);
        await endpoint.read('genBasic', [0x0004, 0x000, 0x0001, 0x0005, 0x0007, 0xfffe]);
        await endpoint.write('genBasic', {0xffde: {value: 0x13, type: 0x20}});
    },
};

module.exports = definition;
  1. In configuration.yaml add
external_converters:
  - tuya44.js
  1. Restart Zigbee2MQTT
  2. Re-pair your device
2 Likes

hi i have this issue but dont have the folders you mention in my system, should i create the zigbee2mqtt folder inside my config folder where the configuration.yaml file is and put the new file in there?

Hi. No, you should not create that dirs. They must exists. I think you looking for them wrong place or wrong way. Try to install File Editor addon addons/configurator at master · home-assistant/addons · GitHub
Note, that by default you rooted in config directory

Yeah im using that program and im in the config folder but theres no zigbee2mqtt folder in there

ive created a zigbee2mqtt folder in the config dir, but will that not work if it wasnt there already?

Do you have zigbee2mqtt installed and running? It uses config/zigbee2mqtt/configuration.yaml file. You should locate that file. tuya44.js must be in same dir, and you must add external converter to configuration.yaml itself.
Maybe z2m guide can help you locate that file Configuration | Zigbee2MQTT

i have a HA yellow, i presumed this was zigbee2mqtt

Maybe z2m config file location depends on Home Assistant installation type. I use Home Assistant OS and it placed config/zigbee2mqtt in my case.
Try to look /opt/zigbee2mqtt/data/

no theres no folder like that in config dir but i cant go up the tree like you said im rooted in the config folder and im new to HA

No, it is ZHA addon. Unfortunately i don’t know how to fix that issue with ZHA. My instructions is for Zigbee2MQTT addon GitHub - Koenkk/zigbee2mqtt: Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨

ok, thanks for your time though :slight_smile:

This looks just what I need. Would I need to implement multiple times and change the manufacturer ID (which appears to be a serial number) for each device? If so, how do I put repeat devices in.

Thanks for your support.

Can you explain what this implementation is doing exactly versus the out-of-the-box Z2M implementation? How does it help to solve the issue? Does it keep it awake somehow?

I tried that and sadly it did not fix the issue with the first action ignored. In my case, it’s even 2 or 3 actions that are required before it starts working again.

I am sure it’s using the external converter because it showed “custom” while pairing it again.

I don’t remember having issues with that button when I was using Deconz.