Refactored component 'general' into components.__init__
This commit is contained in:
1 parent
0fc3d359cb
commit
097a51abc6
8 files changed
+144
-145
No files matched your search
@@ -8,7 +8,7 @@ Provides functionality to group devices that can be turned on or off.
|
||||
import logging
|
||||
|
||||
import homeassistant as ha
|
||||
from homeassistant.components import general as gen
|
||||
import homeassistant.components as components
|
||||
|
||||
DOMAIN = "group"
|
||||
|
||||
@@ -17,8 +17,8 @@ ENTITY_ID_FORMAT = DOMAIN + ".{}"
|
||||
STATE_ATTR_ENTITY_IDS = "entity_ids"
|
||||
|
||||
_GROUP_TYPES = {
|
||||
"on_off": (gen.STATE_ON, gen.STATE_OFF),
|
||||
"home_not_home": (gen.STATE_HOME, gen.STATE_NOT_HOME)
|
||||
"on_off": (components.STATE_ON, components.STATE_OFF),
|
||||
"home_not_home": (components.STATE_HOME, components.STATE_NOT_HOME)
|
||||
}
|
||||
|
||||
|
||||
@@ -141,28 +141,28 @@ def setup(bus, statemachine, name, entity_ids):
|
||||
# group.setup is called to setup each group. Only the first time will we
|
||||
# register a turn_on and turn_off method for groups.
|
||||
|
||||
if not bus.has_service(DOMAIN, gen.SERVICE_TURN_ON):
|
||||
if not bus.has_service(DOMAIN, components.SERVICE_TURN_ON):
|
||||
def _turn_group_on_service(service):
|
||||
""" Call general.turn_on for each entity_id from this group. """
|
||||
""" Call components.turn_on for each entity_id from this group. """
|
||||
for entity_id in get_entity_ids(statemachine,
|
||||
service.data.get(
|
||||
gen.ATTR_ENTITY_ID)):
|
||||
components.ATTR_ENTITY_ID)):
|
||||
|
||||
gen.turn_on(bus, entity_id)
|
||||
components.turn_on(bus, entity_id)
|
||||
|
||||
bus.register_service(DOMAIN, gen.SERVICE_TURN_ON,
|
||||
bus.register_service(DOMAIN, components.SERVICE_TURN_ON,
|
||||
_turn_group_on_service)
|
||||
|
||||
if not bus.has_service(DOMAIN, gen.SERVICE_TURN_OFF):
|
||||
if not bus.has_service(DOMAIN, components.SERVICE_TURN_OFF):
|
||||
def _turn_group_off_service(service):
|
||||
""" Call general.turn_off for each entity_id from this group. """
|
||||
""" Call components.turn_off for each entity_id in this group. """
|
||||
for entity_id in get_entity_ids(statemachine,
|
||||
service.data.get(
|
||||
gen.ATTR_ENTITY_ID)):
|
||||
components.ATTR_ENTITY_ID)):
|
||||
|
||||
gen.turn_off(bus, entity_id)
|
||||
components.turn_off(bus, entity_id)
|
||||
|
||||
bus.register_service(DOMAIN, gen.SERVICE_TURN_OFF,
|
||||
bus.register_service(DOMAIN, components.SERVICE_TURN_OFF,
|
||||
_turn_group_off_service)
|
||||
|
||||
statemachine.set_state(group_entity_id, group_state, state_attr)
|
||||
|
||||
Reference in new issue
Block a user