-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing classes and methods (#37)
* copy bluetooth -> wifi * Add mode (now/fdr) to reboot * set_night_mode_params * get_configured_networks * get_wifi_scan_result * Add new classes to connect * scan_for_wifi * forget_network * get_paired_devices * forget_paired_device * docstring update * pair_with_mac * get_offer * timezones and locales * speedtest * get_app_device_id * lint * lint * set_accessibility * delete_alarms * set_equalizer * the rest * add headers * add assistant to test * PRINT JSON * cleanup and add rest to test * test * move things * update test * remove test * Alarm -> Assistant
- Loading branch information
1 parent
ec7a258
commit afe936d
Showing
9 changed files
with
460 additions
and
89 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
"""Controll Assistant settings on the unit.""" | ||
from googledevices.utils.const import CASTPORT, HEADERS | ||
from googledevices.helpers import gdh_request | ||
import googledevices.utils.log as log | ||
|
||
|
||
class Assistant(object): | ||
"""A class for Assistant settings.""" | ||
|
||
def __init__(self, host, loop, session): | ||
"""Initialize the class.""" | ||
self.host = host | ||
self.loop = loop | ||
self.session = session | ||
self._alarms = [] | ||
self._alarmvolume = None | ||
|
||
async def set_night_mode_params(self, data): | ||
"""Set night mode options.""" | ||
endpoint = 'setup/assistant/set_night_mode_params' | ||
result = await gdh_request(host=self.host, port=CASTPORT, | ||
endpoint=endpoint, method='post', | ||
loop=self.loop, session=self.session, | ||
json_data=data, headers=HEADERS) | ||
return result | ||
|
||
async def notifications_enabled(self, mode=True): | ||
"""Set notifications_enabled True/False.""" | ||
endpoint = 'setup/assistant/notifications' | ||
data = {"notifications_enabled": mode} | ||
result = await gdh_request(host=self.host, port=CASTPORT, | ||
endpoint=endpoint, method='post', | ||
loop=self.loop, session=self.session, | ||
json_data=data, headers=HEADERS) | ||
return result | ||
|
||
async def set_accessibility(self, start=True, end=False): | ||
"""Set accessibility True/False.""" | ||
endpoint = 'setup/assistant/a11y_mode' | ||
data = {"endpoint_enabled": end, "hotword_enabled": start} | ||
result = await gdh_request(host=self.host, port=CASTPORT, | ||
endpoint=endpoint, method='post', | ||
loop=self.loop, session=self.session, | ||
json_data=data, headers=HEADERS) | ||
return result | ||
|
||
async def delete_alarms(self, data): | ||
"""Delete active alarms and timers.""" | ||
endpoint = 'setup/assistant/alarms/delete' | ||
result = await gdh_request(host=self.host, port=CASTPORT, | ||
endpoint=endpoint, method='post', | ||
loop=self.loop, session=self.session, | ||
json_data=data, headers=HEADERS) | ||
return result | ||
|
||
async def set_equalizer(self, low_gain=0, high_gain=0): | ||
"""Set equalizer db gain.""" | ||
endpoint = 'setup/user_eq/set_equalizer' | ||
returnvalue = False | ||
data = { | ||
"low_shelf": {"gain_db": low_gain}, | ||
"high_shelf": {"gain_db": high_gain} | ||
} | ||
result = await gdh_request(host=self.host, port=CASTPORT, | ||
endpoint=endpoint, method='post', | ||
loop=self.loop, session=self.session, | ||
json_data=data, headers=HEADERS, | ||
json=False) | ||
try: | ||
if result.status == 200: | ||
returnvalue = True | ||
except AttributeError: | ||
msg = "Error connecting to - {}".format(self.host) | ||
log.error(msg) | ||
return returnvalue | ||
|
||
async def get_alarms(self): | ||
"""Get the alarms from the device.""" | ||
endpoint = 'setup/assistant/alarms' | ||
response = await gdh_request(host=self.host, port=CASTPORT, | ||
loop=self.loop, session=self.session, | ||
endpoint=endpoint, headers=HEADERS) | ||
self._alarms = response | ||
log.debug(self._alarms) | ||
return self._alarms | ||
|
||
async def get_alarm_volume(self): | ||
"""Get the alarm volume for the device.""" | ||
endpoint = 'setup/assistant/alarms/volume' | ||
response = await gdh_request(host=self.host, port=CASTPORT, | ||
loop=self.loop, session=self.session, | ||
endpoint=endpoint, headers=HEADERS, | ||
method='post') | ||
self._alarmvolume = response | ||
log.debug(self._alarmvolume) | ||
return self._alarmvolume | ||
|
||
async def set_alarm_volume(self, volume): | ||
"""Set the alarm volume for the device.""" | ||
data = {'volume': volume} | ||
endpoint = 'setup/assistant/alarms/volume' | ||
returnvalue = False | ||
result = await gdh_request(host=self.host, port=CASTPORT, | ||
endpoint=endpoint, method='post', | ||
loop=self.loop, session=self.session, | ||
json_data=data, headers=HEADERS, | ||
json=False) | ||
try: | ||
if result.status == 200: | ||
returnvalue = True | ||
except AttributeError: | ||
msg = "Error connecting to - {}".format(self.host) | ||
log.error(msg) | ||
return returnvalue | ||
|
||
@property | ||
def alarms(self): | ||
"""Return the alarms.""" | ||
return self._alarms | ||
|
||
@property | ||
def alarm_volume(self): | ||
"""Return the alarm volume.""" | ||
return self._alarmvolume |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.