openhab-jrubyscripting 5.0.0.rc5 → 5.0.0.rc8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/lib/openhab/core/actions.rb +6 -6
  3. data/lib/openhab/core/dependency_tracking.rb +34 -0
  4. data/lib/openhab/core/entity_lookup.rb +132 -78
  5. data/lib/openhab/core/events/item_channel_link.rb +2 -2
  6. data/lib/openhab/core/events/item_command_event.rb +1 -1
  7. data/lib/openhab/core/events/item_event.rb +2 -2
  8. data/lib/openhab/core/events/item_state_changed_event.rb +1 -1
  9. data/lib/openhab/core/events/thing.rb +1 -1
  10. data/lib/openhab/core/items/accepted_data_types.rb +2 -2
  11. data/lib/openhab/core/items/contact_item.rb +1 -1
  12. data/lib/openhab/core/items/dimmer_item.rb +2 -2
  13. data/lib/openhab/core/items/generic_item.rb +45 -224
  14. data/lib/openhab/core/items/group_item.rb +5 -3
  15. data/lib/openhab/core/items/image_item.rb +2 -2
  16. data/lib/openhab/core/items/item.rb +219 -0
  17. data/lib/openhab/core/items/metadata/hash.rb +1 -1
  18. data/lib/openhab/core/items/persistence.rb +4 -5
  19. data/lib/openhab/core/items/provider.rb +2 -2
  20. data/lib/openhab/core/items/proxy.rb +68 -7
  21. data/lib/openhab/core/items/registry.rb +6 -6
  22. data/lib/openhab/core/items/semantics/enumerable.rb +6 -6
  23. data/lib/openhab/core/items/semantics.rb +8 -7
  24. data/lib/openhab/core/items.rb +2 -1
  25. data/lib/openhab/core/provider.rb +14 -7
  26. data/lib/openhab/core/rules/registry.rb +2 -2
  27. data/lib/openhab/core/rules.rb +1 -1
  28. data/lib/openhab/core/script_handling.rb +6 -6
  29. data/lib/openhab/core/things/channel.rb +1 -1
  30. data/lib/openhab/core/things/channel_uid.rb +2 -2
  31. data/lib/openhab/core/things/item_channel_link.rb +2 -2
  32. data/lib/openhab/core/things/links/provider.rb +2 -2
  33. data/lib/openhab/core/things/registry.rb +1 -1
  34. data/lib/openhab/core/things/thing.rb +1 -1
  35. data/lib/openhab/core/types/date_time_type.rb +4 -4
  36. data/lib/openhab/core/types/hsb_type.rb +2 -2
  37. data/lib/openhab/core/types/quantity_type.rb +1 -1
  38. data/lib/openhab/core/types.rb +1 -1
  39. data/lib/openhab/core/uid.rb +1 -1
  40. data/lib/openhab/core/value_cache.rb +188 -0
  41. data/lib/openhab/core.rb +57 -15
  42. data/lib/openhab/core_ext/ruby/symbol.rb +7 -0
  43. data/lib/openhab/dsl/items/builder.rb +17 -10
  44. data/lib/openhab/dsl/items/ensure.rb +5 -5
  45. data/lib/openhab/dsl/items/timed_command.rb +4 -4
  46. data/lib/openhab/dsl/rules/automation_rule.rb +53 -39
  47. data/lib/openhab/dsl/rules/builder.rb +128 -79
  48. data/lib/openhab/dsl/rules/guard.rb +5 -5
  49. data/lib/openhab/dsl/rules/name_inference.rb +20 -1
  50. data/lib/openhab/dsl/rules/rule_triggers.rb +3 -3
  51. data/lib/openhab/dsl/rules/terse.rb +1 -0
  52. data/lib/openhab/dsl/rules/triggers/changed.rb +26 -23
  53. data/lib/openhab/dsl/rules/triggers/command.rb +6 -5
  54. data/lib/openhab/dsl/rules/triggers/conditions/duration.rb +2 -2
  55. data/lib/openhab/dsl/rules/triggers/cron/cron.rb +2 -2
  56. data/lib/openhab/dsl/rules/triggers/cron/cron_handler.rb +6 -6
  57. data/lib/openhab/dsl/rules/triggers/updated.rb +5 -5
  58. data/lib/openhab/dsl/rules/triggers/watch/watch_handler.rb +11 -12
  59. data/lib/openhab/dsl/things/builder.rb +73 -14
  60. data/lib/openhab/dsl/version.rb +2 -2
  61. data/lib/openhab/dsl.rb +43 -17
  62. data/lib/openhab/log.rb +5 -5
  63. data/lib/openhab/rspec/configuration.rb +5 -5
  64. data/lib/openhab/rspec/example_group.rb +1 -1
  65. data/lib/openhab/rspec/helpers.rb +4 -4
  66. data/lib/openhab/rspec/hooks.rb +19 -1
  67. data/lib/openhab/rspec/karaf.rb +12 -19
  68. data/lib/openhab/rspec/suspend_rules.rb +2 -1
  69. metadata +7 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5963df56b31bb66f4d4cf5afa5927719d61740df847c5d5ff0965a188a73c62
