openhab-scripting 2.14.1 → 2.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/openhab.rb +3 -0
  3. data/lib/openhab/core/dsl/actions.rb +1 -1
  4. data/lib/openhab/core/dsl/entities.rb +41 -4
  5. data/lib/openhab/core/dsl/gems.rb +1 -1
  6. data/lib/openhab/core/dsl/group.rb +3 -1
  7. data/lib/openhab/core/dsl/items/items.rb +3 -1
  8. data/lib/openhab/core/dsl/items/number_item.rb +151 -50
  9. data/lib/openhab/core/dsl/items/string_item.rb +21 -3
  10. data/lib/openhab/core/dsl/monkey_patch/items/metadata.rb +66 -42
  11. data/lib/openhab/core/dsl/monkey_patch/items/switch_item.rb +2 -1
  12. data/lib/openhab/core/dsl/monkey_patch/ruby/range.rb +2 -1
  13. data/lib/openhab/core/dsl/property.rb +15 -4
  14. data/lib/openhab/core/dsl/rule/automation_rule.rb +348 -0
  15. data/lib/openhab/core/dsl/rule/guard.rb +43 -6
  16. data/lib/openhab/core/dsl/rule/rule.rb +80 -367
  17. data/lib/openhab/core/dsl/rule/rule_config.rb +153 -0
  18. data/lib/openhab/core/dsl/rule/triggers/changed.rb +145 -0
  19. data/lib/openhab/core/dsl/rule/{channel.rb → triggers/channel.rb} +22 -8
  20. data/lib/openhab/core/dsl/rule/triggers/command.rb +106 -0
  21. data/lib/openhab/core/dsl/rule/{cron.rb → triggers/cron.rb} +36 -14
  22. data/lib/openhab/core/dsl/rule/triggers/trigger.rb +126 -0
  23. data/lib/openhab/core/dsl/rule/triggers/updated.rb +100 -0
  24. data/lib/openhab/core/dsl/time_of_day.rb +50 -24
  25. data/lib/openhab/core/dsl/timers.rb +2 -6
  26. data/lib/openhab/core/dsl/types/quantity.rb +106 -69
  27. data/lib/openhab/core/log.rb +3 -8
  28. data/lib/openhab/core/startup_delay.rb +1 -0
  29. data/lib/openhab/osgi.rb +7 -0
  30. data/lib/openhab/version.rb +1 -1
  31. metadata +10 -6
  32. data/lib/openhab/core/dsl/rule/item.rb +0 -203
  33. data/lib/openhab/core/dsl/rule/triggers.rb +0 -77
@@ -1,77 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'securerandom'
4
-
5
- module OpenHAB
6
- module Core
7
- module DSL
8
- module Rule
9
- #
10
- # Class for creating and managing triggers
11
- #
12
- class Trigger
13
- java_import org.openhab.core.automation.util.TriggerBuilder
14
- java_import org.openhab.core.config.core.Configuration
15
-
16
- # @return [String] A channel event trigger
17
- CHANNEL_EVENT = 'core.ChannelEventTrigger'
18
-
19
- # @return [String] A thing status Change trigger
20
- THING_CHANGE = 'core.ThingStatusChangeTrigger'
21
-
22
- # @return [String] A thing status update trigger
23
- THING_UPDATE = 'core.ThingStatusUpdateTrigger'
24
-
25
- # @return [String] An item command trigger
26
- ITEM_COMMAND = 'core.ItemCommandTrigger'
27
-
28
- # @return [String] An item state update trigger
29
- ITEM_STATE_UPDATE = 'core.ItemStateUpdateTrigger'
30
-
31
- # @return [String] An item state change trigger
32
- ITEM_STATE_CHANGE = 'core.ItemStateChangeTrigger'
33
-
34
- # @return [String] A group state change trigger for items in the group
35
- GROUP_STATE_CHANGE = 'core.GroupStateChangeTrigger'
36
-
37
- # @return [String] A group state update trigger for items in the group
38
- GROUP_STATE_UPDATE = 'core.GroupStateUpdateTrigger'
39
-
40
- # @return [String] A group command trigger for items in the group
41
- GROUP_COMMAND = 'core.GroupCommandTrigger'
42
-
43
- # @return [String] A time of day trigger
44
- TIME_OF_DAY = 'timer.TimeOfDayTrigger'
45
-
46
- # @return [String] A cron trigger
47
- CRON = 'timer.GenericCronTrigger'
48
-
49
- #
50
- # Create a trigger
51
- #
52
- # @param [String] type of trigger
53
- # @param [Map] config map
54
- #
55
- # @return [OpenHAB Trigger] configured by type and supplied config
56
- #
57
- def self.trigger(type:, config:)
58
- TriggerBuilder.create
59
- .with_id(uuid)
60
- .with_type_uid(type)
61
- .with_configuration(Configuration.new(config))
62
- .build
63
- end
64
-
65
- #
66
- # Generate a UUID for triggers
67
- #
68
- # @return [String] UUID
69
- #
70
- def self.uuid
71
- SecureRandom.uuid
72
- end
73
- end
74
- end
75
- end
76
- end
77
- end