zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

[New device support]: BAC-3000-ALZB Fan Coil Thermostat

Open hanfreakingsolo opened this issue 4 years ago • 7 comments

Link

https://www.aliexpress.com/item/1005002593757973.html

Database entry

{"id":16,"type":"Router","ieeeAddr":"0x2c1165fffe99ebcd","nwkAddr":32547,"manufId":4098,"manufName":"_TZE200_dzuqwsyg","powerSource":"Mains (single phase)","modelId":"TS0601","epList":[1],"endpoints":{"1":{"profId":260,"epId":1,"devId":81,"inClusterList":[0,4,5,61184],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"65503":"\u0000\u0000\u0000\u0000\u0007","65506":31,"65508":0,"modelId":"TS0601","manufacturerName":"_TZE200_dzuqwsyg","powerSource":1,"zclVersion":3,"appVersion":72,"stackVersion":0,"hwVersion":1,"dateCode":""}},"genGroups":{"attributes":{"nameSupport":0}},"genPowerCfg":{"attributes":{}},"genScenes":{"attributes":{"currentScene":0}},"genLevelCtrl":{"attributes":{}},"hvacThermostat":{"attributes":{}},"genIdentify":{"attributes":{}},"hvacPumpCfgCtrl":{"attributes":{}},"manuSpecificTuya_3":{"attributes":{}},"genDeviceTempCfg":{"attributes":{}},"hvacUserInterfaceCfg":{"attributes":{}}},"binds":[{"cluster":61184,"type":"endpoint","deviceIeeeAddress":"0x00124b0024c0bcf6","endpointID":1}],"configuredReportings":[],"meta":{}}},"appVersion":72,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{},"lastSeen":1662067468154,"defaultSendRequestWhen":"immediate"}

Comments

