Skip to content

Commit

Permalink
Added set_eureka_info and enable_control_notifications (#2)
Browse files Browse the repository at this point in the history
* Added set_eureka_info and enable_control_notifications

* rename to control_notifications
  • Loading branch information
ludeeus authored and eliseomartelli committed Nov 23, 2018
1 parent a72fc81 commit ee398e0
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions googledevices/device_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,37 @@ async def reboot(self):
aiohttp.ClientError, socket.gaierror) as error:
_LOGGER.error('Error connecting to googledevices, %s', error)
return returnvalue

async def set_eureka_info(self, data):
"""Set eureka info."""
endpoint = '/setup/set_eureka_info'
url = API.format(ip=self._ipaddress, endpoint=endpoint)
returnvalue = False
try:
async with async_timeout.timeout(5, loop=self._loop):
result = await self._session.post(url, json=data,
headers=HEADERS)
if result.status == 200:
returnvalue = True
except (asyncio.TimeoutError,
aiohttp.ClientError, socket.gaierror) as error:
_LOGGER.error('Error connecting to googledevices, %s', error)
return returnvalue

async def control_notifications(self, active):
"""Set control_notifications option."""
endpoint = '/setup/set_eureka_info'
url = API.format(ip=self._ipaddress, endpoint=endpoint)
value = 1 if active else 2
data = {'settings': {'control_notifications': value}}
returnvalue = False
try:
async with async_timeout.timeout(5, loop=self._loop):
result = await self._session.post(url, json=data,
headers=HEADERS)
if result.status == 200:
returnvalue = True
except (asyncio.TimeoutError,
aiohttp.ClientError, socket.gaierror) as error:
_LOGGER.error('Error connecting to googledevices, %s', error)
return returnvalue

0 comments on commit ee398e0

Please sign in to comment.