Skip to content

Commit

Permalink
feat: TS refactor (#5804)
Browse files Browse the repository at this point in the history
* feat: TS refactor

* fix build

* u

* u
  • Loading branch information
Koenkk committed May 27, 2023
1 parent 5735246 commit 1b6d940
Show file tree
Hide file tree
Showing 28 changed files with 3,357 additions and 2,588 deletions.
2,337 changes: 63 additions & 2,274 deletions src/converters/fromZigbee.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/devices/alecto.js
Expand Up @@ -68,7 +68,7 @@ module.exports = [
model: 'SMART-HEAT10',
vendor: 'Alecto',
description: 'Radiator valve with thermostat',
fromZigbee: [fz.tuya_thermostat, fz.ignore_basic_report],
fromZigbee: [fz.legacy.tuya_thermostat, fz.ignore_basic_report],
meta: {tuyaThermostatSystemMode: tuya.thermostatSystemModes4, tuyaThermostatPreset: tuya.thermostatPresets,
tuyaThermostatPresetToSystemMode: tuya.thermostatSystemModes4},
toZigbee: [tz.tuya_thermostat_child_lock, tz.siterwell_thermostat_window_detection,
Expand Down
2 changes: 1 addition & 1 deletion src/devices/blitzwolf.js
Expand Up @@ -11,7 +11,7 @@ module.exports = [
model: 'BW-IS3',
vendor: 'BlitzWolf',
description: 'Rechargeable Zigbee PIR motion sensor',
fromZigbee: [fz.blitzwolf_occupancy_with_timeout],
fromZigbee: [fz.legacy.blitzwolf_occupancy_with_timeout],
toZigbee: [],
exposes: [e.occupancy()],
},
Expand Down
2 changes: 1 addition & 1 deletion src/devices/bseed.js
Expand Up @@ -10,7 +10,7 @@ module.exports = [
model: 'BSEED_TS0601_cover',
vendor: 'BSEED',
description: 'Zigbee curtain switch',
fromZigbee: [fz.tuya_cover],
fromZigbee: [fz.legacy.tuya_cover],
toZigbee: [tz.tuya_cover_control],
exposes: [e.cover_position().setAccess('position', ea.STATE_SET)],
},
Expand Down
2 changes: 1 addition & 1 deletion src/devices/connecte.js
Expand Up @@ -11,7 +11,7 @@ module.exports = [
model: '4500994',
vendor: 'Connecte',
description: 'Smart thermostat',
fromZigbee: [fz.connecte_thermostat],
fromZigbee: [fz.legacy.connecte_thermostat],
toZigbee: [tz.connecte_thermostat],
onEvent: tuya.onEventSetTime,
configure: tuya.configureMagicPacket,
Expand Down
4 changes: 2 additions & 2 deletions src/devices/evanell.js
@@ -1,5 +1,5 @@
const exposes = require('../lib/exposes');
const fz = require('../converters/fromZigbee');
const fz = {...require('../converters/fromZigbee'), legacy: require('../lib/legacy').fromZigbee};
const tz = require('../converters/toZigbee');
const tuya = require('../lib/tuya');
const reporting = require('../lib/reporting');
Expand All @@ -12,7 +12,7 @@ module.exports = [
model: 'EZ200',
vendor: 'Evanell',
description: 'Thermostatic radiator valve',
fromZigbee: [fz.evanell_thermostat],
fromZigbee: [fz.legacy.evanell_thermostat],
toZigbee: [tz.evanell_thermostat_current_heating_setpoint, tz.evanell_thermostat_system_mode,
tz.evanell_thermostat_child_lock],
onEvent: tuya.onEventSetTime,
Expand Down
4 changes: 2 additions & 2 deletions src/devices/fantem.js
Expand Up @@ -16,7 +16,7 @@ module.exports = [
description: 'Smart dimmer module',
extend: extend.light_onoff_brightness({noConfigure: true}),
fromZigbee: [...extend.light_onoff_brightness({noConfigure: true}).fromZigbee,
fz.command_on, fz.command_off, fz.command_move, fz.command_stop, fz.ZB006X_settings],
fz.command_on, fz.command_off, fz.command_move, fz.command_stop, fz.legacy.ZB006X_settings],
toZigbee: [...extend.light_onoff_brightness({noConfigure: true}).toZigbee, tz.ZB006X_settings],
exposes: [e.light_brightness(),
e.action(['on', 'off', 'brightness_move_down', 'brightness_move_up', 'brightness_stop']),
Expand Down Expand Up @@ -53,7 +53,7 @@ module.exports = [
model: 'ZB003-X',
vendor: 'Fantem',
description: '4 in 1 multi sensor',
fromZigbee: [fz.battery, fz.ignore_basic_report, fz.illuminance, fz.ZB003X, fz.ZB003X_attr, fz.ZB003X_occupancy],
fromZigbee: [fz.battery, fz.ignore_basic_report, fz.illuminance, fz.legacy.ZB003X, fz.ZB003X_attr, fz.ZB003X_occupancy],
toZigbee: [tz.ZB003X],
exposes: [e.occupancy(), e.tamper(), e.illuminance_lux(), e.illuminance(), e.temperature(), e.humidity(),
e.battery(), e.battery_voltage(),
Expand Down
2 changes: 1 addition & 1 deletion src/devices/frankever.js
Expand Up @@ -12,7 +12,7 @@ module.exports = [
model: 'FK_V02',
vendor: 'FrankEver',
description: 'Zigbee smart water valve',
fromZigbee: [fz.frankever_valve],
fromZigbee: [fz.legacy.frankever_valve],
toZigbee: [tz.tuya_switch_state, tz.frankever_threshold, tz.frankever_timer],
exposes: [e.switch().setAccess('state', ea.STATE_SET),
exposes.numeric('threshold', exposes.access.STATE_SET).withValueMin(0).withValueMax(100).withUnit('%')
Expand Down
2 changes: 1 addition & 1 deletion src/devices/hgkg.js
Expand Up @@ -12,7 +12,7 @@ module.exports = [
vendor: 'HKGK',
description: 'BAC series thermostat',
fromZigbee: [
fz.moes_thermostat,
fz.legacy.moes_thermostat,
fz.ignore_basic_report,
fz.ignore_tuya_set_time,
],
Expand Down
4 changes: 2 additions & 2 deletions src/devices/immax.js
Expand Up @@ -102,7 +102,7 @@ module.exports = [
model: '07703L',
vendor: 'Immax',
description: 'Radiator valve',
fromZigbee: [fz.legacy.tuya_thermostat_weekly_schedule, fz.etop_thermostat, fz.ignore_basic_report, fz.ignore_tuya_set_time],
fromZigbee: [fz.legacy.tuya_thermostat_weekly_schedule_1, fz.legacy.etop_thermostat, fz.ignore_basic_report, fz.ignore_tuya_set_time],
toZigbee: [tz.etop_thermostat_system_mode, tz.etop_thermostat_away_mode, tz.tuya_thermostat_child_lock,
tz.tuya_thermostat_current_heating_setpoint, tz.tuya_thermostat_weekly_schedule],
onEvent: tuya.onEventSetTime,
Expand Down Expand Up @@ -164,7 +164,7 @@ module.exports = [
model: '07502L',
vendor: 'Immax',
description: '4 in 1 multi sensor',
fromZigbee: [fz.battery, fz.ignore_basic_report, fz.illuminance, fz.ZB003X, fz.ZB003X_attr, fz.ZB003X_occupancy],
fromZigbee: [fz.battery, fz.ignore_basic_report, fz.illuminance, fz.legacy.ZB003X, fz.ZB003X_attr, fz.ZB003X_occupancy],
toZigbee: [tz.ZB003X],
exposes: [e.occupancy(), e.tamper(), e.battery(), e.illuminance(), e.illuminance_lux().withUnit('lx'), e.temperature(),
e.humidity(), exposes.numeric('reporting_time', ea.STATE_SET).withDescription('Reporting interval in minutes')
Expand Down
2 changes: 1 addition & 1 deletion src/devices/iotperfect.js
Expand Up @@ -14,7 +14,7 @@ module.exports = [
description: 'Smart water/gas valve',
extend: extend.switch(),
exposes: [e.switch().setAccess('state', ea.STATE_SET)],
fromZigbee: [fz.tuya_switch, fz.ignore_time_read, fz.ignore_basic_report],
fromZigbee: [fz.legacy.tuya_switch, fz.ignore_time_read, fz.ignore_basic_report],
toZigbee: [tz.tuya_switch_state],
},
];
2 changes: 1 addition & 1 deletion src/devices/javis.js
Expand Up @@ -24,7 +24,7 @@ module.exports = [
model: 'JS-MC-SENSOR-ZB',
vendor: 'JAVIS',
description: 'Microwave sensor',
fromZigbee: [fz.javis_microwave_sensor, fz.ignore_basic_report],
fromZigbee: [fz.legacy.javis_microwave_sensor, fz.ignore_basic_report],
toZigbee: [tz.javis_microwave_sensor],
exposes: [e.occupancy(), e.illuminance_lux(),
exposes.binary('led_enable', ea.STATE_SET, true, false).withDescription('Enabled LED'),
Expand Down
4 changes: 2 additions & 2 deletions src/devices/lidl.js
@@ -1,5 +1,5 @@
const exposes = require('../lib/exposes');
const fz = require('../converters/fromZigbee');
const fz = {...require('../converters/fromZigbee'), legacy: require('../lib/legacy').fromZigbee};
const tz = require('../converters/toZigbee');
const reporting = require('../lib/reporting');
const e = exposes.presets;
Expand Down Expand Up @@ -693,7 +693,7 @@ module.exports = [
vendor: 'Lidl',
description: 'Melinera smart LED string lights',
toZigbee: [tz.on_off, tz.silvercrest_smart_led_string],
fromZigbee: [fz.on_off, fz.silvercrest_smart_led_string],
fromZigbee: [fz.on_off, fz.legacy.silvercrest_smart_led_string],
exposes: [e.light_brightness_colorhs().setAccess('brightness', ea.STATE_SET).setAccess('color_hs', ea.STATE_SET)],
},
{
Expand Down
6 changes: 3 additions & 3 deletions src/devices/lonsonho.js
Expand Up @@ -65,7 +65,7 @@ module.exports = [
description: '1 gang switch',
extend: extend.switch(),
exposes: [e.switch().setAccess('state', ea.STATE_SET)],
fromZigbee: [fz.tuya_switch, fz.ignore_time_read],
fromZigbee: [fz.legacy.tuya_switch, fz.ignore_time_read],
toZigbee: [tz.tuya_switch_state],
},
{
Expand All @@ -76,7 +76,7 @@ module.exports = [
extend: extend.switch(),
exposes: [e.switch().withEndpoint('l1').setAccess('state', ea.STATE_SET),
e.switch().withEndpoint('l2').setAccess('state', ea.STATE_SET)],
fromZigbee: [fz.tuya_switch, fz.ignore_time_read],
fromZigbee: [fz.legacy.tuya_switch, fz.ignore_time_read],
toZigbee: [tz.tuya_switch_state],
meta: {multiEndpoint: true},
endpoint: (device) => {
Expand All @@ -92,7 +92,7 @@ module.exports = [
extend: extend.switch(),
exposes: [e.switch().withEndpoint('l1').setAccess('state', ea.STATE_SET),
e.switch().withEndpoint('l2').setAccess('state', ea.STATE_SET), e.switch().withEndpoint('l3').setAccess('state', ea.STATE_SET)],
fromZigbee: [fz.tuya_switch, fz.ignore_time_read],
fromZigbee: [fz.legacy.tuya_switch, fz.ignore_time_read],
toZigbee: [tz.tuya_switch_state],
meta: {multiEndpoint: true},
endpoint: (device) => {
Expand Down
16 changes: 8 additions & 8 deletions src/devices/moes.js
@@ -1,5 +1,5 @@
const exposes = require('../lib/exposes');
const fz = require('../converters/fromZigbee');
const fz = {...require('../converters/fromZigbee'), legacy: require('../lib/legacy').fromZigbee};
const tz = require('../converters/toZigbee');
const ota = require('../lib/ota');
const tuya = require('../lib/tuya');
Expand Down Expand Up @@ -103,7 +103,7 @@ module.exports = [
model: 'BHT-002-GCLZB',
vendor: 'Moes',
description: 'Moes BHT series Thermostat',
fromZigbee: [fz.moes_thermostat],
fromZigbee: [fz.legacy.moes_thermostat],
toZigbee: [tz.moes_thermostat_child_lock, tz.moes_thermostat_current_heating_setpoint, tz.moes_thermostat_mode,
tz.moes_thermostat_standby, tz.moes_thermostat_sensor, tz.moes_thermostat_calibration,
tz.moes_thermostat_deadzone_temperature, tz.moes_thermostat_max_temperature_limit, tz.moes_thermostat_min_temperature_limit,
Expand Down Expand Up @@ -164,7 +164,7 @@ module.exports = [
.withDescription('Indicator light status'),
exposes.enum('power_on_behavior', ea.STATE_SET, Object.values(tuya.moesSwitch.powerOnBehavior))
.withDescription('Controls the behavior when the device is powered on')],
fromZigbee: [fz.tuya_switch, fz.moes_switch],
fromZigbee: [fz.legacy.tuya_switch, fz.legacy.moes_switch],
toZigbee: [tz.tuya_switch_state, tz.moes_switch],
onEvent: tuya.onEventSetLocalTime,
configure: async (device, coordinatorEndpoint, logger) => {
Expand All @@ -185,7 +185,7 @@ module.exports = [
.withDescription('Indicator light status'),
exposes.enum('power_on_behavior', ea.STATE_SET, Object.values(tuya.moesSwitch.powerOnBehavior))
.withDescription('Controls the behavior when the device is powered on')],
fromZigbee: [fz.ignore_basic_report, fz.tuya_switch, fz.moes_switch],
fromZigbee: [fz.ignore_basic_report, fz.legacy.tuya_switch, fz.legacy.moes_switch],
toZigbee: [tz.tuya_switch_state, tz.moes_switch],
onEvent: tuya.onEventSetLocalTime,
meta: {multiEndpoint: true},
Expand Down Expand Up @@ -213,7 +213,7 @@ module.exports = [
.withDescription('Indicator light status'),
exposes.enum('power_on_behavior', ea.STATE_SET, Object.values(tuya.moesSwitch.powerOnBehavior))
.withDescription('Controls the behavior when the device is powered on')],
fromZigbee: [fz.ignore_basic_report, fz.tuya_switch, fz.moes_switch],
fromZigbee: [fz.ignore_basic_report, fz.legacy.tuya_switch, fz.legacy.moes_switch],
toZigbee: [tz.tuya_switch_state, tz.moes_switch],
onEvent: tuya.onEventSetLocalTime,
meta: {multiEndpoint: true},
Expand Down Expand Up @@ -243,7 +243,7 @@ module.exports = [
.withDescription('Indicator light status'),
exposes.enum('power_on_behavior', ea.STATE_SET, Object.values(tuya.moesSwitch.powerOnBehavior))
.withDescription('Controls the behavior when the device is powered on')],
fromZigbee: [fz.ignore_basic_report, fz.tuya_switch, fz.moes_switch],
fromZigbee: [fz.ignore_basic_report, fz.legacy.tuya_switch, fz.legacy.moes_switch],
toZigbee: [tz.tuya_switch_state, tz.moes_switch],
onEvent: tuya.onEventSetLocalTime,
meta: {multiEndpoint: true},
Expand Down Expand Up @@ -277,7 +277,7 @@ module.exports = [
description: 'Thermostatic radiator valve',
ota: ota.zigbeeOTA,
onEvent: tuya.onEventSetLocalTime,
fromZigbee: [fz.ignore_basic_report, fz.ignore_tuya_set_time, fz.moesS_thermostat],
fromZigbee: [fz.ignore_basic_report, fz.ignore_tuya_set_time, fz.legacy.moesS_thermostat],
toZigbee: [tz.moesS_thermostat_current_heating_setpoint, tz.moesS_thermostat_child_lock,
tz.moesS_thermostat_window_detection, tz.moesS_thermostat_temperature_calibration,
tz.moesS_thermostat_boost_heating, tz.moesS_thermostat_boostHeatingCountdownTimeSet,
Expand Down Expand Up @@ -339,7 +339,7 @@ module.exports = [
vendor: 'Moes',
description: 'Zigbee + RF curtain switch',
onEvent: tuya.onEventSetLocalTime,
fromZigbee: [fz.moes_cover, fz.ignore_basic_report],
fromZigbee: [fz.legacy.moes_cover, fz.ignore_basic_report],
toZigbee: [tz.moes_cover],
exposes: [e.cover_position().setAccess('position', ea.STATE_SET), exposes.enum('backlight', ea.STATE_SET, ['OFF', 'ON']),
exposes.enum('calibration', ea.STATE_SET, ['OFF', 'ON']), exposes.enum('motor_reversal', ea.STATE_SET, ['OFF', 'ON'])],
Expand Down
6 changes: 3 additions & 3 deletions src/devices/neo.js
Expand Up @@ -12,7 +12,7 @@ module.exports = [
model: 'NAS-AB02B0',
vendor: 'Neo',
description: 'Temperature & humidity sensor and alarm',
fromZigbee: [fz.neo_t_h_alarm, fz.ignore_basic_report, fz.ignore_tuya_set_time],
fromZigbee: [fz.legacy.neo_t_h_alarm, fz.ignore_basic_report, fz.ignore_tuya_set_time],
toZigbee: [tz.neo_t_h_alarm],
exposes: [
e.temperature(), e.humidity(), exposes.binary('humidity_alarm', ea.STATE_SET, true, false), e.battery_low(),
Expand Down Expand Up @@ -40,7 +40,7 @@ module.exports = [
model: 'NAS-AB02B2',
vendor: 'Neo',
description: 'Alarm',
fromZigbee: [fz.neo_alarm, fz.ignore_basic_report],
fromZigbee: [fz.legacy.neo_alarm, fz.ignore_basic_report],
toZigbee: [tz.neo_alarm],
exposes: [
e.battery_low(),
Expand All @@ -62,7 +62,7 @@ module.exports = [
model: 'NAS-PD07',
vendor: 'Neo',
description: 'Motion, temperature & humidity sensor',
fromZigbee: [fz.neo_nas_pd07, fz.ignore_tuya_set_time],
fromZigbee: [fz.legacy.neo_nas_pd07, fz.ignore_tuya_set_time],
toZigbee: [tz.neo_nas_pd07],
onEvent: tuya.onEventSetTime,
exposes: [e.occupancy(), e.humidity(), e.temperature(), e.tamper(), e.battery_low(),
Expand Down
4 changes: 2 additions & 2 deletions src/devices/nous.js
Expand Up @@ -23,7 +23,7 @@ module.exports = [
model: 'SZ-T04',
vendor: 'Nous',
description: 'Temperature and humidity sensor with clock',
fromZigbee: [fz.nous_lcd_temperature_humidity_sensor, fz.ignore_tuya_set_time],
fromZigbee: [fz.legacy.nous_lcd_temperature_humidity_sensor, fz.ignore_tuya_set_time],
toZigbee: [tz.nous_lcd_temperature_humidity_sensor],
onEvent: tuya.onEventSetLocalTime,
configure: async (device, coordinatorEndpoint, logger) => {
Expand Down Expand Up @@ -60,7 +60,7 @@ module.exports = [
model: 'E6',
vendor: 'Nous',
description: 'Temperature & humidity LCD sensor',
fromZigbee: [fz.nous_lcd_temperature_humidity_sensor, fz.ignore_tuya_set_time],
fromZigbee: [fz.legacy.nous_lcd_temperature_humidity_sensor, fz.ignore_tuya_set_time],
toZigbee: [tz.nous_lcd_temperature_humidity_sensor],
onEvent: tuya.onEventSetLocalTime,
configure: async (device, coordinatorEndpoint, logger) => {
Expand Down
4 changes: 2 additions & 2 deletions src/devices/novo.js
@@ -1,5 +1,5 @@
const exposes = require('../lib/exposes');
const fz = require('../converters/fromZigbee');
const fz = {...require('../converters/fromZigbee'), legacy: require('../lib/legacy').fromZigbee};
const tz = require('../converters/toZigbee');
const e = exposes.presets;
const ea = exposes.access;
Expand All @@ -10,7 +10,7 @@ module.exports = [
model: 'C10-3E-1.2',
vendor: 'Novo',
description: 'Curtain switch',
fromZigbee: [fz.tuya_cover, fz.ignore_basic_report],
fromZigbee: [fz.legacy.tuya_cover, fz.ignore_basic_report],
toZigbee: [tz.tuya_cover_control, tz.tuya_cover_options],
exposes: [e.cover_position().setAccess('position', ea.STATE_SET)],
},
Expand Down
4 changes: 2 additions & 2 deletions src/devices/rtx.js
@@ -1,4 +1,4 @@
const fz = require('../converters/fromZigbee');
const fz = {...require('../converters/fromZigbee'), legacy: require('../lib/legacy').fromZigbee};
const tz = require('../converters/toZigbee');
const exposes = require('../lib/exposes');
const tuya = require('../lib/tuya');
Expand All @@ -16,7 +16,7 @@ module.exports = [
vendor: 'RTX',
description: 'Zigbee smart water valve',
onEvent: tuya.onEventSetLocalTime,
fromZigbee: [fz.ZVG1, fz.ignore_basic_report],
fromZigbee: [fz.legacy.ZVG1, fz.ignore_basic_report],
toZigbee: [tz.tuya_switch_state, tz.ZVG1_weather_delay, tz.ZVG1_timer, tz.ZVG1_cycle_timer, tz.ZVG1_normal_schedule_timer],
exposes: [e.switch().setAccess('state', ea.STATE_SET), e.battery(),
exposes.enum('weather_delay', ea.STATE_SET, ['disabled', '24h', '48h', '72h']),
Expand Down
2 changes: 1 addition & 1 deletion src/devices/saswell.js
Expand Up @@ -31,7 +31,7 @@ module.exports = [
description: 'Thermostatic radiator valve',
whiteLabel: [{vendor: 'HiHome', model: 'WZB-TRVL'}, {vendor: 'Hama', model: '00176592'},
{vendor: 'RTX', model: 'ZB-RT1'}, {vendor: 'SETTI+', model: 'TRV001'}],
fromZigbee: [fz.saswell_thermostat, fz.ignore_tuya_set_time, fz.ignore_basic_report, fz.legacy.tuya_thermostat_weekly_schedule],
fromZigbee: [fz.legacy.saswell_thermostat, fz.ignore_tuya_set_time, fz.ignore_basic_report, fz.legacy.tuya_thermostat_weekly_schedule_1],
toZigbee: [tz.saswell_thermostat_current_heating_setpoint, tz.saswell_thermostat_mode, tz.saswell_thermostat_away,
tz.saswell_thermostat_child_lock, tz.saswell_thermostat_window_detection, tz.saswell_thermostat_frost_detection,
tz.saswell_thermostat_calibration, tz.saswell_thermostat_anti_scaling, tz.tuya_thermostat_weekly_schedule],
Expand Down
2 changes: 1 addition & 1 deletion src/devices/siterwell.js
Expand Up @@ -20,7 +20,7 @@ module.exports = [
model: 'GS361A-H04',
vendor: 'Siterwell',
description: 'Radiator valve with thermostat',
fromZigbee: [fz.tuya_thermostat, fz.ignore_basic_report],
fromZigbee: [fz.legacy.tuya_thermostat, fz.ignore_basic_report],
meta: {tuyaThermostatSystemMode: tuya.thermostatSystemModes4, tuyaThermostatPreset: tuya.thermostatPresets,
tuyaThermostatPresetToSystemMode: tuya.thermostatSystemModes4},
toZigbee: [tz.tuya_thermostat_child_lock, tz.siterwell_thermostat_window_detection, tz.tuya_thermostat_valve_detection,
Expand Down

0 comments on commit 1b6d940

Please sign in to comment.