[SOLVED] Setting a timer (createTimer) using a slider value

Hi Guys,
I have a small problem that I cannot solve even with a lot of Internet search.

I am currently writing rules for my fish tank control via openhab. I’m trying to find the best way to make certain settings via the HabPanel. For example, I need timers whose length has to be changed occasionally. For this purpose I created a slider in the items:

File: virtual.items

Dimmer v_water_rf_timesilder “water refill time”

In the rules I access the slider
File: fishtank.rules

var runtime = v_water_rf_timesilder.state as DecimalType

logInfo(“FishtankRules:WaterRefill”, “Water refill was manually activated for {} seconds.”, runtime)

wftimer=createTimer(now.plusSeconds(runtime), [|

The command logInfo works as expected

The timer but not… I get an error message:

2019-05-10 17:11:59.043 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Manual Water Refill’: An error occurred during the script execution: Could not invoke method: org.joda.time.DateTime.plusSeconds(int) on instance: 2019-05-10T17:11:59.040+02:00

What am I doing wrong?

Cheers Gabriel

Translated with www.DeepL.com/Translator

The first question I have is under what circumstances do they need to be changed? Is there a fixed number of changes? Is there some event or criteria that could be sensed (e.g. it’s summer time) to automate these changes?

It looks like you tried to use code fences but didn’t use the right symbol. See How to use code fences.

The error is that now.plusSeconds requires a primitive int but runtime is a DecimalType. Try

wftimer=createTimer(now.plusSeconds(runtime.intValue), [|
1 Like

You’re the best Rich. It works with your sugestion!

To your question. You can solve the water control in an aquarium with 1, 2 or 3 float gauges. I have decided for 2 float gauges.

The control must be able to do two things.

  1. Refill water if the water level is too low
  2. Drain off water and refill (change water)

In my case the water level is regulated with one float gauge. If the float gauge is out of the water, water should be refilled for a certain time. E.g. for 30 seconds. And exactly for that I need it. Otherwise I would need another float gauge to switch off. This is not necessary if the refill speed is always the same.

I’m not a big aquarium person but couldn’t you refill the water until the float gauge that triggered telling you need to add water to the tank goes back as the water level raises?

It seems like one would only need one gauge. When it is “ON” add water until it goes “OFF”. I’m sure there is something else going on here.

I’m glad you got it working.

Sometimes things are more complicated than you think at first. :slight_smile: This cannot be answered adequately in two sentences.

As I mentioned before: There is a solution with one float gauge, two and three. And you want to do two things. 1. Fill up with water which has evaporated. 2. And change some water to stabilize the aquarium. Otherwise the water values will go through the roof. The aquarium poisons over time (depends on the type of filtration).

We’re just talking about refilling the water. This can be solved with one or two float gauges.

Case 1 float gauge:
The float gauge switches because it is out of the water. You have to be careful not to react immediately but to check if it is still out of the water after a short time. Because a wave would also switch it. This is not desirable. If you are sure that it is out of the water, you refill with water. When you refill it until the float gauge switches, it will happen again quickly. The system is instable! The refilled water will evaporate quickly and it must be refilled very soon. This is unacceptable. So - you pour a little more water into it. And there are two solutions for that.

Case 2 float gauges:
Now you can take a second float gauge and fill it up to there.

Case 1 with my delay slider solution:
Or you know how long you can fill water without overflowing the aquarium. And that’s exactly whyI need the adjustable time for. Because I didn’t want the second float gauge. And I forgot to mention it. I also need persistence. The value should not be lost when the computer is restarted. So that would be the one and two float gauge solution for refilling the water.

The water change is similar:
I can only use one float gauge. The same as in case the above. You pump off water for a certain time and then I let it refill according to the above rule.

You can take two float gauges. Then you pump the water up to the second and fill up to the first. All float gauges have different heights - of course.

You can take three float gauges. You pump down to the lowest float gauge. Then I fill up to the top. If the middle one falls out, then refilling is announced…