Update docstrings (#7374)

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstring

* Update docstrings

* Update docstrings

* Fix lint issues

* Update docstrings

* Revert changes in dict
This commit is contained in:
Fabian Affolter 2017-05-02 18:18:47 +02:00 committed by Paulus Schoutsen
parent 0e08925259
commit a4f1f6e724
340 changed files with 1533 additions and 1708 deletions

View file

@ -28,16 +28,17 @@ API_ACTION_URL = BASE_URL + '/v2/locks/{}?access_token={}&state={}'
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Lockitron platform."""
"""Set up the Lockitron platform."""
access_token = config.get(CONF_ACCESS_TOKEN)
device_id = config.get(CONF_ID)
response = requests.get(API_STATE_URL.format(device_id, access_token))
response = requests.get(
API_STATE_URL.format(device_id, access_token), timeout=5)
if response.status_code == 200:
add_devices([Lockitron(response.json()['state'], access_token,
device_id)])
else:
_LOGGER.error('Error retrieving lock status during init: %s',
response.text)
_LOGGER.error(
"Error retrieving lock status during init: %s", response.text)
class Lockitron(LockDevice):
@ -72,21 +73,20 @@ class Lockitron(LockDevice):
def update(self):
"""Update the internal state of the device."""
response = requests \
.get(API_STATE_URL.format(self.device_id, self.access_token))
response = requests.get(API_STATE_URL.format(
self.device_id, self.access_token), timeout=5)
if response.status_code == 200:
self._state = response.json()['state']
else:
_LOGGER.error('Error retrieving lock status: %s', response.text)
_LOGGER.error("Error retrieving lock status: %s", response.text)
def do_change_request(self, requested_state):
"""Execute the change request and pull out the new state."""
response = requests.put(
API_ACTION_URL.format(self.device_id, self.access_token,
requested_state))
response = requests.put(API_ACTION_URL.format(
self.device_id, self.access_token, requested_state), timeout=5)
if response.status_code == 200:
return response.json()['state']
else:
_LOGGER.error('Error setting lock state: %s\n%s',
_LOGGER.error("Error setting lock state: %s\n%s",
requested_state, response.text)
return self._state