Class: OpenHAB::DSL::Sitemaps::Builder

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

Overview

A sitemap builder allows you to dynamically create openHAB sitemaps at runtime.

Examples:

sitemaps.build do
  sitemap "demo", label: "My home automation" do
    frame label: "Date" do
      text item: Date
    end
    frame label: "Demo" do
      switch item: Lights, icon: "light"
      text item: LR_Temperature, label: "Livingroom [%.1f °C]"
      group item: Heating
      text item: LR_Multimedia_Summary, label: "Multimedia [%s]", static_icon: "video" do
        selection item: LR_TV_Channel,
                  mappings: { 0 => "off", 1 => "DasErste", 2 => "BBC One", 3 => "Cartoon Network" }
        slider item: LR_TV_Volume
      end
    end
  end
end

See Also:

Instance Method Summary collapse

Instance Method Details

#sitemap(name, label: nil, icon: nil) { ... } ⇒ SitemapBuilder

Parameters:

  • name (String)
  • label (String, nil) (defaults to: nil)
  • icon (String, nil) (defaults to: nil)

Yields:

Returns:



51
52
53
54
55
56
57
58
59
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 51

def sitemap(name, label: nil, icon: nil, &block)
  sitemap = SitemapBuilder.new(name, @builder_proxy, label: label, icon: icon, &block)
  sitemap = sitemap.build
  if @update && @provider.get(sitemap.uid)
    @provider.update(sitemap)
  else
    @provider.add(sitemap)
  end
end