4
- data.tar.gz: 0011f05f77383e9618844437bc63b55d02e62ed9a402d775a76dbc75d20a8334
3
+ metadata.gz: 7a08d2ec63be7c6f1049ddc92de20e0184a9c4e959c6a20e97ce9c9214520d94
4
+ data.tar.gz: 90178ba5a194cc91e24381c91bb691ddbafae498a033284a687698a8406c3b68
5
5
  SHA512:
6
- metadata.gz: ffdb129b03aac2d44365aa42a7f02889f5d8a20f662391b874cb795547b646d6d4f02d014284a73143862ca25f931f42429be012a25b645d02b1e713a02c073b
7
- data.tar.gz: ca9804074c3092c6bcff87ed17bffe4543ef95b3ef0c230d4767811a266d368210658f36968d4d42b6ed2f320a8935ab28363a318a6bd0d2a7d393afab67a29a
6
+ metadata.gz: 659647412602ecb689524f4f760f1b4f6f054617190ffb8adee922daeb5a715b75f6e245a062f250e18b9262dc27667f7081ed2ca168454552ae1ca12fd24e0b
7
+ data.tar.gz: ac977120af8e531f0471d9f17601e7b59de9c9f44a40379d069b50227c4ec6d9674ab6f5a7791afb79f90174b6e532de3846f45d6f270459a94b2e12ecb47917
@@ -5,7 +5,7 @@ module OpenHAB
5
5
  #
6
6
  # Access to global actions.
7
7
  #
8
- # All OpenHAB's actions including those provided by add-ons are available, notably:
8
+ # All openHAB's actions including those provided by add-ons are available, notably:
9
9
  # * Audio
10
10
  # * Voice
11
11
  # * Things
@@ -17,7 +17,7 @@ module OpenHAB
17
17
  # From add-ons, e.g.:
18
18
  # * Transformation
19
19
  # * PersistenceExtensions (see {Items::Persistence})
20
- # * NotificationAction (from [OpenHAB Cloud Connector](https://www.openhab.org/addons/integrations/openhabcloud/))
20
+ # * NotificationAction (from [openHAB Cloud Connector](https://www.openhab.org/addons/integrations/openhabcloud/))
21
21
  #
22
22
  # Global actions are available as "global" methods on {OpenHAB::DSL}, or
23
23
  # explicitly from this {Actions} module, or you can explicitly reference a
@@ -39,7 +39,7 @@ module OpenHAB
39
39
  #
40
40
  # play_stream 'example.com'
41
41
  #
42
- # @example Send a broadcast notification via the OpenHAB Cloud
42
+ # @example Send a broadcast notification via the openHAB Cloud
43
43
  # rule 'Send an alert' do
44
44
  # changed Alarm_Triggered, to: ON
45
45
  # run { notify 'Red Alert!' }
@@ -102,7 +102,7 @@ module OpenHAB
102
102
  #
103
103
  def notify(msg, email: nil, icon: nil, severity: nil)
104
104
  unless Actions.const_defined?(:NotificationAction)
105
- raise NoMethodError, "NotificationAction is not available. Please install the OpenHAB cloud addon"
105
+ raise NoMethodError, "NotificationAction is not available. Please install the openHAB cloud addon"
106
106
  end
107
107
 
108
108
  if email
@@ -113,7 +113,7 @@ module OpenHAB
113
113
  end
