Replace emulated_hue: with emulated_hue_hidden: for consistency. (#9382)

* Update __init__.py

* fix lint errors

* Update __init__.py

* Update __init__.py

* Update __init__.py

* Update __init__.py

* Update __init__.py

Lint errors

* use get_deprecated instead to log old attr

* Updated tests to hide fan.ceiling_fan

* remove space fix lint
This commit is contained in:
rbflurry 2017-09-26 03:31:35 -04:00 committed by Paulus Schoutsen
parent 154b070eae
commit fd9ceb7381
2 changed files with 22 additions and 3 deletions

View file

@ -16,6 +16,7 @@ from homeassistant.const import (
)
from homeassistant.components.http import REQUIREMENTS # NOQA
from homeassistant.components.http import HomeAssistantWSGI
from homeassistant.helpers.deprecation import get_deprecated
import homeassistant.helpers.config_validation as cv
from .hue_api import (
HueUsernameView, HueAllLightsStateView, HueOneLightStateView,
@ -66,6 +67,7 @@ CONFIG_SCHEMA = vol.Schema({
}, extra=vol.ALLOW_EXTRA)
ATTR_EMULATED_HUE = 'emulated_hue'
ATTR_EMULATED_HUE_HIDDEN = 'emulated_hue_hidden'
def setup(hass, yaml_config):
@ -223,7 +225,15 @@ class Config(object):
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:
expose = True
elif explicit_expose is False or explicit_hidden is True:
expose = False
else:
expose = None
get_deprecated(entity.attributes, ATTR_EMULATED_HUE_HIDDEN,
ATTR_EMULATED_HUE, None)
domain_exposed_by_default = \
self.expose_by_default and domain in self.exposed_domains
@ -231,9 +241,9 @@ class Config(object):
# 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
return is_default_exposed or explicit_expose
return is_default_exposed or expose
def _load_numbers_json(self):
"""Set up helper method to load numbers json."""

View file

@ -99,6 +99,14 @@ def hass_hue(loop, hass):
kitchen_light_entity.entity_id, kitchen_light_entity.state,
attributes=attrs)
# Ceiling Fan is explicitly excluded from being exposed
ceiling_fan_entity = hass.states.get('fan.ceiling_fan')
attrs = dict(ceiling_fan_entity.attributes)
attrs[emulated_hue.ATTR_EMULATED_HUE_HIDDEN] = True
hass.states.async_set(
ceiling_fan_entity.entity_id, ceiling_fan_entity.state,
attributes=attrs)
# Expose the script
script_entity = hass.states.get('script.set_kitchen_light')
attrs = dict(script_entity.attributes)
@ -146,6 +154,7 @@ def test_discover_lights(hue_client):
assert 'media_player.walkman' in devices
assert 'media_player.lounge_room' in devices
assert 'fan.living_room_fan' in devices
assert 'fan.ceiling_fan' not in devices
@asyncio.coroutine