Class: OpenHAB::DSL::Sitemaps::WidgetBuilder

Inherits:
Object
  • Object
show all
Includes:
Core::EntityLookup
Defined in:
lib/openhab/dsl/sitemaps/builder.rb

Overview

Base class for all widgets

See Also:

  • orgorg.openhaborg.openhab.coreorg.openhab.core.modelorg.openhab.core.model.sitemaporg.openhab.core.model.sitemap.sitemaporg.openhab.core.model.sitemap.sitemap.Widget

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#iconString, ...

The icon to show It can be a string, or a hash of conditions and icons.

Examples:

A simple icon

sitemaps.build { text icon: "f7:house" }

A dynamic icon with conditions

sitemaps.build do
  text item: Wifi_Status, icon: {
    "ON" => "f7:wifi",
    "OFF" => "f7:wifi_slash",
    default: "f7:wifi_exclamationmark"
  }
end

Returns:

  • (String, Hash<String, String>, Hash<Array<String>, String>, nil)

See Also:



96
97
98
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 96

def icon
  @icon
end

#icon_colorsHash<String, String>, Hash<Array<String>, String> (readonly)

Icon color rules

Returns:

  • (Hash<String, String>, Hash<Array<String>, String>)

See Also:



114
115
116
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 114

def icon_colors
  @icon_colors
end

#itemString, ...

The item whose state to show

Returns:



79
80
81
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 79

def item
  @item
end

#labelString?

Returns:

  • (String, nil)


76
77
78
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 76

def label
  @label
end

#label_colorsHash<String, String>, Hash<Array<String>, String> (readonly)

Label color rules

Returns:

  • (Hash<String, String>, Hash<Array<String>, String>)

See Also:



106
107
108
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 106

def label_colors
  @label_colors
end

#static_iconString?

The static icon to show This is mutually exclusive with #icon

Returns:

  • (String, nil)

See Also:

Since:

  • openHAB 4.1



102
103
104
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 102

def static_icon
  @static_icon
end

#value_colorsHash<String, String>, Hash<Array<String>, String> (readonly)

Value color rules

Returns:

  • (Hash<String, String>, Hash<Array<String>, String>)

See Also:



110
111
112
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 110

def value_colors
  @value_colors
end

#visibilitiesArray<String> (readonly)

Visibility rules



118
119
120
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 118

def visibilities
  @visibilities
end

Instance Method Details

#icon_color(rules) ⇒ Hash<String, String>

Adds one or more new rules for setting the icon color

Returns:

  • (Hash<String, String>)

    the current rules



203
204
205
206
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 203

def icon_color(rules)
  rules = { default: rules } if rules.is_a?(String)
  @icon_colors.merge!(rules)
end

#label_color(rules) ⇒ Hash<String, String>

Adds one or more new rules for setting the label color

Returns:

  • (Hash<String, String>)

    the current rules



189
190
191
192
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 189

def label_color(rules)
  rules = { default: rules } if rules.is_a?(String)
  @label_colors.merge!(rules)
end

#value_color(rules) ⇒ Hash<String, String>

Adds one or more new rules for setting the value color

Returns:

  • (Hash<String, String>)

    the current rules



196
197
198
199
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 196

def value_color(rules)
  rules = { default: rules } if rules.is_a?(String)
  @value_colors.merge!(rules)
end

#visibility(*rules) ⇒ Array<String>

Adds one or more new visibility rules

Returns:

  • (Array<String>)

    the current rules



210
211
212
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 210

def visibility(*rules)
  @visibilities.concat(rules)
end