From bbeea422697254c58db51b6427c71883864853fa Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Sun, 7 Jul 2024 17:58:09 -0600 Subject: [PATCH 1/4] update CI to 4.2 final and 4.3 SNAPSHOT Signed-off-by: Cody Cutrer --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6906672b..92ae7ef8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,7 +71,7 @@ jobs: if: "!contains(github.event.head_commit.message, 'ci skip')" outputs: openhab_matrix: | - ["3.4.5", "4.0.4", "4.1.1", "4.2.0.RC1", "4.2.0-SNAPSHOT"] + ["3.4.5", "4.0.4", "4.1.1", "4.2.0", "4.3.0-SNAPSHOT"] snapshot_date: | ${{ steps.snapshot-date.outputs.SNAPSHOT_DATE }} steps: @@ -133,9 +133,9 @@ jobs: jruby_version: jruby-9.3.10.0 - openhab_version: 4.1.1 jruby_version: jruby-9.3.10.0 - - openhab_version: 4.2.0-SNAPSHOT + - openhab_version: 4.2.0 jruby_version: jruby-9.3.10.0 - - openhab_version: 4.2.0.RC1 + - openhab_version: 4.3.0-SNAPSHOT jruby_version: jruby-9.3.10.0 steps: - uses: actions/checkout@v4 From befa8c47e4d4d89ac12f6af91072414538064469 Mon Sep 17 00:00:00 2001 From: Jimmy Tanagra Date: Mon, 8 Jul 2024 22:05:40 +1000 Subject: [PATCH 2/4] fix persistence spec Signed-off-by: Jimmy Tanagra --- spec/openhab/core/items/persistence_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/openhab/core/items/persistence_spec.rb b/spec/openhab/core/items/persistence_spec.rb index 8bcfcd353..3d7f54009 100644 --- a/spec/openhab/core/items/persistence_spec.rb +++ b/spec/openhab/core/items/persistence_spec.rb @@ -152,8 +152,9 @@ def call_method(method, item) end it "accepts a TimeSeries" do - item.persist(TimeSeries.new) - item.persist(TimeSeries.new, :influxdb) + time_series = TimeSeries.new.add(Time.now, 0) + item.persist(time_series) + item.persist(time_series, :influxdb) end end end From 4f626675094768c83a8202cc6b3b7832511d8701 Mon Sep 17 00:00:00 2001 From: Jimmy Tanagra Date: Mon, 8 Jul 2024 22:06:01 +1000 Subject: [PATCH 3/4] update oh version in rake Signed-off-by: Jimmy Tanagra --- rakelib/openhab.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rakelib/openhab.rake b/rakelib/openhab.rake index 50eb7d082..182337c15 100644 --- a/rakelib/openhab.rake +++ b/rakelib/openhab.rake @@ -11,7 +11,7 @@ require "net/http" # Disabled due to part of buid / potentially refactor into classes # rubocop: disable Rake/MethodDefinitionInTask Legacy code namespace :openhab do - @openhab_version = ENV["OPENHAB_VERSION"] || "4.2.0-SNAPSHOT" + @openhab_version = ENV["OPENHAB_VERSION"] || "4.3.0-SNAPSHOT" @port_numbers = { ssh: { port: ENV["OPENHAB_SSH_PORT"] || 8101, config: "org.apache.karaf.shell:sshPort" }, lsp: { port: ENV["OPENHAB_LSP_PORT"] || 5007, config: "org.openhab.lsp:port" } From 3dc059475e2509dadd6bf29b69c93e69853a3d98 Mon Sep 17 00:00:00 2001 From: Jimmy Tanagra Date: Thu, 11 Jul 2024 11:32:42 +1000 Subject: [PATCH 4/4] Support attachment for `every` trigger Signed-off-by: Jimmy Tanagra --- lib/openhab/dsl/rules/builder.rb | 4 +-- spec/openhab/dsl/rules/builder_spec.rb | 36 +++++++++++++++++--------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/lib/openhab/dsl/rules/builder.rb b/lib/openhab/dsl/rules/builder.rb index 77995335d..182edab79 100644 --- a/lib/openhab/dsl/rules/builder.rb +++ b/lib/openhab/dsl/rules/builder.rb @@ -1369,9 +1369,9 @@ def every(value, at: nil, attach: nil) @ruby_triggers << [:every, value, { at: at }] if value == :day && at.is_a?(Item) - raise ArgumentError, "Attachments are not supported with dynamic datetime triggers" unless attach.nil? + # raise ArgumentError, "Attachments are not supported with dynamic datetime triggers" unless attach.nil? - return trigger("timer.DateTimeTrigger", itemName: at.name, timeOnly: true) + return trigger("timer.DateTimeTrigger", itemName: at.name, timeOnly: true, attach: attach) end cron_expression = case value diff --git a/spec/openhab/dsl/rules/builder_spec.rb b/spec/openhab/dsl/rules/builder_spec.rb index 8fda9b4ce..d69544395 100644 --- a/spec/openhab/dsl/rules/builder_spec.rb +++ b/spec/openhab/dsl/rules/builder_spec.rb @@ -1323,23 +1323,35 @@ def self.generate(name, cron_expression, *every_args, attach: nil, **kwargs) generate("can use MonthDay as a string", "0 0 12 17 11 ? *", "11-17", at: LocalTime.parse("12:00")) generate("can use LocalTime a string", "0 0 12 17 11 ? *", MonthDay.parse("11-17"), at: "12:00") - it "supports dynamic `at`" do - items.build { date_time_item MyDateTimeItem } + context "with dynamic `at`" do + let(:item) { items.build { date_time_item MyDateTimeItem } } - triggered = false - every(:day, id: "dynamic_at_rule", at: MyDateTimeItem) { triggered = true } + it "works" do + triggered = false + every(:day, id: "dynamic_at_rule", at: item) { triggered = true } - rule = rules["dynamic_at_rule"] - trigger = rule.triggers.first + rule = rules["dynamic_at_rule"] + trigger = rule.triggers.first - handler = OpenHAB::Core::Rules.manager.get_module_handler_factory(trigger.type_uid) - .get_handler(trigger, rule.uid) + handler = OpenHAB::Core::Rules.manager.get_module_handler_factory(trigger.type_uid) + .get_handler(trigger, rule.uid) - expect(handler.getTemporalAdjuster).not_to be_nil + expect(handler.getTemporalAdjuster).not_to be_nil - MyDateTimeItem.update(Time.now + 2 - 2.days) - wait(4.seconds) do - expect(triggered).to be true + item.update(Time.now + 2 - 2.days) + wait(4.seconds) do + expect(triggered).to be true + end + end + + it "supports attachments" do + triggered = nil + every(:day, id: "dynamic_at_rule", at: item, attach: 1) { |event| triggered = event.attachment } + + item.update(Time.now + 2 - 2.days) + wait(4.seconds) do + expect(triggered).to be 1 + end end end