simplifications
This commit is contained in:
@@ -195,7 +195,7 @@ class RoomController(Hass):
|
|||||||
def activate(self, **kwargs):
|
def activate(self, **kwargs):
|
||||||
self.call_service(f'{self.name}/activate', namespace='controller', **kwargs)
|
self.call_service(f'{self.name}/activate', namespace='controller', **kwargs)
|
||||||
|
|
||||||
def _service_activate(self, namespace: str, domain: str, service: str, **kwargs: Dict[str, Any]):
|
def _service_activate(self, namespace: str, domain: str, service: str, **kwargs):
|
||||||
# self.log(f'Custom kwargs: {kwargs}', level='DEBUG')
|
# self.log(f'Custom kwargs: {kwargs}', level='DEBUG')
|
||||||
state = self.current_state()
|
state = self.current_state()
|
||||||
if isinstance(state.scene, str):
|
if isinstance(state.scene, str):
|
||||||
@@ -210,9 +210,7 @@ class RoomController(Hass):
|
|||||||
"""Activate if any of the entities are on. Args and kwargs are passed directly to self.activate()"""
|
"""Activate if any of the entities are on. Args and kwargs are passed directly to self.activate()"""
|
||||||
self.call_service(f'{self.name}/activate_any_on', namespace='controller', **kwargs)
|
self.call_service(f'{self.name}/activate_any_on', namespace='controller', **kwargs)
|
||||||
|
|
||||||
def _service_activate_any_on(
|
def _service_activate_any_on(self, namespace: str, domain: str, service: str, **kwargs):
|
||||||
self, namespace: str, domain: str, service: str, **kwargs: Dict[str, Any]
|
|
||||||
):
|
|
||||||
if self.any_on() and not self.manual_mode():
|
if self.any_on() and not self.manual_mode():
|
||||||
self.activate(**kwargs)
|
self.activate(**kwargs)
|
||||||
|
|
||||||
@@ -220,25 +218,21 @@ class RoomController(Hass):
|
|||||||
"""Activate if all of the entities are off. Args and kwargs are passed directly to self.activate()"""
|
"""Activate if all of the entities are off. Args and kwargs are passed directly to self.activate()"""
|
||||||
self.call_service(f'{self.name}/activate_all_off', namespace='controller', **kwargs)
|
self.call_service(f'{self.name}/activate_all_off', namespace='controller', **kwargs)
|
||||||
|
|
||||||
def _service_activate_all_off(
|
def _service_activate_all_off(self, namespace: str, domain: str, service: str, **kwargs):
|
||||||
self, namespace: str, domain: str, service: str, **kwargs: Dict[str, Any]
|
|
||||||
):
|
|
||||||
if self.all_off() and not self.manual_mode():
|
if self.all_off() and not self.manual_mode():
|
||||||
self.activate(**kwargs)
|
self.activate(**kwargs)
|
||||||
|
|
||||||
def deactivate(self, **kwargs):
|
def deactivate(self, **kwargs):
|
||||||
self.call_service(f'{self.name}/deactivate', namespace='controller', **kwargs)
|
self.call_service(f'{self.name}/deactivate', namespace='controller', **kwargs)
|
||||||
|
|
||||||
def _service_deactivate(
|
def _service_deactivate(self, namespace: str, domain: str, service: str, **kwargs):
|
||||||
self, namespace: str, domain: str, service: str, **kwargs: Dict[str, Any]
|
|
||||||
):
|
|
||||||
for e in self.app_entities:
|
for e in self.app_entities:
|
||||||
self.turn_off(e)
|
self.turn_off(e)
|
||||||
|
|
||||||
def toggle(self, **kwargs):
|
def toggle(self, **kwargs):
|
||||||
self.call_service(f'{self.name}/toggle', namespace='controller', **kwargs)
|
self.call_service(f'{self.name}/toggle', namespace='controller', **kwargs)
|
||||||
|
|
||||||
def _service_toggle(self, namespace: str, domain: str, service: str, **kwargs: Dict[str, Any]):
|
def _service_toggle(self, namespace: str, domain: str, service: str, **kwargs):
|
||||||
if self.any_on():
|
if self.any_on():
|
||||||
self.deactivate(**kwargs)
|
self.deactivate(**kwargs)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user