114
114
 
115
115
  #
116
- # Say text via OpenHAB Text-To-Speech service, Voice.say()
116
+ # Say text via openHAB Text-To-Speech service, Voice.say()
117
117
  #
118
118
  # @param text [String] The text to say
119
119
  # @param voice [String] Specify a particular voice to use
@@ -128,7 +128,7 @@ module OpenHAB
128
128
  end
129
129
 
130
130
  #
131
- # Play an audio file via OpenHAB sound service, Audio.playSound()
131
+ # Play an audio file via openHAB sound service, Audio.playSound()
132
132
  #
133
133
  # @param filename [String] The sound file to play
134
134
  # @param sink [String] Specify a particular sink to output the speech
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ if defined?($dependencyListener)
4
+ require "jruby"
5
+
6
+ klass = Class.new(org.jruby.util.collections.StringArraySet) do
7
+ def initialize(other)
8
+ super(JRuby.runtime)
9
+ other.each { |feature| append(feature) }
10
+ end
11
+
12
+ def append(name)
13
+ $dependencyListener.accept(name)
14
+
15
+ super
16
+ end
17
+ end
18
+
19
+ JRuby.runtime.load_service.class.field_accessor :loadedFeatures
20
+ JRuby.runtime.load_service.loadedFeatures = klass.new(JRuby.runtime.load_service.loadedFeatures)
21
+
22
+ loaded_specs = Gem.loaded_specs
23
+ loaded_specs.each_key do |gem|
24
+ $dependencyListener.accept("gem:#{gem}")
25
+ end
26
+
27
+ def loaded_specs.[]=(gem, _spec)
28
+ super
29
+
30
+ $dependencyListener.accept("gem:#{gem}")
31
+ end
32
+ else
33
+ logger.warn("Dependency listener not found; dependency tracking disabled.")
34
+ end
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ruby2_keywords"
4
+
3
5
  module OpenHAB
4
6
  module Core
5
7
  #
6
- # Manages access to OpenHAB entities
8
+ # Manages access to openHAB entities
7
9
  #
8
- # You can access OpenHAB items and things directly using their name, anywhere `EntityLookup` is available.
10
+ # You can access openHAB items and things directly using their name, anywhere `EntityLookup` is available.
9
11
  #
10
12
  # @note Thing UIDs are separated by a colon `:`. Since it is not a valid symbol for an identifier,
11
13
  # it must be replaced with an underscore `_`. So to access `astro:sun:home`, use `astro_sun_home`
@@ -16,7 +18,7 @@ module OpenHAB
16
18
  #
17
19
  # @example Accessing Items and Groups
18
20
  # gAll_Lights # Access the gAll_Lights group. It is the same as items["gAll_Lights"]
19
- # Kitchen_Light.on # The OpenHAB object for the Kitchen_Light item and send an ON command
21
+ # Kitchen_Light.on # The openHAB object for the Kitchen_Light item and send an ON command
20
22
  #
21
23
  # @example Accessing Things
22
24
  # smtp_mail_local.send_mail('me@example.com', 'Subject', 'Dear Person, ...')
@@ -24,110 +26,162 @@ module OpenHAB
24
26
  # things['smtp:mail:local'].send_mail('me@example.com', 'Subject', 'Dear Person, ...')
25
27
  #
26
28
  module EntityLookup
27
- #
28
- # Automatically looks up OpenHAB items and things in appropriate registries
29
- #
30
- # @return [GenericItem, Things::Thing, nil]
31
- #
32
- def method_missing(method, *args, &block)
33
- logger.trace("method missing, performing OpenHab Lookup for: #{method}")
34
- EntityLookup.lookup_entity(method) || super
35
- end
36
-
37
29
  # @!visibility private
38
- def respond_to_missing?(method_name, _include_private = false)
39
- logger.trace("Checking if OpenHAB entities exist for #{method_name}")
40
- method_name = method_name.to_s if method_name.is_a?(Symbol)
30
+ module ClassMethods
31
+ # @!attribute [w] create_dummy_items
32
+ # @return [true,false]
33
+ def create_dummy_items=(value)
34
+ @create_dummy_items = value
35
+ end
36
+
37
+ # @return [Boolean] if dummy items should be created in this context
38
+ def create_dummy_items?
39
+ @create_dummy_items
40
+ end
41
+
42
+ # @!visibility private
43
+ def inherited(klass)
44
+ super
45
+
46
+ EntityLookup.included(klass)
47
+ end
41
48
 
