Class: OpenHAB::DSL::Things::ChannelBuilder
- Inherits:
-
Object
- Object
- OpenHAB::DSL::Things::ChannelBuilder
- Defined in:
- lib/openhab/dsl/things/builder.rb
Overview
The ChannelBuilder DSL allows you to customize a channel
Instance Attribute Summary collapse
-
#accepted_item_type ⇒ Object
readonly
Returns the value of attribute accepted_item_type.
-
#auto_update_policy ⇒ Object
readonly
Returns the value of attribute auto_update_policy.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#default_tags ⇒ Object
readonly
Returns the value of attribute default_tags.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#label ⇒ Object
Returns the value of attribute label.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Instance Method Summary collapse
-
#initialize(uid, type, label = nil, thing:, description: nil, group: nil, config: nil, properties: nil, default_tags: nil, auto_update_policy: nil, accepted_item_type: nil) ⇒ ChannelBuilder
constructor
Constructor for ChannelBuilder.
Constructor Details
#initialize(uid, type, label = nil, thing:, description: nil, group: nil, config: nil, properties: nil, default_tags: nil, auto_update_policy: nil, accepted_item_type: nil) ⇒ ChannelBuilder
Constructor for ChannelBuilder
This class is instantiated by the #channel method inside a Builder#thing block.
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/openhab/dsl/things/builder.rb', line 289 def initialize(uid, type, label = nil, thing:, description: nil, group: nil, config: nil, properties: nil, default_tags: nil, auto_update_policy: nil, accepted_item_type: nil) @thing = thing uid = uid.to_s uid_segments = uid.split(org.openhab.core.common.AbstractUID::SEPARATOR) group_segments = uid_segments.last.split(org.openhab.core.thing.ChannelUID::CHANNEL_GROUP_SEPARATOR) if group if group_segments.length == 2 group_segments[0] = group else group_segments.unshift(group) end uid_segments[-1] = group_segments.join(org.openhab.core.thing.ChannelUID::CHANNEL_GROUP_SEPARATOR) end @uid = org.openhab.core.thing.ChannelUID.new(thing.uid, uid_segments.last) unless type.is_a?(org.openhab.core.thing.type.ChannelTypeUID) type = org.openhab.core.thing.type.ChannelTypeUID.new(thing.uid.binding_id, type) end @type = type @label = label @config = config&.transform_keys(&:to_s) @default_tags = Items::ItemBuilder.normalize_tags(*Array.wrap(default_tags)) @properties = properties&.transform_keys(&:to_s) @description = description @accepted_item_type = accepted_item_type return unless auto_update_policy @auto_update_policy = org.openhab.core.thing.type.AutoUpdatePolicy.value_of(auto_update_policy.to_s.upcase) end |
Instance Attribute Details
#accepted_item_type ⇒ Object (readonly)
Returns the value of attribute accepted_item_type.
260 261 262 |
# File 'lib/openhab/dsl/things/builder.rb', line 260 def accepted_item_type @accepted_item_type end |
#auto_update_policy ⇒ Object (readonly)
Returns the value of attribute auto_update_policy.
260 261 262 |
# File 'lib/openhab/dsl/things/builder.rb', line 260 def auto_update_policy @auto_update_policy end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
260 261 262 |
# File 'lib/openhab/dsl/things/builder.rb', line 260 def config @config end |
#default_tags ⇒ Object (readonly)
Returns the value of attribute default_tags.
260 261 262 |
# File 'lib/openhab/dsl/things/builder.rb', line 260 def default_tags @default_tags end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
260 261 262 |
# File 'lib/openhab/dsl/things/builder.rb', line 260 def description @description end |
#label ⇒ Object
Returns the value of attribute label.
259 260 261 |
# File 'lib/openhab/dsl/things/builder.rb', line 259 def label @label end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
260 261 262 |
# File 'lib/openhab/dsl/things/builder.rb', line 260 def properties @properties end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
260 261 262 |
# File 'lib/openhab/dsl/things/builder.rb', line 260 def type @type end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
260 261 262 |
# File 'lib/openhab/dsl/things/builder.rb', line 260 def uid @uid end |