Remove service helper (3) (#16879)

* Update duckdns

* Update google_assistant

* Update group

* Update homematic

* Update image_processing

* Update input_boolean

* Update input_number

* Update input_select

* Update input_text
This commit is contained in:
cdce8p authored and Paulus Schoutsen committed 2018-09-26 08:50:05 +02:00
1 parent 672fc61bb2
commit e2a56721d3
22 files changed
+217 -231

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
"""Collection of helper methods.
All containing methods are legacy helpers that should not be used by new
components. Instead call the service directly.
"""
from homeassistant.components.group import ATTR_VISIBLE, DOMAIN, \
SERVICE_SET_VISIBILITY
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.loader import bind_hass
@bind_hass
def set_visibility(hass, entity_id=None, visible=True):
"""Hide or shows a group."""
data = {ATTR_ENTITY_ID: entity_id, ATTR_VISIBLE: visible}
hass.services.call(DOMAIN, SERVICE_SET_VISIBILITY, data)
+3 -2
View File
@@ -12,6 +12,7 @@ from homeassistant.const import (
import homeassistant.components.group as group
from tests.common import get_test_home_assistant, assert_setup_component
from tests.components.group import common
class TestComponentsGroup(unittest.TestCase):
@@ -385,13 +386,13 @@ class TestComponentsGroup(unittest.TestCase):
group_entity_id = group.ENTITY_ID_FORMAT.format('test_group')
# Hide the group
group.set_visibility(self.hass, group_entity_id, False)
common.set_visibility(self.hass, group_entity_id, False)
self.hass.block_till_done()
group_state = self.hass.states.get(group_entity_id)
self.assertTrue(group_state.attributes.get(ATTR_HIDDEN))
# Show it again
group.set_visibility(self.hass, group_entity_id, True)
common.set_visibility(self.hass, group_entity_id, True)
self.hass.block_till_done()
group_state = self.hass.states.get(group_entity_id)
self.assertIsNone(group_state.attributes.get(ATTR_HIDDEN))