emptying device state attributes if the update from the feed fails (#17249)

This commit is contained in:
Malte Franken 2018-10-09 01:13:08 +11:00 committed by Paulus Schoutsen
parent 42fb886d71
commit b637b48bd8
2 changed files with 5 additions and 0 deletions

View File

@ -145,3 +145,4 @@ class GeoRssServiceSensor(Entity):
# If no events were found due to an error then just set state to
# zero.
self._state = 0
self._state_attributes = {}

View File

@ -123,6 +123,10 @@ class TestGeoRssServiceUpdater(unittest.TestCase):
assert len(all_states) == 1
state = self.hass.states.get("sensor.event_service_any")
assert int(state.state) == 0
assert state.attributes == {
ATTR_FRIENDLY_NAME: "Event Service Any",
ATTR_UNIT_OF_MEASUREMENT: "Events",
ATTR_ICON: "mdi:alert"}
@mock.patch('georss_client.generic_feed.GenericFeed')
def test_setup_with_categories(self, mock_feed):