Skip to content

Commit

Permalink
fix: Fix state for some Tuya covers not updating Koenkk/zigbee2mqtt…
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Aug 27, 2024
1 parent 9acc033 commit f25b2bc
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/lib/tuya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
Range,
KeyValueNumberString,
DefinitionExposesFunction,
Publish,
} from './types';
import * as utils from './utils';
// import {Color} from './color';
Expand Down Expand Up @@ -548,16 +549,22 @@ export const valueConverter = {
to: async (v: number, meta: Tz.Meta) => {
return meta.options.invert_cover ? 100 - v : v;
},
from: (v: number, meta: Fz.Meta, options: KeyValue) => {
return options.invert_cover ? 100 - v : v;
from: (v: number, meta: Fz.Meta, options: KeyValue, publish: Publish) => {
const position = options.invert_cover ? 100 - v : v;
const closed = options.invert_cover ? position === 100 : position === 0;
publish({state: closed ? 'CLOSE' : 'OPEN'});
return position;
},
},
coverPositionInverted: {
to: async (v: number, meta: Tz.Meta) => {
return meta.options.invert_cover ? v : 100 - v;
},
from: (v: number, meta: Fz.Meta, options: KeyValue) => {
return options.invert_cover ? v : 100 - v;
from: (v: number, meta: Fz.Meta, options: KeyValue, publish: Publish) => {
const position = options.invert_cover ? v : 100 - v;
const closed = options.invert_cover ? position === 100 : position === 0;
publish({state: closed ? 'CLOSE' : 'OPEN'});
return position;
},
},
tubularMotorDirection: valueConverterBasic.lookup({normal: new Enum(0), reversed: new Enum(1)}),
Expand Down

0 comments on commit f25b2bc

Please sign in to comment.