Darksky: Expose missing conditions for day 0 forecast (#18312)

Dark Sky Sensor didn't expose conditions for day 0 (today forecast) that
had the same name as current conditions. With this change all conditions
form day 0 (today) forecast are exposed the same way as conditions for
the rest of the days (1..7): as `dark_sky_<condition>_<day>`. As a
consequence, conditions for day 0 that were already exposed now have
`_0` suffix. This actually improves the code by removing most of
special handling, based on condition name.

To get day 0 conditions the user now has to add `- 0` to `forecast`
configuration parameter.

Conditions, for which suffix `_0` appeared: `precip_accumulation`,
`temperature_high`, `temperature_low`, `apparent_temperature_high`,
`apparent_temperature_low`, `precip_intensity_max`, `moon_phase`.

This is a breaking change!

Closes #18205
This commit is contained in:
Oleksii Serdiuk 2018-11-19 14:48:52 +01:00 committed by Pascal Vizeli
parent fc4dd4e51f
commit 01953ab46b
2 changed files with 27 additions and 38 deletions

View file

@ -20,7 +20,7 @@ VALID_CONFIG_MINIMAL = {
'platform': 'darksky',
'api_key': 'foo',
'forecast': [1, 2],
'monitored_conditions': ['summary', 'icon', 'temperature_max'],
'monitored_conditions': ['summary', 'icon', 'temperature_high'],
'update_interval': timedelta(seconds=120),
}
}
@ -30,7 +30,7 @@ INVALID_CONFIG_MINIMAL = {
'platform': 'darksky',
'api_key': 'foo',
'forecast': [1, 2],
'monitored_conditions': ['sumary', 'iocn', 'temperature_max'],
'monitored_conditions': ['sumary', 'iocn', 'temperature_high'],
'update_interval': timedelta(seconds=120),
}
}
@ -42,7 +42,7 @@ VALID_CONFIG_LANG_DE = {
'forecast': [1, 2],
'units': 'us',
'language': 'de',
'monitored_conditions': ['summary', 'icon', 'temperature_max',
'monitored_conditions': ['summary', 'icon', 'temperature_high',
'minutely_summary', 'hourly_summary',
'daily_summary', 'humidity', ],
'update_interval': timedelta(seconds=120),
@ -55,7 +55,7 @@ INVALID_CONFIG_LANG = {
'api_key': 'foo',
'forecast': [1, 2],
'language': 'yz',
'monitored_conditions': ['summary', 'icon', 'temperature_max'],
'monitored_conditions': ['summary', 'icon', 'temperature_high'],
'update_interval': timedelta(seconds=120),
}
}
@ -154,7 +154,7 @@ class TestDarkSkySetup(unittest.TestCase):
assert mock_get_forecast.called
assert mock_get_forecast.call_count == 1
assert len(self.hass.states.entity_ids()) == 9
assert len(self.hass.states.entity_ids()) == 8
state = self.hass.states.get('sensor.dark_sky_summary')
assert state is not None