zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

[New device support]: Tuya Zigbee Sensor de Gas Natural para el hogar, Detector de fugas de Gas GLP inteligente, protección contra incendios

Open Waterbrain opened this issue 3 years ago • 41 comments

Link

https://es.aliexpress.com/item/1005005936314298.html

Database entry

{"1":"Gas Detection State","2":"Detected Gas","6":"Alarm Ringtone","7":"Alarm Time","8":"Auto-Detect","9":"Auto-Detect Result","10":"Preheat","13":"Alarm Switch","16":"Silence"}

Comments

Hello, I followed the guide to add new zigbee devices for Tuya, and diving into the tuya.ts repository I wrote this converter. I wonder if before adding it as an external converter, what I have put in would work and not break my Zigbe2MQTT.

External converter

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 e = exposes.presets;
const ea = exposes.access;
const tuya = require('zigbee-herdsman-converters/lib/tuya');

const definition = {
    // Since a lot of TuYa devices use the same modelID, but use different datapoints
    // it's necessary to provide a fingerprint instead of a zigbeeModel
    fingerprint: [
        {
            // The model ID from: Device with modelID 'TS0601' is not supported
            // You may need to add \u0000 at the end of the name in some cases
            modelID: 'TS0601',
            // The manufacturer name from: Device with modelID 'TS0601' is not supported.
            manufacturerName: '_TZE204_zougpkpy',
        },
    ],
    model: 'TS0601_new',
    vendor: 'TuYa',
    description: 'Combustible gas detector',
    fromZigbee: [tuya.fz.datapoints],
    toZigbee: [tuya.tz.datapoints],
    onEvent: tuya.onEventSetTime, // Add this if you are getting no converter for 'commandMcuSyncTime'
    configure: tuya.configureMagicPacket,
    exposes: [
        e.gas(), tuya.exposes.gasValue().withUnit('LEL'), tuya.exposes.selfTest(), tuya.exposes.selfTestResult(),
        tuya.exposes.silence(),
        e.enum('alarm_ringtone', ea.STATE_SET, ['1', '2', '3', '4', '5']).withDescription('Ringtone of the alarm'),
        e.numeric('alarm_time', ea.STATE_SET).withValueMin(1).withValueMax(180).withValueStep(1)
            .withUnit('s').withDescription('Alarm time'),
        e.binary('preheat', ea.STATE, true, false).withDescription('Indicates sensor preheat is active'),
    ],
    meta: {
        tuyaDatapoints: [
            [1, 'gas', tuya.valueConverter.trueFalseEnum0],
            [2, 'gas_value', tuya.valueConverter.divideBy10],
            [6, 'alarm_ringtone', tuya.valueConverterBasic.lookup({'1': 0, '2': 1, '3': 2, '4': 3, '5': 4})],
            [7, 'alarm_time', tuya.valueConverter.raw],
            [8, 'self_test', tuya.valueConverter.raw],
            [9, 'self_test_result', tuya.valueConverter.selfTestResult],
            [10, 'preheat', tuya.valueConverter.raw],
            [13, null, null], // alarm_switch; ignore for now since it is unclear what it does
            [16, 'silence', tuya.valueConverter.raw],
        ],
    },
};

module.exports = definition;

Supported color modes

No response

Color temperature range

No response

Waterbrain avatar Oct 11 '23 10:10 Waterbrain

Captura de Pantalla 2023-10-11 a las 12 40 03

Waterbrain avatar Oct 11 '23 11:10 Waterbrain

does z2m start and does the device work when using this ext converter?

Koenkk avatar Oct 11 '23 15:10 Koenkk

This is what I want to know if I activate it. Know if it is well done?

Waterbrain avatar Oct 12 '23 06:10 Waterbrain

This is what I want to know if I activate it. Know if it is well done?

Waterbrain avatar Oct 12 '23 06:10 Waterbrain

[08:11:59] INFO: Preparing to start... [08:12:00] INFO: Socat not enabled [08:12:02] ERROR: Got unexpected response from the API: Service not enabled [08:12:02] INFO: Starting Zigbee2MQTT...

Waterbrain avatar Oct 12 '23 06:10 Waterbrain

