Class: OpenHAB::Core::Items::ContactItem

Inherits:
GenericItem show all
Defined in:
lib/openhab/core/items/contact_item.rb

Overview

A ContactItem can be used for sensors that return an “open” or “closed” as a state.

This is useful for doors, windows, etc.

Examples:

rule 'Log state of all doors on system startup' do
  on_load
  run do
    Doors.each do |door|
      case door.state
      when OPEN then logger.info("#{door.name} is Open")
      when CLOSED then logger.info("#{door.name} is Open")
      else logger.info("#{door.name} is not initialized")
      end
    end
  end
end

Constant Summary

Constants included from Semantics

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

Constants included from Persistence

Persistence::HistoricState

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 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

#call_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, #average_until, #changed_between?, #changed_since?, #changed_until?, #count_between, #count_since, #count_state_changes_between, #count_state_changes_since, #count_state_changes_until, #count_until, #delta_between, #delta_since, #delta_until, #deviation_between, #deviation_since, #deviation_until, #evolution_rate, #evolution_rate_between, #evolution_rate_since, #evolution_rate_until, #historic_state, #last_change, #last_update, #maximum_between, #maximum_since, #maximum_until, #median_between, #median_since, #median_until, #minimum_between, #minimum_since, #minimum_until, #next_change, #next_state, #next_update, #persist, #persisted_state, #previous_state, #remove_all_states_between, #remove_all_states_since, #remove_all_states_until, #sum_between, #sum_since, #sum_until, #updated_between?, #updated_since?, #updated_until?, #variance_between, #variance_since, #variance_until

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

#ensure

Instance Attribute Details

#stateOpenClosedType? (readonly)

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/openhab/core/items/contact_item.rb', line 33

class ContactItem < GenericItem
  # @!method open?
  #   Check if the item state == {OPEN}
  #   @return [true,false]
  #
  # @example Log open contacts
  #   Contacts.select(&:open?).each { |contact| logger.info("Contact #{contact.name} is open")}

  # @!method closed?
  #   Check if the item state == {CLOSED}
  #   @return [true,false]
  #
  # @example Log closed contacts
  #   Contacts.select(&:closed?).each { |contact| logger.info("Contact #{contact.name} is closed")}
end