Skip to content

Commit

Permalink
fix: TS refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Jun 2, 2023
1 parent d498494 commit cdbca3a
Show file tree
Hide file tree
Showing 184 changed files with 1,546 additions and 1,193 deletions.
2 changes: 1 addition & 1 deletion scripts/devicesTSrefactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ for (const file of fs.readdirSync('./src/devices').sort()) {

cnt++;

if (cnt == 10) {
if (cnt == 1000) {
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const fz = require('../converters/fromZigbee');
const tz = require('../converters/toZigbee');
const exposes = require('../lib/exposes');
const reporting = require('../lib/reporting');
import fz from '../converters/fromZigbee';
import tz from '../converters/toZigbee';
import * as exposes from '../lib/exposes';
import reporting from '../lib/reporting';
const e = exposes.presets;

module.exports = [
const definitions: Definition[] = [
{
zigbeeModel: ['E-Wand'],
model: 'CP180335E-01',
Expand All @@ -22,3 +22,5 @@ module.exports = [
exposes: [e.battery(), e.cover_tilt()],
},
];

module.exports = definitions;
6 changes: 4 additions & 2 deletions src/devices/cy-lighting.js → src/devices/cy-lighting.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const extend = require('../lib/extend');
import extend from '../lib/extend';

module.exports = [
const definitions: Definition[] = [
{
zigbeeModel: ['DM A60F'],
model: 'DM A60F',
Expand All @@ -9,3 +9,5 @@ module.exports = [
extend: extend.light_onoff_brightness(),
},
];

module.exports = definitions;
14 changes: 8 additions & 6 deletions src/devices/danalock.js → src/devices/danalock.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const exposes = require('../lib/exposes');
const fz = {...require('../converters/fromZigbee'), legacy: require('../lib/legacy').fromZigbee};
const tz = require('../converters/toZigbee');
const reporting = require('../lib/reporting');
const ota = require('../lib/ota');
import * as exposes from '../lib/exposes';
import fz from '../converters/fromZigbee';
import tz from '../converters/toZigbee';
import reporting from '../lib/reporting';
import ota from '../lib/ota';
const e = exposes.presets;

module.exports = [
const definitions: Definition[] = [
{
zigbeeModel: ['V3-BTZB', 'V3-BTZBE'],
model: 'V3-BTZB/V3-BTZBE',
Expand All @@ -24,3 +24,5 @@ module.exports = [
exposes: [e.lock(), e.battery(), e.pincode(), e.lock_action(), e.lock_action_source_name(), e.lock_action_user()],
},
];

module.exports = definitions;
88 changes: 45 additions & 43 deletions src/devices/danfoss.js → src/devices/danfoss.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const exposes = require('../lib/exposes');
const fz = {...require('../converters/fromZigbee'), legacy: require('../lib/legacy').fromZigbee};
const tz = require('../converters/toZigbee');
const ota = require('../lib/ota');
const constants = require('../lib/constants');
const reporting = require('../lib/reporting');
import * as exposes from '../lib/exposes';
import fz from '../converters/fromZigbee';
import tz from '../converters/toZigbee';
import ota from '../lib/ota';
import constants from '../lib/constants';
import reporting from '../lib/reporting';
const e = exposes.presets;
const ea = exposes.access;

module.exports = [
const definitions: Definition[] = [
{
// eTRV0100 is the same as Hive TRV001 and Popp eT093WRO. If implementing anything, please consider
// changing those two too.
Expand All @@ -30,32 +30,32 @@ module.exports = [
tz.danfoss_adaptation_control, tz.danfoss_regulation_setpoint_offset,
tz.danfoss_thermostat_occupied_heating_setpoint_scheduled],
exposes: [e.battery(), e.keypad_lockout(), e.programming_operation_mode(),
exposes.binary('mounted_mode_active', ea.STATE_GET, true, false)
e.binary('mounted_mode_active', ea.STATE_GET, true, false)
.withDescription('Is the unit in mounting mode. This is set to `false` for mounted (already on ' +
'the radiator) or `true` for not mounted (after factory reset)'),
exposes.binary('mounted_mode_control', ea.ALL, true, false)
e.binary('mounted_mode_control', ea.ALL, true, false)
.withDescription('Set the unit mounting mode. `false` Go to Mounted Mode or `true` Go to Mounting Mode'),
exposes.binary('thermostat_vertical_orientation', ea.ALL, true, false)
e.binary('thermostat_vertical_orientation', ea.ALL, true, false)
.withDescription('Thermostat Orientation. This is important for the PID in how it assesses temperature. ' +
'`false` Horizontal or `true` Vertical'),
exposes.binary('viewing_direction', ea.ALL, true, false)
e.binary('viewing_direction', ea.ALL, true, false)
.withDescription('Viewing/display direction, `false` normal or `true` upside-down'),
exposes.binary('heat_available', ea.ALL, true, false)
e.binary('heat_available', ea.ALL, true, false)
.withDescription('Not clear how this affects operation. However, it would appear that the device does not execute any ' +
'motor functions if this is set to false. This may be a means to conserve battery during periods that the heating ' +
'system is not energized (e.g. during summer). `false` No Heat Available or `true` Heat Available'),
exposes.binary('heat_required', ea.STATE_GET, true, false)
e.binary('heat_required', ea.STATE_GET, true, false)
.withDescription('Whether or not the unit needs warm water. `false` No Heat Request or `true` Heat Request'),
exposes.enum('setpoint_change_source', ea.STATE, ['manual', 'schedule', 'externally'])
e.enum('setpoint_change_source', ea.STATE, ['manual', 'schedule', 'externally'])
.withDescription('Values observed are `0` (manual), `1` (schedule) or `2` (externally)'),
exposes.climate().withSetpoint('occupied_heating_setpoint', 5, 35, 0.5).withLocalTemperature().withPiHeatingDemand()
e.climate().withSetpoint('occupied_heating_setpoint', 5, 35, 0.5).withLocalTemperature().withPiHeatingDemand()
.withSystemMode(['heat']).withRunningState(['idle', 'heat'], ea.STATE),
exposes.numeric('occupied_heating_setpoint_scheduled', ea.ALL)
e.numeric('occupied_heating_setpoint_scheduled', ea.ALL)
.withValueMin(5).withValueMax(35).withValueStep(0.5).withUnit('°C')
.withDescription('Scheduled change of the setpoint. Alternative method for changing the setpoint. In the opposite ' +
'to occupied_heating_setpoint it does not trigger an aggressive response from the actuator. ' +
'(more suitable for scheduled changes)'),
exposes.numeric('external_measured_room_sensor', ea.ALL)
e.numeric('external_measured_room_sensor', ea.ALL)
.withDescription('The temperature sensor of the TRV is — due to its design — relatively close to the heat source ' +
'(i.e. the hot water in the radiator). Thus there are situations where the `local_temperature` measured by the ' +
'TRV is not accurate enough: If the radiator is covered behind curtains or furniture, if the room is rather big, or ' +
Expand All @@ -72,48 +72,48 @@ module.exports = [
'`External_measured_room_sensor` property to -8000 (disabled). You *should* set the `External_measured_room_sensor` ' +
'property *at most* every 5 minutes or every 0.1K change in measured room temperature.')
.withValueMin(-8000).withValueMax(3500),
exposes.binary('radiator_covered', ea.ALL, true, false)
e.binary('radiator_covered', ea.ALL, true, false)
.withDescription('Controls whether the TRV should solely rely on an external room sensor or operate in offset mode. ' +
'`false` = Auto Offset Mode (use this e.g. for exposed radiators) or `true` = Room Sensor Mode (use this e.g. for ' +
'covered radiators). Please note that this flag only controls how the TRV operates on the value of ' +
'`External_measured_room_sensor`; only setting this flag without setting the `External_measured_room_sensor` ' +
'has no (noticable?) effect.'),
exposes.binary('window_open_feature', ea.ALL, true, false)
e.binary('window_open_feature', ea.ALL, true, false)
.withDescription('Whether or not the window open feature is enabled'),
exposes.enum('window_open_internal', ea.STATE_GET,
e.enum('window_open_internal', ea.STATE_GET,
['quarantine', 'closed', 'hold', 'open', 'external_open'])
.withDescription('0=Quarantine, 1=Windows are closed, 2=Hold - Windows are maybe about to open, ' +
'3=Open window detected, 4=In window open state from external but detected closed locally'),
exposes.binary('window_open_external', ea.ALL, true, false)
e.binary('window_open_external', ea.ALL, true, false)
.withDescription('Set if the window is open or close. This setting will trigger a change in the internal ' +
'window and heating demand. `false` (windows are closed) or `true` (windows are open)'),
exposes.enum('day_of_week', ea.ALL,
e.enum('day_of_week', ea.ALL,
['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'away_or_vacation'])
.withDescription('Exercise day of week: 0=Sun...6=Sat, 7=undefined'),
exposes.numeric('trigger_time', ea.ALL).withValueMin(0).withValueMax(65535)
e.numeric('trigger_time', ea.ALL).withValueMin(0).withValueMax(65535)
.withDescription('Exercise trigger time. Minutes since midnight (65535=undefined). Range 0 to 1439'),
exposes.numeric('algorithm_scale_factor', ea.ALL).withValueMin(1).withValueMax(10)
e.numeric('algorithm_scale_factor', ea.ALL).withValueMin(1).withValueMax(10)
.withDescription('Scale factor of setpoint filter timeconstant ("aggressiveness" of control algorithm) '+
'1= Quick ... 5=Moderate ... 10=Slow'),
exposes.binary('load_balancing_enable', ea.ALL, true, false)
e.binary('load_balancing_enable', ea.ALL, true, false)
.withDescription('Whether or not the thermostat acts as standalone thermostat or shares load with other ' +
'thermostats in the room. The gateway must update load_room_mean if enabled.'),
exposes.numeric('load_room_mean', ea.ALL)
e.numeric('load_room_mean', ea.ALL)
.withDescription('Mean radiator load for room calculated by gateway for load balancing purposes (-8000=undefined)')
.withValueMin(-8000).withValueMax(2000),
exposes.numeric('load_estimate', ea.STATE_GET)
e.numeric('load_estimate', ea.STATE_GET)
.withDescription('Load estimate on this radiator')
.withValueMin(-8000).withValueMax(3600),
exposes.binary('preheat_status', ea.STATE_GET, true, false)
e.binary('preheat_status', ea.STATE_GET, true, false)
.withDescription('Specific for pre-heat running in Zigbee Weekly Schedule mode'),
exposes.enum('adaptation_run_status', ea.STATE_GET, ['none', 'in_progress', 'found', 'lost'])
e.enum('adaptation_run_status', ea.STATE_GET, ['none', 'in_progress', 'found', 'lost'])
.withDescription('Status of adaptation run: None (before first run), In Progress, Valve Characteristic Found, ' +
'Valve Characteristic Lost'),
exposes.binary('adaptation_run_settings', ea.ALL, true, false)
e.binary('adaptation_run_settings', ea.ALL, true, false)
.withDescription('Automatic adaptation run enabled (the one during the night)'),
exposes.enum('adaptation_run_control', ea.ALL, ['none', 'initiate_adaptation', 'cancel_adaptation'])
e.enum('adaptation_run_control', ea.ALL, ['none', 'initiate_adaptation', 'cancel_adaptation'])
.withDescription('Adaptation run control: Initiate Adaptation Run or Cancel Adaptation Run'),
exposes.numeric('regulation_setpoint_offset', ea.ALL)
e.numeric('regulation_setpoint_offset', ea.ALL)
.withDescription('Regulation SetPoint Offset in range -2.5°C to 2.5°C in steps of 0.1°C. Value 2.5°C = 25.')
.withValueMin(-25).withValueMax(25)],
ota: ota.zigbeeOTA,
Expand Down Expand Up @@ -251,35 +251,35 @@ module.exports = [
const epName = `l${i}`;
if (i!=16) {
features.push(e.battery().withEndpoint(epName));
features.push(exposes.climate().withSetpoint('occupied_heating_setpoint', 5, 35, 0.5)
features.push(e.climate().withSetpoint('occupied_heating_setpoint', 5, 35, 0.5)
.withLocalTemperature().withRunningState(['idle', 'heat']).withSystemMode(['heat']).withEndpoint(epName));
features.push(exposes.numeric('abs_min_heat_setpoint_limit', ea.STATE)
features.push(e.numeric('abs_min_heat_setpoint_limit', ea.STATE)
.withUnit('°C').withEndpoint(epName)
.withDescription('Absolute min temperature allowed on the device'));
features.push(exposes.numeric('abs_max_heat_setpoint_limit', ea.STATE)
features.push(e.numeric('abs_max_heat_setpoint_limit', ea.STATE)
.withUnit('°C').withEndpoint(epName)
.withDescription('Absolute max temperature allowed on the device'));
features.push(exposes.numeric('min_heat_setpoint_limit', ea.ALL)
features.push(e.numeric('min_heat_setpoint_limit', ea.ALL)
.withValueMin(4).withValueMax(35).withValueStep(0.5).withUnit('°C')
.withEndpoint(epName).withDescription('Min temperature limit set on the device'));
features.push(exposes.numeric('max_heat_setpoint_limit', ea.ALL)
features.push(e.numeric('max_heat_setpoint_limit', ea.ALL)
.withValueMin(4).withValueMax(35).withValueStep(0.5).withUnit('°C')
.withEndpoint(epName).withDescription('Max temperature limit set on the device'));
features.push(exposes.enum('setpoint_change_source', ea.STATE, ['manual', 'schedule', 'externally'])
features.push(e.enum('setpoint_change_source', ea.STATE, ['manual', 'schedule', 'externally'])
.withEndpoint(epName));
features.push(exposes.enum('output_status', ea.STATE_GET, ['inactive', 'active'])
features.push(e.enum('output_status', ea.STATE_GET, ['inactive', 'active'])
.withEndpoint(epName).withDescription('Danfoss Output Status [Active vs Inactive])'));
features.push(exposes.enum('room_status_code', ea.STATE_GET, ['no_error', 'missing_rt',
features.push(e.enum('room_status_code', ea.STATE_GET, ['no_error', 'missing_rt',
'rt_touch_error', 'floor_sensor_short_circuit', 'floor_sensor_disconnected'])
.withEndpoint(epName).withDescription('Thermostat status'));
} else {
features.push(exposes.enum('system_status_code', ea.STATE_GET, ['no_error', 'missing_expansion_board',
features.push(e.enum('system_status_code', ea.STATE_GET, ['no_error', 'missing_expansion_board',
'missing_radio_module', 'missing_command_module', 'missing_master_rail', 'missing_slave_rail_no_1',
'missing_slave_rail_no_2', 'pt1000_input_short_circuit', 'pt1000_input_open_circuit',
'error_on_one_or_more_output']).withEndpoint('l16').withDescription('Regulator Status'));
features.push(exposes.enum('system_status_water', ea.STATE_GET, ['hot_water_flow_in_pipes', 'cool_water_flow_in_pipes'])
features.push(e.enum('system_status_water', ea.STATE_GET, ['hot_water_flow_in_pipes', 'cool_water_flow_in_pipes'])
.withEndpoint('l16').withDescription('Water Status of Regulator'));
features.push(exposes.enum('multimaster_role', ea.STATE_GET, ['invalid_unused', 'master', 'slave_1', 'slave_2'])
features.push(e.enum('multimaster_role', ea.STATE_GET, ['invalid_unused', 'master', 'slave_1', 'slave_2'])
.withEndpoint('l16').withDescription('Regulator role (Master vs Slave)'));
}
}
Expand Down Expand Up @@ -338,3 +338,5 @@ module.exports = [
},
},
];

module.exports = definitions;
4 changes: 3 additions & 1 deletion src/devices/digi.js → src/devices/digi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
const definitions: Definition[] = [
{
fingerprint: [{type: 'Router', manufacturerID: 4126, endpoints: [
{ID: 230, profileID: 49413, deviceID: 1, inputClusters: [], outputClusters: []},
Expand All @@ -12,3 +12,5 @@ module.exports = [
exposes: [],
},
];

module.exports = definitions;

0 comments on commit cdbca3a

Please sign in to comment.