mirror of
https://github.com/home-assistant/core.git
synced 2025-04-28 11:17:53 +00:00
Expose the condition code on condition sensors (#14011)
* expose the condition code on condition sensors
* 💄
* like thisss duh
* add test for condition_code
* It’s a string
This commit is contained in:
parent
cb490780c9
commit
f12ff6f297
@ -131,9 +131,12 @@ class YahooWeatherSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
return {
|
attrs = {ATTR_ATTRIBUTION: CONF_ATTRIBUTION}
|
||||||
ATTR_ATTRIBUTION: CONF_ATTRIBUTION,
|
|
||||||
}
|
if self._code is not None and "weather" in self._type:
|
||||||
|
attrs['condition_code'] = self._code
|
||||||
|
|
||||||
|
return attrs
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest data from Yahoo! and updates the states."""
|
"""Get the latest data from Yahoo! and updates the states."""
|
||||||
|
@ -162,6 +162,8 @@ class TestWeather(unittest.TestCase):
|
|||||||
state = self.hass.states.get('sensor.yweather_condition')
|
state = self.hass.states.get('sensor.yweather_condition')
|
||||||
assert state is not None
|
assert state is not None
|
||||||
self.assertEqual(state.state, 'Mostly Cloudy')
|
self.assertEqual(state.state, 'Mostly Cloudy')
|
||||||
|
self.assertEqual(state.attributes.get('condition_code'),
|
||||||
|
'28')
|
||||||
self.assertEqual(state.attributes.get('friendly_name'),
|
self.assertEqual(state.attributes.get('friendly_name'),
|
||||||
'Yweather Condition')
|
'Yweather Condition')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user