42
- method_name == "scriptLoaded" ||
43
- method_name == "scriptUnloaded" ||
44
- EntityLookup.lookup_entity(method_name) ||
49
+ # @!visibility private
50
+ def included(klass)
45
51
  super
52
+
53
+ EntityLookup.included(klass)
54
+ end
46
55
  end
47
56
 
48
- #
49
- # Looks up an OpenHAB entity
50
- # items are checked first, then things
51
- #
52
57
  # @!visibility private
53
- #
54
- # @param [String] name of entity to lookup in item or thing registry
55
- #
56
- # @return [GenericItem, Things::Thing, nil]
57
- #
58
- def self.lookup_entity(name)
59
- lookup_item(name) || lookup_thing_const(name)
58
+ def self.included(klass)
59
+ klass.singleton_class.prepend(ClassMethods)
60
+ klass.ancestors.each do |ancestor|
61
+ next unless ancestor.singleton_class.ancestors.include?(ClassMethods)
62
+ next if ancestor.create_dummy_items?.nil?
63
+
64
+ klass.create_dummy_items = ancestor.create_dummy_items?
65
+ break
66
+ end
60
67
  end
61
68
 
62
69
  #
63
- # Looks up a Thing in the OpenHAB registry
64
- #
65
- # @!visibility private
66
- #
67
- # @param [String] uid name of Thing to lookup in Thing registry
70
+ # Automatically looks up openHAB items and things in appropriate registries
68
71
  #
69
- # @return [Things::Thing, nil]
72
+ # @return [Item, Things::Thing, nil]
70
73
  #
71
- def self.lookup_thing(uid)
72
- logger.trace("Looking up thing '#{uid}'")
73
- uid = uid.to_s if uid.is_a?(Symbol)
74
+ ruby2_keywords def method_missing(method, *args)
75
+ return super unless args.empty? && !block_given?
74
76
 
75
- uid = Things::ThingUID.new(uid) unless uid.is_a?(Things::ThingUID)
76
- thing = $things.get(uid)
77
- return unless thing
77
+ logger.trace("method missing, performing openHAB Lookup for: #{method}")
78
+ EntityLookup.lookup_entity(method,
79
+ create_dummy_items: self.class.respond_to?(:create_dummy_items?) &&
80
+ self.class.create_dummy_items?) || super
81
+ end
78
82
 
79
- logger.trace("Retrieved Thing(#{thing}) from registry for uid: #{uid}")
80
- Things::Proxy.new(thing)
83
+ # @!visibility private
84
+ def respond_to_missing?(method, *)
85
+ logger.trace("Checking if openHAB entities exist for #{method}")
86
+ EntityLookup.lookup_entity(method) || super
81
87
  end
82
88
 
83
- #
84
- # Looks up a Thing in the OpenHAB registry replacing `_` with `:`
85
- #
86
89
  # @!visibility private
87
- #
88
- # @param [String] name of Thing to lookup in Thing registry
89
- #
90
- # @return [Things::Thing, nil]
91
- #
92
- def self.lookup_thing_const(name)
93
- name = name.to_s if name.is_a?(Symbol)
90
+ def instance_eval_with_dummy_items(&block)
91
+ DSL::ThreadLocal.thread_local(openhab_create_dummy_items: self.class.create_dummy_items?) do
92
+ instance_eval(&block)
93
+ end
94
+ end
95
+
96
+ class << self
97
+ #
98
+ # Looks up an openHAB entity
99
+ # items are checked first, then things
100
+ #
101
+ # @!visibility private
102
+ #
103
+ # @param [String] name of entity to lookup in item or thing registry
104
+ # @param [true, false] create_dummy_items If a dummy {Item} should be created if an actual item can't be found
105
+ #
106
+ # @return [Item, Things::Thing, nil]
107
+ #
108
+ def lookup_entity(name, create_dummy_items: false)
109
+ # make sure we have a nil return
110
+ create_dummy_items = nil if create_dummy_items == false
111
+ lookup_item(name) || lookup_thing_const(name) || (create_dummy_items && Items::Proxy.new(name.to_sym))
112
+ end
113
+
114
+ #
115
+ # Looks up a Thing in the openHAB registry
116
+ #
117
+ # @!visibility private
118
+ #
119
+ # @param [String] uid name of Thing to lookup in Thing registry
120
+ #
121
+ # @return [Things::Thing, nil]
122
+ #
123
+ def lookup_thing(uid)
124
+ logger.trace("Looking up thing '#{uid}'")
125
+ uid = uid.to_s if uid.is_a?(Symbol)
94
126
 
