Skip to content

Commit

Permalink
support sitemap colortemperaturepicker
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Cutrer <[email protected]>
  • Loading branch information
ccutrer committed Nov 17, 2024
1 parent f610bd2 commit a1ad4cf
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
45 changes: 45 additions & 0 deletions lib/openhab/dsl/sitemaps/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,33 @@ def build
end
end

# Builds a `Colortemperaturepicker` element
# @since openHAB 4.3
# @see https://www.openhab.org/docs/ui/sitemaps.html#element-type-colortemperaturepicker
# @see org.openhab.core.model.sitemap.sitemap.Colortemperaturepicker
class ColortemperaturepickerBuilder < WidgetBuilder
# Allowed range of the value
# @return [Range, nil]
attr_accessor :range

# (see WidgetBuilder#initialize)
# @!method initialize(item: nil, label: nil, icon: nil, static_icon: nil, range: nil, label_color: nil, value_color: nil, icon_color: nil, visibility: nil)
# @param range [Range, nil] Allowed range of the value (see {ColortemperaturepickerBuilder#range})
# @!visibility private
def initialize(type, builder_proxy, frequency: nil, **kwargs, &block)
super(type, builder_proxy, **kwargs, &block)

@frequency = frequency
end

# @!visibility private
def build
widget = super
widget.frequency = (frequency * 1000).to_i if frequency
widget
end
end

# Builds a `Mapview` element
# @see https://www.openhab.org/docs/ui/sitemaps.html#element-type-mapview
# @see org.openhab.core.model.sitemap.sitemap.Mapview
Expand Down Expand Up @@ -1084,6 +1111,23 @@ class LinkableWidgetBuilder < WidgetBuilder
# visibility: nil)
# end
#
# # (see ColortemperaturepickerBuilder#initialize)
# # Create a new `Colortemperaturepicker` element.
# # @since openHAB 4.3
# # @yield Block executed in the context of a {ColortemperaturepickerBuilder}
# # @return [ColortemperaturepickerBuilder]
# # @!visibility public
# def colortemperaturepicker(item: nil,
# label: nil,
# icon: nil,
# static_icon: nil,
# range: nil,
# label_color: nil,
# value_color: nil,
# icon_color: nil,
# visibility: nil)
# end
#
# # (see DefaultBuilder#initialize)
# # Create a new `Default` element.
# # @yield Block executed in the context of a {DefaultBuilder}
Expand Down Expand Up @@ -1116,6 +1160,7 @@ class LinkableWidgetBuilder < WidgetBuilder
buttongrid
setpoint
colorpicker
colortemperaturepicker
default].each do |method|
class_eval <<~RUBY, __FILE__, __LINE__ + 1
def #{method}(*args, **kwargs, &block) # def frame(*args, **kwargs, &block)
Expand Down
8 changes: 8 additions & 0 deletions spec/openhab/dsl/sitemaps/builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,14 @@
end
end

it "can add a colortemperaturepicker", if: OpenHAB::Core.version >= OpenHAB::Core::V4_3 do
sitemaps.build do
sitemap "default" do
colortemperaturepicker label: "My Colorpicker"
end
end
end

# @deprecated OH 4.0 guard is only needed for < OH 4.1
describe "#buttongrid", if: OpenHAB::Core.version >= OpenHAB::Core::V4_1 do
it "works" do
Expand Down

0 comments on commit a1ad4cf

Please sign in to comment.