Captura de Pantalla 2023-10-12 a las 8 16 15

Waterbrain avatar Oct 12 '23 06:10 Waterbrain

But, it detects the gas and does not activate the sensor....

Captura de Pantalla 2023-10-12 a las 8 22 11

Waterbrain avatar Oct 12 '23 06:10 Waterbrain

I'm going to link it to Tuya and see something else.....

Waterbrain avatar Oct 12 '23 06:10 Waterbrain

Captura de Pantalla 2023-10-12 a las 8 57 01 Captura de Pantalla 2023-10-12 a las 8 57 36

Waterbrain avatar Oct 12 '23 07:10 Waterbrain

May be [1, 'gas', tuya.valueConverter.trueFalseEnum0],?

Waterbrain avatar Oct 12 '23 07:10 Waterbrain

It doesn't work either

Captura de Pantalla 2023-10-12 a las 9 10 27

Waterbrain avatar Oct 12 '23 07:10 Waterbrain

[1, 'gas', tuya.valueConverterBasic.lookup({'alarm': tuya.enum(0), 'normal': tuya.enum(1)})]

Waterbrain avatar Oct 12 '23 07:10 Waterbrain

Well the gas is sue works: Captura de Pantalla 2023-10-12 a las 9 47 19 Detected: Captura de Pantalla 2023-10-12 a las 9 49 37 But at startup it gives this error:

[09:56:33] INFO: Preparing to start... [09:56:33] INFO: Socat not enabled [09:56:35] ERROR: Got unexpected response from the API: Service not enabled [09:56:35] INFO: Starting Zigbee2MQTT...

Captura de Pantalla 2023-10-12 a las 9 46 23

And the tone selection doesn't work, any ideas?

Waterbrain avatar Oct 12 '23 07:10 Waterbrain

Works perfectly

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 e = exposes.presets;
const ea = exposes.access;
const tuya = require('zigbee-herdsman-converters/lib/tuya');

const definition = {
    // Since a lot of TuYa devices use the same modelID, but use different datapoints
    // it's necessary to provide a fingerprint instead of a zigbeeModel
    fingerprint: [
        {
            modelID: 'TS0601',
            manufacturerName: '_TZE204_zougpkpy',
        },
    ],
    model: 'TZE204_zougpkpy',
    vendor: 'TuYa',
    description: 'Combustible gas detector',
    fromZigbee: [tuya.fz.datapoints],
    toZigbee: [tuya.tz.datapoints],
    onEvent: tuya.onEventSetTime, // Add this if you are getting no converter for 'commandMcuSyncTime'
    configure: tuya.configureMagicPacket,
    exposes: [
        e.gas(), tuya.exposes.gasValue().withUnit('LEL'), tuya.exposes.selfTest(), tuya.exposes.selfTestResult(),
        tuya.exposes.silence(),
        e.enum('alarm_ringtone', ea.STATE_SET, [
            'melody1', 'melody2', 'melody3', 'melody4', 'melody5',
        ]).withDescription('Ringtone of the alarm'),
        e.numeric('alarm_time', ea.STATE_SET).withValueMin(1).withValueMax(180).withValueStep(1)
            .withUnit('s').withDescription('Alarm time'),
        e.binary('preheat', ea.STATE, true, false).withDescription('Indicates sensor preheat is active'),
    ],
    meta: {
        tuyaDatapoints: [
            [1, 'gas', tuya.valueConverterBasic.lookup({'alarm': tuya.enum(0), 'normal': tuya.enum(1)})],
            [2, 'gas_value', tuya.valueConverter.divideBy10],
            [6, 'alarm_ringtone', tuya.valueConverterBasic.lookup({
                'melody1': tuya.enum(0), 'melody2': tuya.enum(1), 'melody3': tuya.enum(2), 'melody4': tuya.enum(3),
                'melody5': tuya.enum(4), })],
            [7, 'alarm_time', tuya.valueConverter.raw],
            [8, 'self_test', tuya.valueConverter.raw],
            [9, 'self_test_result', tuya.valueConverter.selfTestResult],
            [10, 'preheat', tuya.valueConverter.raw],
            [13, null, null], // alarm_switch; ignore for now since it is unclear what it does
            [16, 'silence', tuya.valueConverter.raw],
        ],
    },
};

