Created
March 23, 2022 10:36
-
-
Save JohnMcLear/a703974255768bf26479a2b523fe95eb to your computer and use it in GitHub Desktop.
Miboxerr zigbee2mqtt external converter addresses TS0505B model and TZ3210 vendor firmware requirements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const exposes = require('zigbee-herdsman-converters/lib/exposes'); | |
const globalStore = require('zigbee-herdsman-converters/lib/store'); | |
const ota = require('zigbee-herdsman-converters/lib/ota'); | |
const extend = require('zigbee-herdsman-converters/lib/extend'); | |
const utils = require('zigbee-herdsman-converters/lib/utils'); | |
const tz = require('zigbee-herdsman-converters/converters/toZigbee'); | |
const e = exposes.presets; | |
const gledoptoExtend = { | |
light_onoff_brightness: (options={}) => ({ | |
...extend.light_onoff_brightness(options), | |
toZigbee: utils.replaceInArray( | |
extend.light_onoff_brightness(options).toZigbee, | |
[tz.light_onoff_brightness], | |
[tz.gledopto_light_onoff_brightness], | |
), | |
}), | |
light_onoff_brightness_colortemp: (options={}) => ({ | |
...extend.light_onoff_brightness_colortemp(options), | |
toZigbee: utils.replaceInArray( | |
extend.light_onoff_brightness_colortemp(options).toZigbee, | |
[tz.light_onoff_brightness, tz.light_colortemp], | |
[tz.gledopto_light_onoff_brightness, tz.gledopto_light_colortemp], | |
), | |
}), | |
light_onoff_brightness_color: (options={}) => ({ | |
...extend.light_onoff_brightness_color({...options, supportsHS: true}), | |
toZigbee: utils.replaceInArray( | |
extend.light_onoff_brightness_color(options).toZigbee, | |
[tz.light_onoff_brightness, tz.light_color], | |
[tz.gledopto_light_onoff_brightness, tz.gledopto_light_color], | |
), | |
}), | |
light_onoff_brightness_colortemp_color: (options={}) => ({ | |
...extend.light_onoff_brightness_colortemp_color({...options, supportsHS: true}), | |
toZigbee: utils.replaceInArray( | |
extend.light_onoff_brightness_colortemp_color(options).toZigbee, | |
[tz.light_onoff_brightness, tz.light_color_colortemp], | |
[tz.gledopto_light_onoff_brightness, tz.gledopto_light_color_colortemp], | |
), | |
}), | |
switch: (options={}) => ({ | |
...extend.switch(options), | |
onEvent: async (type, data, device) => { | |
// This device doesn't support reporting. | |
// Therefore we read the on/off state every 5 seconds. | |
// This is the same way as the Hue bridge does it. | |
if (type === 'stop') { | |
clearInterval(globalStore.getValue(device, 'interval')); | |
globalStore.clearValue(device, 'interval'); | |
} else if (!globalStore.hasValue(device, 'interval')) { | |
const interval = setInterval(async () => { | |
try { | |
await device.endpoints[0].read('genOnOff', ['onOff']); | |
} catch (error) { | |
// Do nothing | |
} | |
}, 5000); | |
globalStore.putValue(device, 'interval', interval); | |
} | |
}, | |
}), | |
}; | |
const configureReadModelID = async (device, coordinatorEndpoint, logger) => { | |
// https://github.com/Koenkk/zigbee-herdsman-converters/issues/3016#issuecomment-1027726604 | |
const endpoint = device.endpoints[0]; | |
const oldModel = device.modelID; | |
const newModel = (await endpoint.read('genBasic', ['modelId'])).modelId; | |
if (oldModel != newModel) { | |
logger.info(`Detected Gledopto device mode change, from '${oldModel}' to '${newModel}'`); | |
} | |
}; | |
module.exports = [ | |
{ | |
fingerprint: [ | |
{type: 'Router', manufacturerName: '_TZ3210_leyz4rju', modelID: 'TS0505B', endpoints: [ | |
{ID: 11, profileID: 49246, deviceID: 528, inputClusters: [0, 3, 4, 5, 6, 8, 768], outputClusters: []}, | |
{ID: 13, profileID: 49246, deviceID: 528, inputClusters: [4096], outputClusters: [4096]}, | |
]}, | |
], | |
model: 'TS0505B', | |
vendor: '_TZ3210_leyz4rju', | |
description: 'Zigbee RF Hub', | |
extend: gledoptoExtend.light_onoff_brightness_colortemp_color(), | |
}, | |
{ | |
zigbeeModel: ['TS0505B'], | |
model: 'TS0505B', | |
vendor: 'TZ3210_leyz4rju', | |
ota: ota.zigbeeOTA, | |
description: 'Zigbee garden light', | |
extend: gledoptoExtend.light_onoff_brightness_colortemp_color({colorTempRange: [150, 500]}), | |
} | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment