8000 Replace emulated_hue: with emulated_hue_hidden: for consistency. by rbflurry · Pull Request #9382 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Replace 8000 emulated_hue: with emulated_hue_hidden: for consistency. #9382

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

Merged
merged 11 commits into from
Sep 26, 2017
Merged

Replace emulated_hue: with emulated_hue_hidden: for consistency. #9382

merged 11 commits into from
Sep 26, 2017

Conversation

rbflurry
Copy link
Contributor
@rbflurry rbflurry commented Sep 11, 2017

Description:

I would like to propose the following code changes to standardize the way we choose to expose entity's to other platforms. This might be the wrong way to go about this but it is working in my situation.

Currently we use the following configs to get the same "hidden" result.

homeassistant:
  customize:
    light.demo:
      homebridge_hidden: true     # should we hide from homebridge?
      haaska_hidden: true              # should we hide from haaska?
      emulated_hue: false              # should we show to emulated_hue?

The code will continue to accept the current emulated_hue: attribute but will also except emulated_hue_hidden as well.

Example entry for configuration.yaml (if applicable):

homeassistant:
  customize:
    light.demo:
      homebridge_hidden: true
      haaska_hidden: true
      emulated_hue_hidden: true

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

else:
expose = False
if explicit_expose:
_LOGGER.warning("The attribute 'emulated_hue' is deprecated and will be removed in a"

Choose a reason for hiding this comment

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

line too long (97 > 79 characters)

if explicit_expose is True or explicit_hidden is False :
expose = True
else:
expose = False

Choose a reason for hiding this comment

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

indentation is not a multiple of four


explicit_hidden = entity.attributes.get (ATTR_EMULATED_HUE_HIDDEN, None)
if explicit_expose is True or explicit_hidden is False :
expose = True

Choose a reason for hiding this comment

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

indentation is not a multiple of four

@@ -223,17 +224,24 @@ def is_entity_exposed(self, entity):

domain = entity.domain.lower()
explicit_expose = entity.attributes.get(ATTR_EMULATED_HUE, None)

explicit_hidden = entity.attributes.get (ATTR_EMULATED_HUE_HIDDEN, None)
if explicit_expose is True or explicit_hidden is False :

Choose a reason for hiding this comment

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

whitespace before ':'

@@ -223,17 +224,24 @@ def is_entity_exposed(self, entity):

domain = entity.domain.lower()
explicit_expose = entity.attributes.get(ATTR_EMULATED_HUE, None)

explicit_hidden = entity.attributes.get (ATTR_EMULATED_HUE_HIDDEN, None)

Choose a reason for hiding this comment

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

whitespace before '('
line too long (80 > 79 characters)


return is_default_exposed or explicit_expose
return is_default_exposed or expose

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

domain_exposed_by_default = \
self.expose_by_default and domain in self.exposed_domains

# Expose an entity if the entity's domain is exposed by default and
# the configuration doesn't explicitly exclude it from being
# exposed, or if the entity is explicitly exposed
is_default_exposed = \
domain_exposed_by_default and explicit_expose is not False
domain_exposed_by_default and expose is not False

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

expose = False
if explicit_expose:
_LOGGER.warning("The attribute 'emulated_hue' is deprecated and"
"will be removed in a future version use"

Choose a reason for hiding this comment

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

unexpected indentation

else:
expose = False
if explicit_expose:
_LOGGER.warning("The attribute 'emulated_hue' is deprecated and"

Choose a reason for hiding this comment

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

trailing whitespace

expose = True
else:
expose = False
if explicit_expose:

Choose a reason for hiding this comment

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

continuation line missing indentation or outdented
multiple statements on one line (colon)

if explicit_expose is True or explicit_hidden is False:
expose = True
else:
expose = False

Choose a reason for hiding this comment

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

unexpected spaces around keyword / parameter equals

explicit_hidden = entity.attributes.get ATTR_EMULATED_HUE_HIDDEN, None)
if explicit_expose is True or explicit_hidden is False:
expose = True
else:

Choose a reason for hiding this comment

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

continuation line missing indentation or outdented
multiple statements on one line (colon)


explicit_hidden = e 8000 ntity.attributes.get ATTR_EMULATED_HUE_HIDDEN, None)
if explicit_expose is True or explicit_hidden is False:
expose = True

Choose a reason for hiding this comment

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

unexpected spaces around keyword / parameter equals

@@ -223,17 +224,25 @@ def is_entity_exposed(self, entity):

domain = entity.domain.lower()
explicit_expose = entity.attributes.get(ATTR_EMULATED_HUE, None)

explicit_hidden = entity.attributes.get ATTR_EMULATED_HUE_HIDDEN, None)
if explicit_expose is True or explicit_hidden is False:

