From 31ce36ce07426c7659ac06c0a119dfd119dde9d0 Mon Sep 17 00:00:00 2001 From: Joel Hawksley Date: Mon, 22 Jul 2024 20:40:05 -0600 Subject: [PATCH] allow use of input boolean for lock state --- app/apis/home_assistant_api.rb | 2 +- test/models/display_content_test.rb | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/apis/home_assistant_api.rb b/app/apis/home_assistant_api.rb index 779b113..203d556 100644 --- a/app/apis/home_assistant_api.rb +++ b/app/apis/home_assistant_api.rb @@ -136,7 +136,7 @@ def unlocked_doors out = [] Timeframe::Application.config.local["home_assistant"]["exterior_door_locks"].map do |entity_id| - if data.find { _1[:entity_id] == entity_id }&.fetch(:state) == "unlocked" + if ["unlocked", "off"].include?(data.find { _1[:entity_id] == entity_id }&.fetch(:state)) out << entity_id.split(".").last.split("_door").first.humanize end end diff --git a/test/models/display_content_test.rb b/test/models/display_content_test.rb index ab71e65..e4667d8 100644 --- a/test/models/display_content_test.rb +++ b/test/models/display_content_test.rb @@ -6,10 +6,12 @@ class DisplayContenttTest < Minitest::Test include ActiveSupport::Testing::TimeHelpers def test_no_data - result = DisplayContent.new.call + travel_to DateTime.new(2023, 8, 27, 18, 15, 0, "-0600") do + result = DisplayContent.new.call - assert_nil(result[:current_temperature]) - assert_equal(result[:day_groups].count, 5) + assert_nil(result[:current_temperature]) + assert_equal(result[:day_groups].count, 5) + end end def test_hide_events_after_cutoff