95
- if name.is_a?(String)
96
- # Thing UIDs have at least 3 segments, separated by `_`
97
- return if name.count("_") < 2
127
+ uid = Things::ThingUID.new(uid) unless uid.is_a?(Things::ThingUID)
128
+ thing = $things.get(uid)
129
+ return unless thing
98
130
 
99
- # Convert from _ syntax to :
100
- name = name.tr("_", ":")
131
+ logger.trace("Retrieved Thing(#{thing}) from registry for uid: #{uid}")
132
+ Things::Proxy.new(thing)
101
133
  end
102
- lookup_thing(name)
103
- end
104
134
 
105
- #
106
- # Lookup OpenHAB items in item registry
107
- #
108
- # @!visibility private
109
- #
110
- # @param [String] name of item to lookup
111
- #
112
- # @return [GenericItem, nil]
113
- #
114
- def self.lookup_item(name)
115
- logger.trace("Looking up item '#{name}'")
116
- name = name.to_s if name.is_a?(Symbol)
117
- item = $ir.get(name)
118
- Items::Proxy.new(item) unless item.nil?
135
+ #
136
+ # Looks up a Thing in the openHAB registry replacing `_` with `:`
137
+ #
138
+ # @!visibility private
139
+ #
140
+ # @param [String] name of Thing to lookup in Thing registry
141
+ #
142
+ # @return [Things::Thing, nil]
143
+ #
144
+ def lookup_thing_const(name)
145
+ name = name.to_s if name.is_a?(Symbol)
146
+
147
+ if name.is_a?(String)
148
+ # Thing UIDs have at least 3 segments, separated by `_`
149
+ return if name.count("_") < 2
150
+
151
+ # Convert from _ syntax to :
152
+ name = name.tr("_", ":")
153
+ end
154
+ lookup_thing(name)
155
+ end
156
+
157
+ #
158
+ # Lookup openHAB items in item registry
159
+ #
160
+ # @!visibility private
161
+ #
162
+ # @param [String] name of item to lookup
163
+ #
164
+ # @return [Item, nil]
165
+ #
166
+ def lookup_item(name)
167
+ logger.trace("Looking up item '#{name}'")
168
+ name = name.to_s if name.is_a?(Symbol)
169
+ item = $ir.get(name)
170
+ Items::Proxy.new(item) unless item.nil?
171
+ end
119
172
  end
120
173
  end
121
174
  end
122
175
  end
123
176
 
124
177
  #
125
- # Implements const_missing to return OpenHAB items or things if mapping to missing name if they exist
178
+ # Implements const_missing to return openHAB items or things if mapping to missing name if they exist
126
179
  #
127
180
  # @param [String] name Capital string that was not set as a constant and to be looked up
128
181
  #
129
- # @return [Object] OpenHAB Item or Thing if their name exist in OpenHAB item and thing regestries
182
+ # @return [Object] openHAB Item or Thing if their name exist in openHAB item and thing regestries
130
183
  #
131
184
  def Object.const_missing(name)
132
- OpenHAB::Core::EntityLookup.lookup_entity(name) || super
185
+ OpenHAB::Core::EntityLookup.lookup_entity(name,
186
+ create_dummy_items: Thread.current[:openhab_create_dummy_items]) || super
133
187
  end
@@ -7,7 +7,7 @@ module OpenHAB
7
7
 
8
8
  # Strictly speaking this class isn't an event, but it's accessed from an AbstractItemChannelLinkEvent
9
9
 
10
- # Adds methods to core OpenHAB ItemChannelLinkDTO to make it more natural in Ruby
10
+ # Adds methods to core openHAB ItemChannelLinkDTO to make it more natural in Ruby
11
11
  class ItemChannelLinkDTO