This is my first time adding a new device, and I'm totally new to JS so bear with me. I bought this thermostat on Aliexpress, and it showed up as a supported device in zigbee2mqtt with model number BAC-002-ALZB. Problem is, it's model BAC-3000-AZLB. The default converter sort of worked, but was missing the heat function and allowed 0.5 degree steps. I found a converter someone made to fix these things for the BAC-002 model, and adjusted it a bit. Adjustments made:

  • Removed 'ON OFF' as a separate state switch, and combined it with system_mode (now 'off', 'cool', 'heat', and 'fan_only) *Personal Preference!
  • Fixed controls trying to send half degree adjustments by adding rounding to occupied_heating_heatpoint value. Although I limited the steps to whole degrees, google home still allowed half degree increments which caused the device to spaz out and set itself to zero.

OUTSTANDING PROBLEMS:

  • Model number! I can't figure this one out. It identifies as a BAC-002-ALZB because the modelID and manufacturerName are the same. How can the device be identified as a different model? NOTE I left the incorrect model in the converter below, that needs to be changed
  • Combining off into system_mode works fine, but the device still returns the state 'ON' when it's actually off
  • When selecting the device modes in google home, they don't match up and still show 'ON' as an option. The Fan mode also doesn't have an icon. (see screenshot below)
  • Half degree increments! Is this possible? The device itself allows this through the touchscreen, but after some reading online I think it's a tuya zigbee limitation? Any way to get around this?

Screenshot_20220901-173616_Home

See the converter below. Things I disabled are left commented out in case I messed anything up, so apologies as the code needs some cleaning.

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 tuya = require('zigbee-herdsman-converters/lib/tuya');
const ota = require('zigbee-herdsman-converters/lib/ota');
const {repInterval, defaultBindGroup, OneJanuary2000} = require('zigbee-herdsman-converters/lib/constants');
const utils = require('zigbee-herdsman-converters/lib/utils');
const e = exposes.presets;
const ea = exposes.access;



const fz_moes_thermostat_custom = {
	cluster: 'manuSpecificTuya',
	type: ['commandGetData', 'commandSetDataResponse', 'commandDataResponse'],
	convert: (model, msg, publish, options, meta) => {
            const dpValue = tuya.firstDpValue(msg, meta, 'moes_thermostat');
            const dp = dpValue.dp;
            const value = tuya.getDataValue(dpValue);
		let temperature;
		/* See tuyaThermostat above for message structure comment */
		switch (dp) {
		case tuya.dataPoints.moesSchedule:
			return {
				program: [
					{weekdays_p1: value[0] + 'h:' + value[1] + 'm ' + value[2]/2 + '°C'},
					{weekdays_p2: value[3] + 'h:' + value[4] + 'm ' + value[5]/2 + '°C'},
					{weekdays_p3: value[6] + 'h:' + value[7] + 'm ' + value[8]/2 + '°C'},
					{weekdays_p4: value[9] + 'h:' + value[10] + 'm ' + value[11]/2 + '°C'},
					{saturday_p1: value[12] + 'h:' + value[13] + 'm ' + value[14]/2+ '°C'},
					{saturday_p2: value[15] + 'h:' + value[16] + 'm ' + value[17]/2 + '°C'},
					{saturday_p3: value[18] + 'h:' + value[19] + 'm ' + value[20]/2 + '°C'},
					{saturday_p4: value[21] + 'h:' + value[22] + 'm ' + value[23]/2 + '°C'},
					{sunday_p1: value[24] + 'h:' + value[25] + 'm ' + value[26]/2 + '°C'},
					{sunday_p2: value[27] + 'h:' + value[28] + 'm ' + value[29]/2 + '°C'},
					{sunday_p3: value[30] + 'h:' + value[31] + 'm ' + value[32]/2 + '°C'},
					{sunday_p4: value[33] + 'h:' + value[34] + 'm ' + value[35]/2 + '°C'},
				],
			};
		case 1: // system mode (OFF, ON)
			if(value == 0) {
				return {system_mode: 'off'};
			//} else if(value == 1) {
			//	return {state: 'ON'};
			} else {
				return {};
			}
		case 2: // system mode (cooling, heating, fan)
			if(value == 0) {
				return {system_mode: 'cool'};
			} else if(value == 1) {
				return {system_mode: 'heat'};
			} else if(value == 2) {
				return {system_mode: 'fan_only'};
			} else {
				return {};
			}
		case 28: // fan mode
			if(value == 0) {
				return {fan_mode: 'low'};
			} else if(value == 1) {
				return {fan_mode: 'medium'};
			} else if(value == 2) {
				return {fan_mode: 'high'};
			} else if(value == 3) {
				return {fan_mode: 'auto'};
			} else {
				return {};
			}
		case 16: // temperature setpoint for both heating and cooling
			return {occupied_heating_setpoint: value};
		case tuya.dataPoints.moesChildLock:
			return {child_lock: value ? 'LOCK' : 'UNLOCK'};
		case tuya.dataPoints.moesMaxTempLimit:
			return {max_temperature_limit: value};
		case tuya.dataPoints.moesMaxTemp:
			return {max_temperature: value};
		case tuya.dataPoints.moesDeadZoneTemp:
			return {deadzone_temperature: value};
		case tuya.dataPoints.moesLocalTemp:
			temperature = value & 1<<15 ? value - (1<<16) + 1 : value;
			return {local_temperature: parseFloat((temperature / 10).toFixed(1))};
		case tuya.dataPoints.moesTempCalibration:
			temperature = value;
			// for negative values produce complimentary hex (equivalent to negative values)
			if (temperature > 4000) temperature = temperature - 4096;
			return {local_temperature_calibration: temperature};
		case tuya.dataPoints.moesHold: // state is inverted, preset_mode is deprecated
			return {preset_mode: value ? 'program' : 'hold', preset: value ? 'program' : 'hold'};
		case tuya.dataPoints.moesScheduleEnable: // state is inverted, preset_mode is deprecated
			return {preset_mode: value ? 'hold' : 'program', preset: value ? 'hold' : 'program'};
		case tuya.dataPoints.moesValve:
			return {heat: value ? 'OFF' : 'ON'};
		case tuya.dataPoints.moesSensor:
			switch (value) {
			case 0:
				return {sensor: 'IN'};
			case 1:
				return {sensor: 'AL'};
			case 2:
				return {sensor: 'OU'};
			default:
				return {sensor: 'not_supported'};
			}
		default: // DataPoint 17 is unknown
			meta.logger.warn(`zigbee-herdsman-converters:Moes BHT-002: Unrecognized DP #${
				dp} with data ${JSON.stringify(msg.data)}`);
		}
	},
};


//const tz_state = {
//	key: ['state'],
//	convertSet: async (entity, key, value, meta) => {
//		if(value == "OFF") {
//			await tuya.sendDataPointBool(entity, 1, false);
//		} else if(value == "ON") {
//			await tuya.sendDataPointBool(entity, 1, true);
//		}
//	},
//};

const tz_system_mode = {
	key: ['system_mode'],
	convertSet: async (entity, key, value, meta) => {
		if(value == "cool") {
			await tuya.sendDataPointEnum(entity, 2, 0);
		} else if(value == "heat") {
			await tuya.sendDataPointEnum(entity, 2, 1);
		} else if(value == "fan_only") {
			await tuya.sendDataPointEnum(entity, 2, 2);
		} else if(value == "off") {
			await tuya.sendDataPointBool(entity, 1, false);
		}
	}
};


const tz_temperature_setpoint = {
	key: ['occupied_heating_setpoint'],
	convertSet: async (entity, key, value, meta) => {
		const temp = Math.round(value)
		await tuya.sendDataPointValue(entity, 16, temp);
	},
};

const tz_fan_mode = {
	key: ['fan_mode'],
	convertSet: async (entity, key, value, meta) => {
		if(value == "low") {
			await tuya.sendDataPointEnum(entity, 28, 0);
		} else if(value == "medium") {
			await tuya.sendDataPointEnum(entity, 28, 1);
		} else if(value == "high") {
			await tuya.sendDataPointEnum(entity, 28, 2);			
		} else if(value == "auto") {
			await tuya.sendDataPointEnum(entity, 28, 3);			
		}
	},
};

module.exports = [
    {
        fingerprint: [{modelID: 'TS0601', manufacturerName: '_TZE200_dzuqwsyg'}],
        model: 'BAC-002-ALZB',
        vendor: 'HKGK',
        description: 'BAC series thermostat',
        fromZigbee: [fz_moes_thermostat_custom],
        toZigbee: [tz_system_mode, tz_fan_mode, tz_temperature_setpoint, tz.moes_thermostat_child_lock, tz.moes_thermostat_current_heating_setpoint, tz.moes_thermostat_mode,
            tz.hgkg_thermostat_standby, tz.moes_thermostat_sensor, tz.moes_thermostat_calibration,
            tz.moes_thermostat_deadzone_temperature, tz.moes_thermostat_max_temperature_limit],
        exposes: [e.child_lock(), e.deadzone_temperature(), e.max_temperature_limit(),
			//exposes.switch()
			//	.withState('state', false, 'OFF/ON state'),
            exposes.climate()
				.withSetpoint('occupied_heating_setpoint', 16, 35, 1, ea.STATE_SET)
                .withLocalTemperature(ea.STATE)
				.withLocalTemperatureCalibration(ea.STATE_SET)
                .withSystemMode(['off', 'cool', 'heat', 'fan_only'], ea.STATE_SET)
				.withFanMode(['low', 'medium', 'high', 'auto'], ea.STATE_SET)
				.withRunningState(['idle', 'heat', 'cool'], ea.STATE)
                .withPreset(['hold', 'program'])
				.withSensor(['IN', 'AL', 'OU'], ea.STATE_SET)],
        onEvent: tuya.onEventSetLocalTime,
    },
];

Supported color modes

No response

Color temperature range

No response

hanfreakingsolo avatar Sep 01 '22 21:09 hanfreakingsolo

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Oct 02 '22 00:10 github-actions[bot]

Anyone able to help with this?

hanfreakingsolo avatar Oct 02 '22 16:10 hanfreakingsolo

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Nov 03 '22 00:11 github-actions[bot]

Not stale, please help

hanfreakingsolo avatar Nov 03 '22 03:11 hanfreakingsolo

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Dec 05 '22 00:12 github-actions[bot]

I have the same problem, can anyone help us?

MBrognoli avatar Jan 12 '23 16:01 MBrognoli

Ok changes to the herdsman converters have messed this up even more. Please help, my thermostat is now showing -6000 room temp

hanfreakingsolo avatar Mar 28 '23 01:03 hanfreakingsolo