module.exports = definition;

Waterbrain avatar Oct 13 '23 11:10 Waterbrain

What is the next step?

Waterbrain avatar Oct 13 '23 11:10 Waterbrain

@Waterbrain integrated it, thanks!

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 avatar Oct 13 '23 18:10 Koenkk

This is the current status of my converter:

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 e = exposes.presets;
const ea = exposes.access;
const tuya = require('zigbee-herdsman-converters/lib/tuya');

const definition = {
    fingerprint: [
        {
            modelID: 'TS0601',
            manufacturerName: '_TZE204_zougpkpy',
        },
    ],
    model: 'TZE204_zougpkpy',
    vendor: 'TuYa',
    description: 'Combustible gas detector',
    fromZigbee: [tuya.fz.datapoints],
    toZigbee: [tuya.tz.datapoints],
    onEvent: tuya.onEventSetTime, // Add this if you are getting no converter for 'commandMcuSyncTime'
    configure: tuya.configureMagicPacket,
    exposes: [
        e.gas(), tuya.exposes.gasValue().withUnit('LEL'), tuya.exposes.selfTest(), tuya.exposes.selfTestResult(),
        tuya.exposes.silence(),
        e.enum('gas_detection_state', ea.STATE, ['alarm', 'normal']).withDescription('State of sensor'),
        e.enum('alarm_ringtone', ea.STATE_SET, [
            'melody1', 'melody2', 'melody3', 'melody4', 'melody5',
        ]).withDescription('Ringtone of the alarm'),
        e.numeric('alarm_time', ea.STATE_SET).withValueMin(1).withValueMax(180).withValueStep(1)
            .withUnit('s').withDescription('Alarm time'),
        e.binary('preheat', ea.STATE, true, false).withDescription('Indicates sensor preheat is active'),
    ],
    meta: {
        tuyaDatapoints: [
            [1, 'gas_detection_state', tuya.valueConverterBasic.lookup({ 'alarm': tuya.enum(0), 'normal': tuya.enum(1) })],
            [2, 'gas_value', tuya.valueConverter.divideBy10],
            [6, 'alarm_ringtone', tuya.valueConverterBasic.lookup({
                'melody1': tuya.enum(0), 'melody2': tuya.enum(1), 'melody3': tuya.enum(2), 'melody4': tuya.enum(3),
                'melody5': tuya.enum(4),
            })],
            [7, 'alarm_time', tuya.valueConverter.raw],
            [8, 'self_test', tuya.valueConverter.raw],
            [9, 'self_test_result', tuya.valueConverter.selfTestResult],
            [10, 'preheat', tuya.valueConverter.raw],
            [13, null, null], // alarm_switch; ignore for now since it is unclear what it does 
            [16, 'silence', tuya.valueConverter.raw],
        ],
    },
};

module.exports = definition;

But the detector status does not work for me:

Captura de Pantalla 2023-10-14 a las 10 17 40

Although it is detecting gas, the status is still false (Gas value 13 LEL and Gas detection state alarm).

And in Home Assitant states:

Captura de Pantalla 2023-10-14 a las 10 30 50

I don't know if it's because of doing so many tests or why this happens. The installation of zigbee2MQTT, as you can see, is in Homeassitant.

In addons store I see:

Captura de Pantalla 2023-10-14 a las 10 35 02

If I install Zigbee2MQTT Edge could you help me?

The thing is that in the documentation to debug the Zigbee protocol it talks about installing a tool that I cannot install on my HomeAssitant.

Waterbrain avatar Oct 14 '23 08:10 Waterbrain

Maybe we can manage to close the gas valve by reading the mqtt lel level via nodered.

kerimcelik avatar Oct 24 '23 21:10 kerimcelik

Maybe this way we can reset the alarm when it activates.

kerimcelik avatar Oct 24 '23 21:10 kerimcelik

But if we do it as I have it, in "Gas detector state" it does change the states of "alarm" or "normal".

Captura de Pantalla 2023-10-25 a las 8 10 36

I am trying to contact the seller to see if we can clear up any problems.

Waterbrain avatar Oct 25 '23 06:10 Waterbrain