Clean up SmartTub reminders (#48033)

* remove "date" state attribute

* remove unused constant
This commit is contained in:
Matt Zimmerman 2021-03-24 00:39:23 -07:00 committed by GitHub
parent 879c82ebf8
commit 5265aabf92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 11 deletions

View File

@ -1,5 +1,4 @@
"""Platform for binary sensor integration.""" """Platform for binary sensor integration."""
from datetime import datetime, timedelta
import logging import logging
from smarttub import SpaReminder from smarttub import SpaReminder
@ -17,8 +16,6 @@ _LOGGER = logging.getLogger(__name__)
# whether the reminder has been snoozed (bool) # whether the reminder has been snoozed (bool)
ATTR_REMINDER_SNOOZED = "snoozed" ATTR_REMINDER_SNOOZED = "snoozed"
# the date at which the reminder will be activated
ATTR_REMINDER_DATE = "date"
async def async_setup_entry(hass, entry, async_add_entities): async def async_setup_entry(hass, entry, async_add_entities):
@ -83,12 +80,10 @@ class SmartTubReminder(SmartTubEntity, BinarySensorEntity):
return self.reminder.remaining_days == 0 return self.reminder.remaining_days == 0
@property @property
def device_state_attributes(self): def extra_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
when = datetime.now() + timedelta(days=self.reminder.remaining_days)
return { return {
ATTR_REMINDER_SNOOZED: self.reminder.snoozed, ATTR_REMINDER_SNOOZED: self.reminder.snoozed,
ATTR_REMINDER_DATE: when.date().isoformat(),
} }
@property @property

View File

@ -1,6 +1,4 @@
"""Test the SmartTub binary sensor platform.""" """Test the SmartTub binary sensor platform."""
from datetime import date, timedelta
from homeassistant.components.binary_sensor import ( from homeassistant.components.binary_sensor import (
DEVICE_CLASS_CONNECTIVITY, DEVICE_CLASS_CONNECTIVITY,
STATE_OFF, STATE_OFF,
@ -25,7 +23,4 @@ async def test_reminders(spa, setup_entry, hass):
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
assert state is not None assert state is not None
assert state.state == STATE_OFF assert state.state == STATE_OFF
assert date.fromisoformat(state.attributes["date"]) <= date.today() + timedelta(
days=2
)
assert state.attributes["snoozed"] is False assert state.attributes["snoozed"] is False