From fad7e43c4f34a3c29152698688c1549d977082c5 Mon Sep 17 00:00:00 2001 From: Matt Zimmerman Date: Sun, 27 Jun 2021 09:39:40 -0700 Subject: [PATCH] Add state attribute to SmartTub reminders for days remaining (#51825) --- homeassistant/components/smarttub/binary_sensor.py | 7 +++++-- tests/components/smarttub/test_binary_sensor.py | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/smarttub/binary_sensor.py b/homeassistant/components/smarttub/binary_sensor.py index 331c0b7e3d7..7bb4e8cc9e0 100644 --- a/homeassistant/components/smarttub/binary_sensor.py +++ b/homeassistant/components/smarttub/binary_sensor.py @@ -29,9 +29,11 @@ ATTR_CREATED_AT = "created_at" ATTR_UPDATED_AT = "updated_at" # how many days to snooze the reminder for -ATTR_SNOOZE_DAYS = "days" +ATTR_REMINDER_DAYS = "days" SNOOZE_REMINDER_SCHEMA = { - vol.Required(ATTR_SNOOZE_DAYS): vol.All(vol.Coerce(int), vol.Range(min=10, max=120)) + vol.Required(ATTR_REMINDER_DAYS): vol.All( + vol.Coerce(int), vol.Range(min=10, max=120) + ) } @@ -117,6 +119,7 @@ class SmartTubReminder(SmartTubEntity, BinarySensorEntity): """Return the state attributes.""" return { ATTR_REMINDER_SNOOZED: self.reminder.snoozed, + ATTR_REMINDER_DAYS: self.reminder.remaining_days, } async def async_snooze(self, days): diff --git a/tests/components/smarttub/test_binary_sensor.py b/tests/components/smarttub/test_binary_sensor.py index 16b4f60d3e4..98d404ef600 100644 --- a/tests/components/smarttub/test_binary_sensor.py +++ b/tests/components/smarttub/test_binary_sensor.py @@ -30,6 +30,7 @@ async def test_reminders(spa, setup_entry, hass): assert state is not None assert state.state == STATE_OFF assert state.attributes["snoozed"] is False + assert state.attributes["days"] == 2 @pytest.fixture