Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the condition code on condition sensors #14011

Merged
merged 5 commits into from
Apr 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions homeassistant/components/sensor/yweather.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ def entity_picture(self):
@property
def device_state_attributes(self):
"""Return the state attributes."""
return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION,
}
attrs = {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):
"""Get the latest data from Yahoo! and updates the states."""
Expand Down
2 changes: 2 additions & 0 deletions tests/components/sensor/test_yweather.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ def test_setup_all(self, mock_yahooweather):
state = self.hass.states.get('sensor.yweather_condition')
assert state is not None
self.assertEqual(state.state, 'Mostly Cloudy')
self.assertEqual(state.attributes.get('condition_code'),
'28')
self.assertEqual(state.attributes.get('friendly_name'),
'Yweather Condition')

Expand Down