Rule engine - gradual increment/decrement, flip state

I have two feature requests to rule engine.

  1. As a user I would like to gradually increment/decrement decimal thing property by certain amount on event: particular use case is to increase lamp level by 1% on each button press.

  2. As a user I would like to flip thing boolean property on event: on/off lamp on each button press.

What are your thoughts? Does this rule engine extension fits into your vision?

I might be willing to help to implement it by providing PR if you can give me guides to start from.

Case 1 might be served better by an external script, using the Web Thing API.

Case 2 can be accomplished as such: https://github.com/mozilla-iot/gateway/issues/694#issuecomment-569439234

Why do you believe Case 1 might be served better by external script? And correct me if I am wrong but I think it would be more that “script” to keep web socket connection open and handle event loop and perform state update…

From UI point of view this will require adding two entries (increment by and decrement by) to drop down in the output thing along with set value; from implementation point view getting current state before performing increment/decrement.

Extending rule engine in such way may help implement “poor mans” dimming functionality to WebThings… and possibly even “proper” dimming with while button pressed perform increment with pulse timming delay for gradual dimming?

As for your suggestion for Case 2 I am aware of this solution but it requires two rules instead of single one;

Maybe it is not worth it… my suggested for “flip” is based on understanding while which puts the thing into certain state under True condition and switches it back as soon as False, or maybe I miss understood?

You can not try the Followers addon. It allows one property to follow the change in another. This includes reverse-follow (increase A as B decreases).

You can even customise the ranges that you want to have translated. So a small change in one value can lead to a large change in another, for example.