openhab-scripting 2.12.0 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/openhab/core/dsl/monkey_patch/items/dimmer_item.rb +42 -0
- data/lib/openhab/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e3db2fe066cd7fe8c314eda96c2ce182611c1af9be801fb179896eaeebbca6e
|
4
|
+
data.tar.gz: a91ab773ddff831028cf3ef9839cca92f8772f3e9c10eb6c49d610282a4f998b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7ada2d4a291c47f44531f47e7556799c800f83ec9fa2d23d3cd708ddba11bd958a84d0df74c999ca49e0f14f5f9067a7a5c7d5ac766bab31bdc5e969bab236f
|
7
|
+
data.tar.gz: b06aae6303a62bf4b53144c9cf0e1ad0d2457be0a76e1930f1558d156259ccd1dbe89ed9a1121c1ffb0a728052665c57cc5736ed1932d78cc61ff88bbdcc2c24
|
@@ -14,6 +14,7 @@ Dimmer = DimmerItem
|
|
14
14
|
#
|
15
15
|
# rubocop:disable Style/ClassAndModuleChildren
|
16
16
|
class Java::OrgOpenhabCoreLibraryItems::DimmerItem
|
17
|
+
include Comparable
|
17
18
|
# rubocop:enable Style/ClassAndModuleChildren
|
18
19
|
java_import org.openhab.core.library.types.DecimalType
|
19
20
|
java_import org.openhab.core.library.types.IncreaseDecreaseType
|
@@ -85,6 +86,38 @@ class Java::OrgOpenhabCoreLibraryItems::DimmerItem
|
|
85
86
|
target
|
86
87
|
end
|
87
88
|
|
89
|
+
#
|
90
|
+
# Compare DimmerItem to supplied object
|
91
|
+
#
|
92
|
+
# @param [Object] other object to compare to
|
93
|
+
#
|
94
|
+
# @return [Integer] -1,0,1 or nil depending on value supplied, nil comparison to supplied object is not possible.
|
95
|
+
#
|
96
|
+
def <=>(other)
|
97
|
+
logger.trace("Comparing #{self} to #{other}")
|
98
|
+
case other
|
99
|
+
when DimmerItem, NumberItem
|
100
|
+
state <=> other.state
|
101
|
+
when DecimalType
|
102
|
+
state <=> other
|
103
|
+
else
|
104
|
+
to_i <=> other.to_i
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# Compare DimmerItem to supplied object.
|
110
|
+
# The == operator needs to be overridden because the parent java object
|
111
|
+
# has .equals which overrides the <=> operator above
|
112
|
+
#
|
113
|
+
# @param [Object] other object to compare to
|
114
|
+
#
|
115
|
+
# @return [Integer] true if the two objects contain the same value, false otherwise
|
116
|
+
#
|
117
|
+
def ==(other)
|
118
|
+
(self <=> other).zero?
|
119
|
+
end
|
120
|
+
|
88
121
|
#
|
89
122
|
# Check if dimmer has a state and state is not zero
|
90
123
|
#
|
@@ -105,6 +138,15 @@ class Java::OrgOpenhabCoreLibraryItems::DimmerItem
|
|
105
138
|
|
106
139
|
alias to_int to_i
|
107
140
|
|
141
|
+
#
|
142
|
+
# Return the string representation of the dimmer item
|
143
|
+
#
|
144
|
+
# @return [String] String version of the dimmer value
|
145
|
+
#
|
146
|
+
def to_s
|
147
|
+
to_i.to_s
|
148
|
+
end
|
149
|
+
|
108
150
|
#
|
109
151
|
# Check if dimmer is on
|
110
152
|
#
|
data/lib/openhab/version.rb
CHANGED