Skip to content

Commit 46e8334

Browse files
committed
all exterior door locks are input booleans
1 parent 31ce36c commit 46e8334

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

app/apis/home_assistant_api.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ def package_present?
7979
def unavailable_door_sensors
8080
out = []
8181

82-
(Timeframe::Application.config.local["home_assistant"]["exterior_door_sensors"] +
83-
Timeframe::Application.config.local["home_assistant"]["exterior_door_locks"]
84-
).each do |entity_id|
82+
Timeframe::Application.config.local["home_assistant"]["exterior_door_sensors"].each do |entity_id|
8583
if data.find { _1[:entity_id] == entity_id }&.fetch(:state) == "unavailable"
8684
out << entity_id.split(".").last.gsub("_opening", "").humanize
8785
end
@@ -136,7 +134,7 @@ def unlocked_doors
136134
out = []
137135

138136
Timeframe::Application.config.local["home_assistant"]["exterior_door_locks"].map do |entity_id|
139-
if ["unlocked", "off"].include?(data.find { _1[:entity_id] == entity_id }&.fetch(:state))
137+
if data.find { _1[:entity_id] == entity_id }&.fetch(:state) == "off"
140138
out << entity_id.split(".").last.split("_door").first.humanize
141139
end
142140
end

test/apis/home_assistant_api_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def test_unlocked_doors_ignores_open_doors
214214
},
215215
{
216216
entity_id: Timeframe::Application.config.local["home_assistant"]["exterior_door_locks"][0],
217-
state: "unlocked"
217+
state: "off"
218218
}
219219
]
220220

@@ -228,7 +228,7 @@ def test_unlocked_doors
228228
data = [
229229
{
230230
entity_id: Timeframe::Application.config.local["home_assistant"]["exterior_door_locks"][0],
231-
state: "unlocked"
231+
state: "off"
232232
}
233233
]
234234

@@ -241,14 +241,14 @@ def test_unlocked_doors
241241
def test_unavailable_door_sensors
242242
data = [
243243
{
244-
entity_id: Timeframe::Application.config.local["home_assistant"]["exterior_door_locks"][0],
244+
entity_id: Timeframe::Application.config.local["home_assistant"]["exterior_door_sensors"][0],
245245
state: "unavailable"
246246
}
247247
]
248248

249249
api = HomeAssistantApi.new
250250
api.stub :data, data do
251-
assert_equal(api.unavailable_door_sensors, ["Patio door lock"])
251+
assert_equal(api.unavailable_door_sensors, ["Alley door sensor"])
252252
end
253253
end
254254

0 commit comments

Comments
 (0)