This commit is contained in:
Paulus Schoutsen committed 2019-07-31 12:25:30 -07:00
1 parent da05dfe708
commit 4de97abc3a
2676 files changed
+163166 -140084

No files matched your search

@@ -2,12 +2,17 @@
from homeassistant.components.switch import SwitchDevice
from . import (
CONF_HOST, CONF_NAME, CONF_SWITCHES, DATA_IP_WEBCAM, ICON_MAP, KEY_MAP,
AndroidIPCamEntity)
CONF_HOST,
CONF_NAME,
CONF_SWITCHES,
DATA_IP_WEBCAM,
ICON_MAP,
KEY_MAP,
AndroidIPCamEntity,
)
async 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
@@ -34,7 +39,7 @@ class IPWebcamSettingsSwitch(AndroidIPCamEntity, SwitchDevice):
self._setting = setting
self._mapped_name = KEY_MAP.get(self._setting, self._setting)
self._name = '{} {}'.format(name, self._mapped_name)
self._name = "{} {}".format(name, self._mapped_name)
self._state = False
@property
@@ -53,11 +58,11 @@ class IPWebcamSettingsSwitch(AndroidIPCamEntity, SwitchDevice):
async def async_turn_on(self, **kwargs):
"""Turn device on."""
if self._setting == 'torch':
if self._setting == "torch":
await self._ipcam.torch(activate=True)
elif self._setting == 'focus':
elif self._setting == "focus":
await self._ipcam.focus(activate=True)
elif self._setting == 'video_recording':
elif self._setting == "video_recording":
await self._ipcam.record(record=True)
else:
await self._ipcam.change_setting(self._setting, True)
@@ -66,11 +71,11 @@ class IPWebcamSettingsSwitch(AndroidIPCamEntity, SwitchDevice):
async def async_turn_off(self, **kwargs):
"""Turn device off."""
if self._setting == 'torch':
if self._setting == "torch":
await self._ipcam.torch(activate=False)
elif self._setting == 'focus':
elif self._setting == "focus":
await self._ipcam.focus(activate=False)
elif self._setting == 'video_recording':
elif self._setting == "video_recording":
await self._ipcam.record(record=False)
else:
await self._ipcam.change_setting(self._setting, False)
@@ -80,4 +85,4 @@ class IPWebcamSettingsSwitch(AndroidIPCamEntity, SwitchDevice):
@property
def icon(self):
"""Return the icon for the switch."""
return ICON_MAP.get(self._setting, 'mdi:flash')
return ICON_MAP.get(self._setting, "mdi:flash")