Class: OpenHAB::Core::Items::ColorItem

Inherits:
DimmerItem show all
Defined in:
lib/openhab/core/items/color_item.rb

Overview

ColorItem represents a color values, e.g. for LED lights.

Note that it inherits from DimmerItem, so you can call SwitchItem#on, SwitchItem#off, SwitchItem#on?, SwitchItem#off?, etc. on it. Its state type is an HSBType, which is stored as Hue, Saturation, and Brightness, but has easy helpers for working with RGB values of various forms.

Examples:

Sending commands

HueBulb << "#ff0000" # send 'red' as a command
HueBulb.on
HueBulb.dim

Inspect state

HueBulb.on? # => true
HueBulb.state.red # => 100%
HueBulb.state.hue # => 0 °
HueBulb.state.brightness # => 100%
HueBulb.state.to_rgb # => [100%, 0%, 0%]
HueBulb.state.rgb # => 16711680
HueBulb.state.to_hex # => "0xff0000"
HueBulb.state.on? # => true
HueBulb.state.red.to_byte # => 255
HueBulb.state.blue.to_byte # => 0

Constant Summary

Constants included from Semantics

Semantics::Equipment, Semantics::Location, Semantics::Point, Semantics::Property, Semantics::Tag

Instance Attribute Summary collapse

Attributes inherited from GenericItem

#category, #formatted_state, #label, #name, #raw_state, #tags

Attributes included from Semantics

#equipment, #equipment_type, #location, #location_type, #point_type, #property_type, #semantic_type

Attributes included from Item

#accepted_command_types, #accepted_data_types, #all_groups, #channel, #channel_uid, #channel_uids, #channels, #groups, #links, #metadata, #name, #provider, #thing, #things

Method Summary

Methods inherited from DimmerItem

#brighten, #decrease, #dim, #increase

Methods inherited from SwitchItem

#off, #off!, #off?, #on, #on!, #on?, #toggle

Methods inherited from GenericItem

#command, #modify, #null?, #refresh, #state?, #time_series=, #undef?, #update

Methods included from Semantics

add, #equipment?, #location?, lookup, #point?, #points, remove, #semantic?, tags

Methods included from Item

#color_item?, #contact_item?, #date_time_item?, #dimmer_item?, #group_item?, #image_item?, #inspect, #link, #location_item?, #member_of?, #number_item?, #player_item?, #rollershutter_item?, #string_item?, #switch_item?, #tagged?, #to_s, #unlink

Methods included from DSL::Items::TimedCommand

#command

Methods included from Persistence

#average_between, #average_since, #changed_between?, #changed_since?, #count_between, #count_since, #count_state_changes_between, #count_state_changes_since, #delta_between, #delta_since, #deviation_between, #deviation_since, #evolution_rate, #historic_state, #last_update, #maximum_between, #maximum_since, #minimum_between, #minimum_since, #persist, #previous_state, #sum_between, #sum_since, #updated_between?, #updated_since?, #variance_between, #variance_since

Methods included from DSL::Items::Ensure::Ensurable

#ensure

Instance Attribute Details

#stateHSBType? (readonly)

Returns:



38
39
40
41
42
43
44
45
46
47
# File 'lib/openhab/core/items/color_item.rb', line 38

class ColorItem < DimmerItem
  # Make sure to do the String => HSBType conversion in Ruby,
  # where we add support for hex
  # @!visibility private
  def format_type(type)
    return Types::HSBType.new(type) if type.respond_to?(:to_str)

    super
  end
end