Class: OpenHAB::DSL::Sitemaps::SwitchBuilder

Inherits:
WidgetBuilder show all
Defined in:
lib/openhab/dsl/sitemaps/builder.rb

Overview

Builds a Switch element

Direct Known Subclasses

SelectionBuilder

Instance Attribute Summary collapse

Attributes inherited from WidgetBuilder

#icon, #icon_colors, #item, #label, #label_colors, #static_icon, #value_colors, #visibilities

Method Summary

Methods inherited from WidgetBuilder

#icon_color, #label_color, #value_color, #visibility

Methods included from Core::EntityLookup

#items, #method_missing, #things

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OpenHAB::Core::EntityLookup

Instance Attribute Details

#mappingsHash, ...

Mappings from command to label

If a hash is given, the keys are the commands and the values are the labels. The keys can be any command, string or symbol. They will be converted to strings.

If an array is given:

  • Scalar elements define the command, and the label is the same as the command.
  • Array elements contain the command, label, and optional third element for the icon.
  • Hash elements contain the command, release (optional), label, and icon (optional) defined by the corresponding keys.

Examples:

A Hash to specify different command and label

switch mappings: { off: "Off", cool: "Cool", heat: "Heat" }

A simple array with the same command and label

switch mappings: %w[off cool heat]

An array of arrays containing the command, label, and icon

switch mappings: [
  %w[off Off f7:power],
  %w[cool Cool f7:snow],
  %w[heat Heat f7:flame],
  %w[auto Auto] # no icon
]

An array of hashes for the command, label, and icon

switch mappings: [
  {command: "off", label: "Off", icon: "f7:power"},
  {command: "cool", label: "Cool", icon: "f7:snow"},
  {command: "heat", label: "Heat", icon: "f7:flame"},
  {command: "auto", label: "Auto"} # no icon
]

Since openHAB 4.2, release is also supported in the array of hashes

# when `release` is specified, `command` will be sent on press and `release` on release
switch mappings: [
  {label: "On", command: ON, release: OFF, icon: "f7:power"}
]

Returns:

See Also:

Since:

  • openHAB 4.1 added support for icons



361
362
363
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 361

def mappings
  @mappings
end