Skip to content

Commit

Permalink
only show unavailable entities stale for >15m
Browse files Browse the repository at this point in the history
  • Loading branch information
joelhawksley committed Jan 20, 2025
1 parent 38b9cd8 commit 138f54a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/apis/home_assistant_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def problems
end.compact

unavailable_entity_problems = data
.select { _1[:state] == "unavailable" }
.select { _1[:state] == "unavailable" && Time.parse(_1[:last_updated].to_s) < 15.minutes.ago }
.map do
{
icon: "triangle-exclamation",
Expand Down
2 changes: 1 addition & 1 deletion test/apis/home_assistant_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def test_problems_non_binary
end

def test_problems_unavailable
data = [{entity_id: "sensor.foo_bar", state: "unavailable"}]
data = [{entity_id: "sensor.foo_bar", state: "unavailable", last_updated: 30.minutes.ago}]

api = HomeAssistantApi.new({})
api.stub :data, data do
Expand Down

0 comments on commit 138f54a

Please sign in to comment.