Skip to content

Expose the condition code on condition sensors#14011

Merged
MartinHjelmare merged 5 commits intodevfrom
expose-condition-code-yweather-sensor
Apr 21, 2018
Merged

Expose the condition code on condition sensors#14011
MartinHjelmare merged 5 commits intodevfrom
expose-condition-code-yweather-sensor

Conversation

@maddox
Copy link
Copy Markdown
Contributor

@maddox maddox commented Apr 20, 2018

Description:

This exposes the condition_code on the condition YWeather sensor. The Yahoo Weather condition codes have long been used to map to icons like these great weather icons and these.

Exposing the codes lets other projects like dashboards utilize the codes to use iconography to show conditions with custom icons.

return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION,
}
attrs = { ATTR_ATTRIBUTION: CONF_ATTRIBUTION }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace after '{'
whitespace before '}'

}
attrs = {ATTR_ATTRIBUTION: CONF_ATTRIBUTION}

if self._code is None or "weather" in self._type:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the attribute added always (attrs['condition_code'] = None) even if "weather" isn't in self._type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Only the weather condition version of this sensor should have condition code since it doesn’t make much sense for the temp sensor to have it.

This follows the pattern of entity_image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to follow that pattern, you should check for is not None

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I blew this, copying the pattern for returning None lol. Late night PRs.

I’ll fix it later today. Thanks.

@syssi syssi changed the title expose the condition code on condition sensors Expose the condition code on condition sensors Apr 20, 2018
@balloob
Copy link
Copy Markdown
Member

balloob commented Apr 20, 2018

Also make sure to update the test

@maddox
Copy link
Copy Markdown
Contributor Author

maddox commented Apr 21, 2018

Ok, this is ready to go, with a boneheadless diff this time. Thanks!

@MartinHjelmare MartinHjelmare merged commit f12ff6f into dev Apr 21, 2018
@maddox maddox deleted the expose-condition-code-yweather-sensor branch April 22, 2018 00:51
@balloob balloob mentioned this pull request May 11, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants