Async syntax 7, switch & tts & vacuum (#17021)
This commit is contained in:
1 parent
9aaf11de8c
commit
121dba659c
20 files changed
+163
-253
No files matched your search
@@ -4,7 +4,6 @@ Support for IP Webcam settings.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.android_ip_webcam/
|
||||
"""
|
||||
import asyncio
|
||||
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
from homeassistant.components.android_ip_webcam import (
|
||||
@@ -14,9 +13,8 @@ from homeassistant.components.android_ip_webcam import (
|
||||
DEPENDENCIES = ['android_ip_webcam']
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the IP Webcam switch platform."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
@@ -51,8 +49,7 @@ class IPWebcamSettingsSwitch(AndroidIPCamEntity, SwitchDevice):
|
||||
"""Return the name of the node."""
|
||||
return self._name
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_update(self):
|
||||
async def async_update(self):
|
||||
"""Get the updated status of the switch."""
|
||||
self._state = bool(self._ipcam.current_settings.get(self._setting))
|
||||
|
||||
@@ -61,31 +58,29 @@ class IPWebcamSettingsSwitch(AndroidIPCamEntity, SwitchDevice):
|
||||
"""Return the boolean response if the node is on."""
|
||||
return self._state
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs):
|
||||
"""Turn device on."""
|
||||
if self._setting == 'torch':
|
||||
yield from self._ipcam.torch(activate=True)
|
||||
await self._ipcam.torch(activate=True)
|
||||
elif self._setting == 'focus':
|
||||
yield from self._ipcam.focus(activate=True)
|
||||
await self._ipcam.focus(activate=True)
|
||||
elif self._setting == 'video_recording':
|
||||
yield from self._ipcam.record(record=True)
|
||||
await self._ipcam.record(record=True)
|
||||
else:
|
||||
yield from self._ipcam.change_setting(self._setting, True)
|
||||
await self._ipcam.change_setting(self._setting, True)
|
||||
self._state = True
|
||||
self.async_schedule_update_ha_state()
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn device off."""
|
||||
if self._setting == 'torch':
|
||||
yield from self._ipcam.torch(activate=False)
|
||||
await self._ipcam.torch(activate=False)
|
||||
elif self._setting == 'focus':
|
||||
yield from self._ipcam.focus(activate=False)
|
||||
await self._ipcam.focus(activate=False)
|
||||
elif self._setting == 'video_recording':
|
||||
yield from self._ipcam.record(record=False)
|
||||
await self._ipcam.record(record=False)
|
||||
else:
|
||||
yield from self._ipcam.change_setting(self._setting, False)
|
||||
await self._ipcam.change_setting(self._setting, False)
|
||||
self._state = False
|
||||
self.async_schedule_update_ha_state()
|
||||
|
||||
|
||||
Reference in new issue
Block a user