-
Platform information:
- Hardware: OrangePi PC
- OS: ARMBIAN
- Java Runtime Environment: 1.8
- openHAB version: 2
-
Issue of the topic: Good afternoon friends!
Today I wanted to turn the fan on and off by choosing the time on the slider.
I turn on the fan when a change occurs + create a timer. But if I decided to change the time during operation (increase or decrease), I reassigned the timer to a new off time, but my timer is not reassigned. Please tell me where there is good information about how to stop the timer, start, delete the timer object so that I can work well. -
Items configuration related to the issue
Dimmer Fan_kitchen "Timer [%d min.]"
- Sitemap configuration related to the issue
Slider item=Fan_kitchen minValue=0 maxValue=6 step=1 icon="fan"
- Rules code related to the issue
import org.openhab.model.script.actions.* import org.openhab.model.script.actions.Timer var Timer fantimer = null rule "Fan timer received" when Item Fan_kitchen received command then var fantime=(Fan_kitchen.state as DecimalType).intValue if(fantime < 1) { fantimer.cancel fantimer = null if(Fan_kitchen.state!="OFF"){ SonoffBasic_fankitchen.sendCommand(OFF) } } else { if(fantimer===null) { SonoffBasic_fankitchen.sendCommand(ON) fantimer = createTimer(now.plusMinutes(fantime), [| SonoffBasic_fankitchen.sendCommand(OFF) Fan_kitchen.sendCommand(0) ]) } else { fantimer.reschedule(now.plusMinutes(fantime), [| SonoffBasic_fankitchen.sendCommand(OFF) Fan_kitchen.sendCommand(0) ]) } } end rule "Item reset" when Item SonoffBasic_fankitchen received command OFF then Fan_kitchen.sendCommand(0) end
- If logs where generated please post these here using code fences:
18:20:34.989 [INFO ] [arthome.event.ItemStatePredictedEvent] - SonoffBasic_fankitchen predicted to become OFF 18:20:35.010 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'Fan_kitchen' received command 0 18:20:35.028 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'Fan timer received': cannot invoke method public abstract boolean org.eclipse.smarthome.model.script.actions.Timer.cancel() on null 18:20:44.529 [INFO ] [del.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'fan.rules', using it anyway: The use of wildcard imports is deprecated.