Skip to content

Commit d6d94b0

Browse files
authored
[triggers] Add missing parameters to PWM trigger (#512)
Fixes #511. Signed-off-by: Florian Hotze <dev@florianhotze.com>
1 parent 6e28d76 commit d6d94b0

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/triggers.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,19 +323,23 @@ const GenericEventTrigger = (eventTopic, eventSource, eventTypes, triggerName) =
323323
* });
324324
*
325325
* @memberof triggers
326-
* @param {string} dutycycleItem Item (PercentType) to read the duty cycle from
326+
* @param {Item|string} dutycycleItemOrName the Item or name of the Item (PercentType) to read the duty cycle from
327327
* @param {number} interval constant interval in which the output is switch ON and OFF again (in sec)
328328
* @param {number} [minDutyCycle] any duty cycle below this value will be increased to this value
329329
* @param {number} [maxDutyCycle] any duty cycle above this value will be decreased to this value
330330
* @param {number} [deadManSwitch] output will be switched off, when the duty cycle is not updated within this time (in ms)
331+
* @param {boolean} [equateMinToZero=false] whether the duty cycle below `minDutyCycle` should be set to 0
332+
* @param {boolean} [equateMaxToHundred=true] whether the duty cycle above `maxDutyCycle` should be set to 100
331333
* @param {string} [triggerName] the optional name of the trigger to create
332334
*/
333-
const PWMTrigger = (dutycycleItem, interval, minDutyCycle, maxDutyCycle, deadManSwitch, triggerName) =>
335+
const PWMTrigger = (dutycycleItemOrName, interval, minDutyCycle, maxDutyCycle, deadManSwitch, equateMinToZero = false, equateMaxToHundred = true, triggerName) =>
334336
_createTrigger('pwm.trigger', triggerName, {
335-
dutycycleItem,
337+
dutycycleItem: _isItem(dutycycleItemOrName) ? dutycycleItemOrName.name : dutycycleItemOrName,
336338
interval,
337339
minDutyCycle,
340+
equateMinToZero,
338341
maxDutyCycle,
342+
equateMaxToHundred,
339343
deadManSwitch
340344
});
341345

test/triggers.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ describe('triggers.js', () => {
367367
minDutyCycle,
368368
maxDutyCycle,
369369
deadManSwitch,
370+
undefined,
371+
undefined,
370372
triggerName
371373
);
372374

@@ -379,7 +381,9 @@ describe('triggers.js', () => {
379381
dutycycleItem,
380382
interval,
381383
minDutyCycle,
384+
equateMinToZero: false,
382385
maxDutyCycle,
386+
equateMaxToHundred: true,
383387
deadManSwitch
384388
}
385389
})

types/triggers.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,16 @@ export function DateTimeTrigger(itemOrName: Item | string, timeOnly?: boolean, o
265265
* });
266266
*
267267
* @memberof triggers
268-
* @param {string} dutycycleItem Item (PercentType) to read the duty cycle from
268+
* @param {Item|string} dutycycleItemOrName the Item or name of the Item (PercentType) to read the duty cycle from
269269
* @param {number} interval constant interval in which the output is switch ON and OFF again (in sec)
270270
* @param {number} [minDutyCycle] any duty cycle below this value will be increased to this value
271271
* @param {number} [maxDutyCycle] any duty cycle above this value will be decreased to this value
272272
* @param {number} [deadManSwitch] output will be switched off, when the duty cycle is not updated within this time (in ms)
273+
* @param {boolean} [equateMinToZero=false] whether the duty cycle below `minDutyCycle` should be set to 0
274+
* @param {boolean} [equateMaxToHundred=true] whether the duty cycle above `maxDutyCycle` should be set to 100
273275
* @param {string} [triggerName] the optional name of the trigger to create
274276
*/
275-
export function PWMTrigger(dutycycleItem: string, interval: number, minDutyCycle?: number, maxDutyCycle?: number, deadManSwitch?: number, triggerName?: string): HostTrigger;
277+
export function PWMTrigger(dutycycleItemOrName: Item | string, interval: number, minDutyCycle?: number, maxDutyCycle?: number, deadManSwitch?: number, equateMinToZero?: boolean, equateMaxToHundred?: boolean, triggerName?: string): HostTrigger;
276278
/**
277279
* Creates a trigger for the {@link https://www.openhab.org/addons/automation/pidcontroller/ PID Controller Automation} add-on.
278280
*

types/triggers.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)