Choose a reason for hiding this comment

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

continuation line missing indentation or outdented
multiple statements on one line (colon)

@@ -223,17 +224,25 @@ def is_entity_exposed(self, entity):

domain = entity.domain.lower()
explicit_expose = entity.attributes.get(ATTR_EMULATED_HUE, None)

explicit_hidden = entity.attributes.get ATTR_EMULATED_HUE_HIDDEN, None)

Choose a reason for hiding this comment

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

SyntaxError: invalid syntax

@fronzbot
Copy link
Contributor

Perhaps I'm misunderstanding, but If you want to standardize it wouldn't it make more sense to have a hidden attribute (or maybe exclude)? So then you can list the domains you want to hide a component from such as:

light.bedroom:
    hidden:
        - emulated_hue
        - homebridge
        - haaska

That way the implementation can scale for any number of platforms that would require certain components to be excluded from discovery.

Given the popularity of the emulated_hue platform, it seems to me that this change is disruptive without actually improving anything. My two cents anyhow. ¯\_(ツ)_/¯

else:
expose = None
if explicit_expose:
_LOGGER.warning("The attribute 'emulated_hue' is deprecated and"

Choose a reason for hiding this comment

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

trailing whitespace

Lint errors
@rbflurry rbflurry changed the title Hide from Emulated hue attr update Replace emulated_hue: with emulated_hue_hidden: for consistency. Sep 11, 2017
@balloob
Copy link
Member
balloob commented Sep 12, 2017

@fronzbot We already have a hidden attribute and it's a boolean for the frontend. Any hidden attribute for other things (emulated_hue, etc) should be via it's own attribute, no overloading. So this is the right approach.

else:
expose = None
if explicit_expose:
_LOGGER.warning("The attribute 'emulated_hue' is deprecated and"
Copy link
Member

Choose a reason for hiding this comment

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

Use helper.deprecation helpers instead.

Copy link
Member
@balloob balloob left a comment

Choose a reason for hiding this comment

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

This will require tests to be written.

@@ -98,6 +98,14 @@ def hass_hue(loop, hass):
hass.states.async_set(
kitchen_light_entity.entity_id, kitchen_light_entity.state,
attributes=attrs)

Choose a reason for hiding this comment

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

blank line contains whitespace

@balloob
Copy link
Member
balloob commented Sep 26, 2017

Thanks!

@balloob balloob merged commit fd9ceb7 into home-assistant:dev Sep 26, 2017
@balloob balloob mentioned this pull request Oct 5, 2017
@nikc0069
Copy link
nikc0069 commented Oct 8, 2017

Seems to me that the naming is confusing.

Emulated_hue_hidden: false implies it is not hidden. It should be true to hide.

@nikc0069
Copy link
nikc0069 commented Oct 8, 2017

Unless it's the documentation that needs to be a bit clearer. Specifying false is relatively pointless as it's the same as default

@kipwittchen
Copy link

I agree with @nikc0069, this is very confusing. If one has expose_by_default set to false, the old way of enabling a light would have been setting emulated_hue to true. Now with emulated_hue_hidden, that would also be set to true? That makes no sense, it implies that I'm saying yes to it being hidden. Seems like haaska and emulated hue should have had their parameter changed to "visible" or "shown" so that it's clear as to what true or false does.

@arsaboo
Copy link
Contributor
arsaboo commented Oct 9, 2017

emulated_hue_hidden: false does exactly what it says - the entity is not hidden. That is the same notation we use for Homebridge.

Also, please don't use closed PRs for such discussions.

@home-assistant home-assistant locked and limited conversation to collaborators Oct 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants
0