Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

docs(timers): add cancelled? to the documentation #422

Merged
merged 1 commit into from
Nov 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions docs/usage/misc/timers.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ grand_parent: Usage
---

# Timers
Timers are created using the `after` method.

Timers are created using the `after` method.

After method parameters

| Parameter | Description |
|-----------|--------------------------------------------------------------------|
| --------- | ------------------------------------------------------------------ |
| duration | Duration for timer |
| id | Optional object that is used to identify the timer |
| block | Block to execute after duration, block will be passed timer object |


Timers with an id are reentrant, by id and block. Reentrant means that when the same id and block are encountered the timer is resheduled rather than creating a second new timer.


Timer Object
The timer object has all of the methods of the [OpenHAB Timer](https://www.openhab.org/docs/configuration/actions.html#timers) with a change to the reschedule method to enable it to operate Ruby context. The following methods are available to a Timer object:

Expand All @@ -31,13 +30,12 @@ The timer object has all of the methods of the [OpenHAB Timer](https://www.openh
| `execution_time` | | An alias for `Timer::getExecutionTime()`. Available in OpenHAB 3.1+ |
| `reschedule` | duration | Optional [duration](#Duration) if unspecified original duration supplied to `after` method is used |
| `active?` | | An alias for `Timer::isActive()` |
| `cancelled?` | | An alias for `Timer::isCancelled()`. Available in OpenHAB 3.2+ |
| `running?` | | An alias for `Timer::isRunning()` |
| `terminated?` | | An alias for `Timer::hasTerminated()` |


Timers
Timers with an id can be accessed via the timers[id] method. This method returns a set of timers associated with that id.

Timers with an id can be accessed via the timers[id] method. This method returns a set of timers associated with that id.

```ruby
after 5.seconds do
Expand Down Expand Up @@ -105,4 +103,3 @@ rule 'Cancel timer' do
on_start true
end
```