12
12
  #
13
13
  # @!attribute [r] item_name
@@ -17,7 +17,7 @@ module OpenHAB
17
17
 
18
18
  #
19
19
  # @!attribute [r] item
20
- # @return [GenericItem] The item that was linked or unlinked
20
+ # @return [Item] The item that was linked or unlinked
21
21
  #
22
22
  def item
23
23
  EntityLookup.lookup_item(itemName)
@@ -7,7 +7,7 @@ module OpenHAB
7
7
  module Events
8
8
  java_import org.openhab.core.items.events.ItemCommandEvent
9
9
 
10
- # Adds methods to core OpenHAB ItemCommandEvent to make it more natural in Ruby
10
+ # Adds methods to core openHAB ItemCommandEvent to make it more natural in Ruby
11
11
  class ItemCommandEvent < ItemEvent
12
12
  # @!attribute [r] command
13
13
  # @return [Type] The command sent to the item.
@@ -6,12 +6,12 @@ module OpenHAB
6
6
  java_import org.openhab.core.items.events.ItemEvent
7
7
 
8
8
  #
9
- # Adds methods to core OpenHAB ItemEvent to make it more natural in Ruby
9
+ # Adds methods to core openHAB ItemEvent to make it more natural in Ruby
10
10
  #
11
11
  class ItemEvent < AbstractEvent
12
12
  #
13
13
  # @!attribute [r] item
14
- # @return [GenericItem] The item that triggered this event.
14
+ # @return [Item] The item that triggered this event.
15
15
  #
16
16
  def item
17
17
  EntityLookup.lookup_item(item_name)
@@ -8,7 +8,7 @@ module OpenHAB
8
8
  java_import org.openhab.core.items.events.ItemStateChangedEvent
9
9
 
10
10
  #
11
- # Adds methods to core OpenHAB ItemStateChangedEvent to make it more natural in Ruby
11
+ # Adds methods to core openHAB ItemStateChangedEvent to make it more natural in Ruby
12
12
  #
13
13
  class ItemStateChangedEvent < ItemEvent
14
14
  include ItemState
@@ -7,7 +7,7 @@ module OpenHAB
7
7
 
8
8
  # Strictly speaking this class isn't an event, but it's accessed from an AbstractThingRegistryEvent
9
9
 
10
- # Adds methods to core OpenHAB AbstractThingDTO to make it more natural in Ruby
10
+ # Adds methods to core openHAB AbstractThingDTO to make it more natural in Ruby
11
11
  class AbstractThingDTO
12
12
  # @!method uid
13
13
  # The thing's UID
@@ -13,12 +13,12 @@ module OpenHAB
13
13
  end
14
14
 
15
15
  module AcceptedDataTypes
16
- # @see GenericItem#accepted_command_types
16
+ # @see Item#accepted_command_types
17
17
  def accepted_command_types
18
18
  super.map { |k| k.is_a?(java.lang.Class) ? k.ruby_class : k }
19
19
  end
20
20
 
21
- # @see GenericItem#accepted_data_types
21
+ # @see Item#accepted_data_types
22
22
  def accepted_data_types
23
23
  super.map { |k| k.is_a?(java.lang.Class) ? k.ruby_class : k }
24
24
  end
@@ -18,7 +18,7 @@ module OpenHAB
18
18
  #
19
19
  # @example
20
20
  # rule 'Log state of all doors on system startup' do
21
- # on_start
21
+ # on_load
22
22
  # run do
23
23
  # Doors.each do |door|
24
24
  # case door.state
@@ -48,7 +48,7 @@ module OpenHAB
48
48
  #
49
49
  # @example
50
50
  # rule 'Dim a switch on system startup over 100 seconds' do
51
- # on_start
51
+ # on_load
52
52
  # 100.times do
53
53
  # run { DimmerSwitch.dim }
54
54
  # delay 1.second
@@ -57,7 +57,7 @@ module OpenHAB
57
57
  #
58
58
  # @example
59
59
  # rule 'Dim a switch on system startup by 5, pausing every second' do
60
- # on_start
60
+ # on_load
61
61
  # 100.step(-5, 0) do |level|
62
62
  # run { DimmerSwitch << level }
63
63
  # delay 1.second