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

Add support for Tongue TOQCB2-80 #7752

Merged
merged 13 commits into from
Jul 9, 2024
Merged

Add support for Tongue TOQCB2-80 #7752

merged 13 commits into from
Jul 9, 2024

Conversation

bifi2090
Copy link
Contributor

@bifi2090 bifi2090 commented Jul 8, 2024

Add support for Tongue TOQCB2-80 from

Koenkk/zigbee2mqtt#21943 (comment)

@bifi2090
Copy link
Contributor Author

bifi2090 commented Jul 8, 2024

OK Guys, i need some help. I don´t know, if i must put something like:

TOQCB2_settings: {
    key: ['temperature_setting','temperature_threshold','under_voltage_setting','under_voltage_threshold',
          'over_current_setting','current_threshold','over_voltage_setting','over_voltage_threshold',
          'over_power_setting','over_power_threshold','restore_default'],
    convertSet: async (entity, key, value, meta) => {
        const settingType = {'trip': 2, 'alarm': 1, 'closed': 0};
        // const typeswitch = {'ON':true, 'OFF':false}
        let dp_key = -1; // value if not found
        // identify dp.
        const tuyadatapoints_list = meta.mapped.meta.tuyaDatapoints
        for (let i = 0; i < tuyadatapoints_list.length; i++) {
            if (tuyadatapoints_list[i][1] === key) {
                dp_key = tuyadatapoints_list[i][0];
                break;
            }
        }
        switch (key) {
        case 'temperature_setting': {
            await tuya.sendDataPointEnum(entity, dp_key, utils.getFromLookup(value, settingType));
            break;
        }
        case 'temperature_threshold': {
            await tuya.sendDataPointValue(entity, dp_key, value*10);
            break;
        }
        case 'under_voltage_setting': {
            await tuya.sendDataPointEnum(entity, dp_key, utils.getFromLookup(value, settingType));
            break;
        }
        case 'under_voltage_threshold': {
            await tuya.sendDataPointValue(entity, dp_key, value);
            break;
        }
        case 'over_voltage_setting': {
            await tuya.sendDataPointEnum(entity, dp_key, utils.getFromLookup(value, settingType));
            break;
        }
        case 'over_voltage_threshold': {
            await tuya.sendDataPointValue(entity, dp_key, value);
            break;
        }
        case 'over_power_setting': {
            await tuya.sendDataPointEnum(entity, dp_key, utils.getFromLookup(value, settingType));
            break;
        }
        case 'over_power_threshold': {
            await tuya.sendDataPointValue(entity, dp_key, value);
            break;
        }
        case 'over_current_setting': {
            await tuya.sendDataPointEnum(entity, dp_key, utils.getFromLookup(value, settingType));
            break;
        }
        case 'current_threshold': {
            await tuya.sendDataPointValue(entity, dp_key, value);
            break;
        }
        default: // Unknown key
            meta.logger.warn(`Unhandled key ${key}`);
        }
    },
}

somewhere between for example line 441 and 442. It gives me a lot of errors at build time.

src/devices/tuya.ts Outdated Show resolved Hide resolved
src/devices/tuya.ts Outdated Show resolved Hide resolved
src/devices/tuya.ts Outdated Show resolved Hide resolved
@Koenkk Koenkk merged commit 61dcfc8 into Koenkk:master Jul 9, 2024
2 checks passed
@Koenkk
Copy link
Owner

Koenkk commented Jul 9, 2024

Thanks!

@Proncio
Copy link

Proncio commented Aug 18, 2024

Hi,
2 small hints:

  1. Vendor is Tongou, rather than generic Tuya
  2. Last event is not working for me, looking at the code DP name in Expose and Meta sections is different, last_event1 vs last_event, changing meta one to last_event it works

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.

3 participants