Skip to content

Commit

Permalink
Merge pull request athombv#123 from Drenso/fix-fan-dim-range
Browse files Browse the repository at this point in the history
Quick fix fan dim capability range
  • Loading branch information
bobvandevijver authored Aug 7, 2024
2 parents 9466cc2 + 81465e0 commit ce266fe
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions lib/TuyaOAuth2DriverFan.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TuyaOAuth2DriverFan extends TuyaOAuth2Driver {
// TODO
];

onTuyaPairListDeviceProperties(device) {
onTuyaPairListDeviceProperties(device, deviceSpecs) {
const props = super.onTuyaPairListDeviceProperties(device);

// onoff
Expand All @@ -27,14 +27,28 @@ class TuyaOAuth2DriverFan extends TuyaOAuth2Driver {
const hasFanSpeedPercent = device.status.some(({ code }) => code === 'fan_speed_percent');
if (hasFanSpeedPercent) {
props.capabilities.push('dim');
props.capabilitiesOptions = props.capabilitiesOptions ?? {};
props.capabilitiesOptions['dim'] = {
max: 1,
min: 1,
max: 6,
step: 1
};
}

// Device Specifications
for (const functionSpecification of specifications.functions) {
const tuyaCapability = functionSpecification.code;
const values = JSON.parse(functionSpecification.values);

if (tuyaCapability === 'fan_speed_percent') {
props.store.tuya_brightness = values;
props.capabilitiesOptions['dim'] = {
min: values.min ?? 1,
max: values.max ?? 100,
step: values.step ?? 1,
}
}
}

return props;
}

Expand Down

0 comments on commit ce266fe

Please sign in to comment.