Class: OpenHAB::Core::Things::Channel
- Inherits:
-
Object
- Object
- OpenHAB::Core::Things::Channel
- Defined in:
- lib/openhab/core/things/channel.rb
Overview
Instance Attribute Summary collapse
-
#item ⇒ Item?
readonly
Return the item if this channel is linked with an item.
-
#items ⇒ Array<Item>
readonly
Returns all of the channel's linked items.
-
#thing ⇒ Thing?
readonly
Return the thing this channel is associated with.
- #uid ⇒ ChannelUID readonly
Instance Method Summary collapse
Instance Attribute Details
#item ⇒ Item? (readonly)
Return the item if this channel is linked with an item. If a channel is linked to more than one item, this method only returns the first item.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/openhab/core/things/channel.rb', line 26 class Channel extend Forwardable delegate %i[item items thing] => :uid # @return [String] def inspect r = "#<OpenHAB::Core::Things::Channel #{uid}" r += " #{label.inspect}" if label r += " description=#{description.inspect}" if description r += " kind=#{kind.inspect}" r += " channel_type_uid=#{channel_type_uid.inspect}" if channel_type_uid r += " configuration=#{configuration.properties.to_h}" unless configuration.properties.empty? r += " properties=#{properties.to_h}" unless properties.empty? r += " default_tags=#{default_tags.to_a}" unless default_tags.empty? r += " auto_update_policy=#{auto_update_policy}" if auto_update_policy r += " accepted_item_type=#{accepted_item_type}" if accepted_item_type "#{r}>" end # @return [String] def to_s uid.to_s end # @deprecated OH3.4 this whole section is not needed in OH4+. Also see Thing#config_eql? if Gem::Version.new(Core::VERSION) < Gem::Version.new("4.0.0") # @!visibility private module ChannelComparable # @!visibility private # This is only needed in OH3 because it is implemented in OH4 core def ==(other) return true if equal?(other) return false unless other.is_a?(Channel) %i[class uid label description kind channel_type_uid configuration properties default_tags auto_update_policy accepted_item_type].all? do |attr| send(attr) == other.send(attr) end end end org.openhab.core.thing.binding.builder.ChannelBuilder.const_get(:ChannelImpl).prepend(ChannelComparable) end end |
#items ⇒ Array<Item> (readonly)
Returns all of the channel's linked items.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/openhab/core/things/channel.rb', line 26 class Channel extend Forwardable delegate %i[item items thing] => :uid # @return [String] def inspect r = "#<OpenHAB::Core::Things::Channel #{uid}" r += " #{label.inspect}" if label r += " description=#{description.inspect}" if description r += " kind=#{kind.inspect}" r += " channel_type_uid=#{channel_type_uid.inspect}" if channel_type_uid r += " configuration=#{configuration.properties.to_h}" unless configuration.properties.empty? r += " properties=#{properties.to_h}" unless properties.empty? r += " default_tags=#{default_tags.to_a}" unless default_tags.empty? r += " auto_update_policy=#{auto_update_policy}" if auto_update_policy r += " accepted_item_type=#{accepted_item_type}" if accepted_item_type "#{r}>" end # @return [String] def to_s uid.to_s end # @deprecated OH3.4 this whole section is not needed in OH4+. Also see Thing#config_eql? if Gem::Version.new(Core::VERSION) < Gem::Version.new("4.0.0") # @!visibility private module ChannelComparable # @!visibility private # This is only needed in OH3 because it is implemented in OH4 core def ==(other) return true if equal?(other) return false unless other.is_a?(Channel) %i[class uid label description kind channel_type_uid configuration properties default_tags auto_update_policy accepted_item_type].all? do |attr| send(attr) == other.send(attr) end end end org.openhab.core.thing.binding.builder.ChannelBuilder.const_get(:ChannelImpl).prepend(ChannelComparable) end end |
#thing ⇒ Thing? (readonly)
Return the thing this channel is associated with.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/openhab/core/things/channel.rb', line 26 class Channel extend Forwardable delegate %i[item items thing] => :uid # @return [String] def inspect r = "#<OpenHAB::Core::Things::Channel #{uid}" r += " #{label.inspect}" if label r += " description=#{description.inspect}" if description r += " kind=#{kind.inspect}" r += " channel_type_uid=#{channel_type_uid.inspect}" if channel_type_uid r += " configuration=#{configuration.properties.to_h}" unless configuration.properties.empty? r += " properties=#{properties.to_h}" unless properties.empty? r += " default_tags=#{default_tags.to_a}" unless default_tags.empty? r += " auto_update_policy=#{auto_update_policy}" if auto_update_policy r += " accepted_item_type=#{accepted_item_type}" if accepted_item_type "#{r}>" end # @return [String] def to_s uid.to_s end # @deprecated OH3.4 this whole section is not needed in OH4+. Also see Thing#config_eql? if Gem::Version.new(Core::VERSION) < Gem::Version.new("4.0.0") # @!visibility private module ChannelComparable # @!visibility private # This is only needed in OH3 because it is implemented in OH4 core def ==(other) return true if equal?(other) return false unless other.is_a?(Channel) %i[class uid label description kind channel_type_uid configuration properties default_tags auto_update_policy accepted_item_type].all? do |attr| send(attr) == other.send(attr) end end end org.openhab.core.thing.binding.builder.ChannelBuilder.const_get(:ChannelImpl).prepend(ChannelComparable) end end |
#uid ⇒ ChannelUID (readonly)
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/openhab/core/things/channel.rb', line 26 class Channel extend Forwardable delegate %i[item items thing] => :uid # @return [String] def inspect r = "#<OpenHAB::Core::Things::Channel #{uid}" r += " #{label.inspect}" if label r += " description=#{description.inspect}" if description r += " kind=#{kind.inspect}" r += " channel_type_uid=#{channel_type_uid.inspect}" if channel_type_uid r += " configuration=#{configuration.properties.to_h}" unless configuration.properties.empty? r += " properties=#{properties.to_h}" unless properties.empty? r += " default_tags=#{default_tags.to_a}" unless default_tags.empty? r += " auto_update_policy=#{auto_update_policy}" if auto_update_policy r += " accepted_item_type=#{accepted_item_type}" if accepted_item_type "#{r}>" end # @return [String] def to_s uid.to_s end # @deprecated OH3.4 this whole section is not needed in OH4+. Also see Thing#config_eql? if Gem::Version.new(Core::VERSION) < Gem::Version.new("4.0.0") # @!visibility private module ChannelComparable # @!visibility private # This is only needed in OH3 because it is implemented in OH4 core def ==(other) return true if equal?(other) return false unless other.is_a?(Channel) %i[class uid label description kind channel_type_uid configuration properties default_tags auto_update_policy accepted_item_type].all? do |attr| send(attr) == other.send(attr) end end end org.openhab.core.thing.binding.builder.ChannelBuilder.const_get(:ChannelImpl).prepend(ChannelComparable) end end |
Instance Method Details
#inspect ⇒ String
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/openhab/core/things/channel.rb', line 32 def inspect r = "#<OpenHAB::Core::Things::Channel #{uid}" r += " #{label.inspect}" if label r += " description=#{description.inspect}" if description r += " kind=#{kind.inspect}" r += " channel_type_uid=#{channel_type_uid.inspect}" if channel_type_uid r += " configuration=#{configuration.properties.to_h}" unless configuration.properties.empty? r += " properties=#{properties.to_h}" unless properties.empty? r += " default_tags=#{default_tags.to_a}" unless default_tags.empty? r += " auto_update_policy=#{auto_update_policy}" if auto_update_policy r += " accepted_item_type=#{accepted_item_type}" if accepted_item_type "#{r}>" end |
#to_s ⇒ String
47 48 49 |
# File 'lib/openhab/core/things/channel.rb', line 47 def to_s uid.to_s end |