Class: OpenHAB::DSL::Sitemaps::ButtongridBuilder
- Inherits:
-
LinkableWidgetBuilder
- Object
- WidgetBuilder
- LinkableWidgetBuilder
- OpenHAB::DSL::Sitemaps::ButtongridBuilder
- Defined in:
- lib/openhab/dsl/sitemaps/builder.rb
Overview
Builds a Buttongrid element
Instance Attribute Summary
Attributes inherited from WidgetBuilder
#icon, #icon_colors, #item, #label, #label_colors, #static_icon, #value_colors, #visibilities
Instance Method Summary collapse
-
#button(row = nil, column = nil, click = nil, label = nil, icon = nil, item: nil, label: nil, icon: nil, static_icon: nil, row:, column:, click:, release: nil, stateless: nil, label_color: nil, value_color: nil, icon_color: nil, confirm: nil, visibility: nil) ⇒ ButtonBuilder
Adds a button inside the buttongrid.
Methods inherited from LinkableWidgetBuilder
#buttongrid, #chart, #colorpicker, #colortemperaturepicker, #default, #frame, #group, #image, #input, #mapview, #selection, #setpoint, #sitemap, #slider, #switch, #text, #video, #webview
Methods inherited from WidgetBuilder
#confirm, #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 Method Details
#button(row = nil, column = nil, click = nil, label = nil, icon = nil, item: nil, label: nil, icon: nil, static_icon: nil, row:, column:, click:, release: nil, stateless: nil, label_color: nil, value_color: nil, icon_color: nil, confirm: nil, visibility: nil) ⇒ ButtonBuilder
Adds a button inside the buttongrid
-
In openHAB 4.1, buttons are direct properties of the buttongrid. Only
row,column,click,label(optional), andicon(optional) are used. All the other parameters are ignored. All the buttons will send commands to the same item assigned to the buttongrid. -
In openHAB 4.2+, buttons are widgets within the containing buttongrid, and they support all the parameters listed in the method signature such as
release,label_color,visibility, etc. Each Button element has an item associated with that button. When an item is not specified for the button, it will default to the containing buttongrid's item.
This method supports positional arguments and/or keyword arguments. Their use can be mixed, however, the keyword arguments will override the positional arguments when both are specified.
1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 |
# File 'lib/openhab/dsl/sitemaps/builder.rb', line 1535 def button(row = nil, column = nil, click = nil, label = nil, icon = nil, **kwargs, &) args = [row, column, click, label, icon].compact args = args.first if args.first.is_a?(Array) kwargs = %i[row column click label icon].zip(args).to_h.compact.merge(kwargs) missing_args = (REQUIRED_BUTTON_ARGS - kwargs.keys).compact unless missing_args.empty? args = kwargs.map { |k, v| "#{k}: #{v.inspect}" }.join(", ") missing_args = missing_args.join(", ") raise ArgumentError, "button(#{args}) missing required parameters: #{missing_args}" end kwargs[:item] ||= item if item # default to the buttongrid's item kwargs[:label] ||= kwargs[:click].to_s ButtonBuilder.new(@builder_proxy, **kwargs, &).tap do |b| children << b end end |